Compare commits

...

628 Commits

Author SHA1 Message Date
coah
dd2993f12d Match RVL SDK FAFinfo wrapper 2026-09-23 02:26:52 +00:00
coah
4b71db7dfd Match FAInitDiskManager data (#207) 2026-09-22 21:23:18 -05:00
coah
e052c9ae0c Match RVL SDK ferror wrapper (#206) 2026-09-22 21:22:57 -05:00
coah
a843f0770f Match RVL SDK flock wrapper (#204) 2026-09-22 03:49:37 -05:00
coah
c356c90f22 Match RVL SDK ferror wrapper (#203) 2026-09-22 03:49:32 -05:00
coah
6af767089f Match RVL SDK FAFclose wrapper (#201) 2026-09-22 03:40:42 -05:00
coah
bee0a51dbf Match MSL wctype tables (#200) 2026-09-22 03:40:29 -05:00
coah
d9e7306a99 Match RVL SDK errnum wrapper (#198) 2026-09-22 03:37:57 -05:00
coah
f214b726b5 Match RVL SDK closedir wrapper (#190) 2026-09-22 03:35:37 -05:00
coah
cbe489cd37 Match AXFX HiExp reverb unit (#195) 2026-09-22 03:33:39 -05:00
coah
d78ab4cfd1 Link matching www browser unit (#193) 2026-09-22 03:32:00 -05:00
coah
311b437e5f Match RVL SDK feof wrapper (#192) 2026-09-22 03:31:56 -05:00
coah
8581b15e80 Match RVL SDK OS exception jump (#191) 2026-09-22 03:31:22 -05:00
coah
16317c11e2 Match RVLFaceLib controller data (#188) 2026-09-22 03:28:53 -05:00
coah
667b9f6fa2 Match MSL wide string helpers (#187) 2026-09-22 03:27:28 -05:00
coah
bf479c7e3f Match ChannelTitle unit (#182) 2026-09-22 03:22:51 -05:00
coah
5ce99fb34c Match RVL SDK fsync wrapper (#179) 2026-09-22 03:19:44 -05:00
coah
44a074bdce Link matching TVRC unit (#178) 2026-09-22 03:17:51 -05:00
coah
59e3ec6007 Match Kitayama normal state (#175) 2026-09-22 03:13:59 -05:00
coah
f9a70d7d43 Match RVL SDK fclose wrapper (#174) 2026-09-22 03:12:48 -05:00
coah
e5adf3de29 Link matching TMC JPEG inverse quantizer (#173) 2026-09-22 03:11:46 -05:00
coah
373ea6a875 Link matching TMC JPEG jdec_main unit (#172) 2026-09-22 03:11:09 -05:00
coah
84c3af7235 Link matching TMC Huffman decoder (#171) 2026-09-22 03:09:50 -05:00
coah
1f0ce55081 Link matching iplDate unit (#170) 2026-09-22 03:09:47 -05:00
coah
002e2e7e36 Link matching NWC24 user ID unit (#168) 2026-09-22 03:07:33 -05:00
coah
6713cca2e3 Match MSL file position helpers (#167) 2026-09-22 03:06:52 -05:00
coah
43fb4f1bb7 Match MSL extras unit (#165) 2026-09-22 03:06:49 -05:00
coah
e926be4585 Match RVLFaceLib system unit (#166) 2026-09-22 03:05:56 -05:00
coah
8d95ccd8ab Match CDB filesystem data padding (#164) 2026-09-22 03:05:14 -05:00
coah
cf3d7c4393 Link matching system menu CSPane unit (#163) 2026-09-22 03:03:43 -05:00
coah
da448d002b Link matching RevoEX SD driver unit (#162) 2026-09-22 03:02:46 -05:00
coah
d6c74589e5 Match RVL SDK fwrite wrapper (#161) 2026-09-22 03:02:43 -05:00
coah
63492be139 Link matching EGG audio manager unit (#160) 2026-09-22 03:02:39 -05:00
coah
bede348ee3 Mark TMC JPEG getcode matching (#157) 2026-09-22 02:59:55 -05:00
coah
75bdcc3e2c Match tiPredictLang rodata padding (#159) 2026-09-22 02:58:36 -05:00
coah
4872b6e925 Match RevoEX WDScan data (#158) 2026-09-22 02:57:22 -05:00
coah
7b96616b53 Link matching EGG ArcPlayer unit (#156) 2026-09-22 02:55:23 -05:00
coah
b9895bb3d6 Match MSL direct IO (#155) 2026-09-22 02:55:20 -05:00
coah
22961c86a3 Match RVL SDK fread wrapper (#154) 2026-09-22 02:54:44 -05:00
coah
e4b8d405ed Match d_vf_sys unit (#153) 2026-09-22 02:52:40 -05:00
coah
584dbb6906 Match MSL multibyte string helpers (#152) 2026-09-22 02:51:42 -05:00
coah
2f865cb308 Match CDB record key dictionary (#151) 2026-09-22 02:49:57 -05:00
coah
476e471184 fix: match CNTCACHE data (#150) 2026-09-22 02:49:53 -05:00
coah
45514dad2d Link matching EGG audio expansion unit (#149) 2026-09-22 02:46:27 -05:00
coah
9e2b86d38a Match iplwww browser window (#148) 2026-09-22 02:43:48 -05:00
coah
86ed50ab79 Match CDBConv (#147) 2026-09-22 02:35:56 -05:00
coah
4a30cfa843 Link matching eZiText zHuwd unit (#146) 2026-09-22 02:32:04 -05:00
coah
bb3365c7da Merge pull request #145 from coah80/agent/continue-0922/refill03-next9
Link matching MSL string unit
2026-09-22 02:25:29 -05:00
coah
511b8d2a57 Link matching MSL string unit 2026-09-22 07:23:26 +00:00
coah
98f0f11dc7 Merge pull request #144 from coah80/agent/refill05/next-unit6
Match RVLFaceLib random face
2026-09-22 02:22:54 -05:00
coah
e194e9ccd4 Merge pull request #143 from coah80/agent/continue-0922/refill15-pf_fatfs
Match RVL SDK FATFS wrapper
2026-09-22 02:22:51 -05:00
coah
9b89894ee2 Match RVLFaceLib random face 2026-09-22 07:21:49 +00:00
coah
71c1c07d3b Match RVL SDK FATFS wrapper 2026-09-22 07:21:27 +00:00
coah
12e0ec188d Merge pull request #142 from coah80/agent/continue-0922/32-iplPostmanManager-pr
[codex] Match CNTCACHE unit
2026-09-22 02:13:06 -05:00
coah
93b2f44cfc Match CNTCACHE unit 2026-09-22 07:12:05 +00:00
coah
9df26503a6 Merge pull request #141 from coah80/agent/refill05/next-unit5
Match RevoEX SSL API data
2026-09-22 02:09:58 -05:00
coah
836a348b64 Merge pull request #140 from coah80/agent/continue-0922/17-next
[codex] Match channel script matrix data
2026-09-22 02:09:54 -05:00
coah
8201dbba31 Merge pull request #139 from coah80/agent/continue-0922/refill21-NWC24StdAPI
Match NWC24 standard API
2026-09-22 02:09:12 -05:00
coah
1711e860c7 Match RevoEX SSL API data 2026-09-22 07:08:41 +00:00
coah
0c3af7ea2e Merge pull request #138 from coah80/agent/refill24-ncdsystem
decomp: match RevoEX ncdsystem
2026-09-22 02:08:31 -05:00
coah
fb539fe968 Merge pull request #137 from coah80/agent/continue-0922/refill03-next8
Link eZiText zaddress unit
2026-09-22 02:08:20 -05:00
coah
cd2a126243 decomp: match RevoEX ncdsystem 2026-09-22 07:07:16 +00:00
coah
620f8c8b4e Merge remote-tracking branch 'origin/main' into agent/continue-0922/refill21-NWC24StdAPI 2026-09-22 07:06:56 +00:00
coah
7bf0665f40 Link eZiText zaddress unit 2026-09-22 07:06:33 +00:00
coah
f5ccda1cb4 Merge pull request #136 from coah80/agent/continue-0922/refill15-FAFwrite
Match RVL SDK FAFwrite
2026-09-22 02:06:02 -05:00
coah
4c84325f64 Match FAFwrite wrapper 2026-09-22 07:05:33 +00:00
coah
380c8a059c Merge origin/main 2026-09-22 07:05:22 +00:00
coah
df19b05818 Match NWC24 standard API 2026-09-22 07:05:09 +00:00
coah
e27bb4c191 Merge pull request #134 from coah80/agent/continue-0922/refill15-FAFread
Match RVL SDK FAFread
2026-09-22 01:59:41 -05:00
coah
6aafa4acfe Merge pull request #135 from coah80/agent/continue-0922/refill03-next7
Link SD interface unit
2026-09-22 01:59:37 -05:00
coah
704850f5dd Link SD interface unit 2026-09-22 06:58:44 +00:00
coah
ca4acc8625 Match FAFread wrapper 2026-09-22 06:56:49 +00:00
coah
9e9c6bcd54 Match channel script matrix data 2026-09-22 06:54:58 +00:00
coah
1975cefade Merge pull request #133 from coah80/agent/refill05/next-unit4
Match get_cursor_pos
2026-09-22 01:54:20 -05:00
coah
721f9907df Merge pull request #132 from coah80/agent/continue-0922/refill03-next6
Link text input GUI manager
2026-09-22 01:52:46 -05:00
coah
21c1e8a207 Match get_cursor_pos 2026-09-22 06:52:29 +00:00
coah
34f121b783 Merge pull request #128 from coah80/agent/refill51/nwc24-userid
[codex] Match NWC24UserId
2026-09-22 01:52:22 -05:00
coah
8647740dd8 Link text input GUI manager 2026-09-22 06:51:53 +00:00
coah
84d8c7fe7a Merge pull request #131 from coah80/agent/continue-0922/17-iplNigaoe
[codex] Match keyboard GUI manager
2026-09-22 01:49:42 -05:00
coah
8923728dc4 Match keyboard GUI manager 2026-09-22 06:48:36 +00:00
coah
71b4ac3296 Merge pull request #130 from coah80/agent/continue-0922/refill15-tiInputForm
Match tiInputForm word wrapping
2026-09-22 01:48:01 -05:00
coah
21c4d9b7d9 Merge pull request #129 from coah80/agent/continue-0922/refill03-next5
Link NWC24 friend list unit
2026-09-22 01:47:14 -05:00
coah
558bb52727 Link NWC24 friend list unit 2026-09-22 06:46:34 +00:00
coah
cacffaa5ee Merge pull request #127 from coah80/agent/refill04/next-unit
Match channel edit box unit
2026-09-22 01:22:49 -05:00
coah
d4cb1ee2ee Merge pull request #126 from coah80/agent/refill61/cdbdatabase
Link matching CDBDatabase unit
2026-09-22 01:22:22 -05:00
coah
ec93b2aad3 Match NWC24 user ID validation 2026-09-22 06:21:34 +00:00
coah
f026821af2 Link matching CDBDatabase unit 2026-09-22 06:20:23 +00:00
coah
dd369fbb8c Match channel edit box unit 2026-09-22 06:17:42 +00:00
coah
47f78dcead Match tiInputForm word wrapping 2026-09-22 06:17:40 +00:00
coah
d951489ea3 Merge pull request #125 from coah80/agent/continue-0922/refill03-next4
Link board URL processor unit
2026-09-22 01:16:45 -05:00
coah
2afb673a8e Link board URL processor unit 2026-09-22 06:15:34 +00:00
coah
5b7475fe54 Merge pull request #124 from coah80/agent/refill05/next-unit3
Match iplCSMtx data
2026-09-22 01:14:20 -05:00
coah
51f1c36f3f Match iplCSMtx data 2026-09-22 06:10:52 +00:00
coah
eb2d67bfe3 Merge pull request #123 from coah80/agent/continue-0922/refill03-next3
Link NW4R ArchiveFont unit
2026-09-22 01:10:06 -05:00
coah
e167441313 Link NW4R ArchiveFont unit 2026-09-22 05:56:44 +00:00
coah
fcf28f93e2 Merge pull request #122 from coah80/agent/refill61/cardblock
Link matching CARDBlock unit
2026-09-22 00:54:23 -05:00
coah
956f076799 Merge pull request #121 from coah80/agent/continue-0922/tools-wchar
[codex] Match MSL wide stream orientation
2026-09-22 00:53:53 -05:00
coah
3283047615 Link matching CARDBlock unit 2026-09-22 05:53:13 +00:00
coah
d0f6f8a7b9 Match MSL wide stream orientation 2026-09-22 05:52:40 +00:00
coah
8bec89c069 Merge pull request #120 from coah80/agent/continue-0922/65-signal
Match MSL signal
2026-09-22 00:51:23 -05:00
coah
84ce6d4198 Match MSL signal 2026-09-22 05:47:20 +00:00
coah
fba54700b6 Merge pull request #119 from coah80/agent/refill05/next-unit2
Match UrlProcessor unit
2026-09-22 00:46:15 -05:00
coah
748265e71b Merge pull request #118 from coah80/agent/continue-0922/49-SOCommon-pr
Match RevoEX SO common
2026-09-22 00:44:09 -05:00
coah
06e8788815 Match RevoEX SO common 2026-09-22 05:42:50 +00:00
coah
44a7f17e41 Match UrlProcessor unit 2026-09-22 05:41:56 +00:00
coah
e1bd339ba5 Merge pull request #116 from coah80/agent/continue-0922/refill03-next2
Link RevoEX NWC24 CH jump unit
2026-09-22 00:40:35 -05:00
coah
0532e405d3 Merge pull request #115 from coah80/agent/continue-0922/61-cdbfilesystemutils
Link matching CDB filesystem utilities
2026-09-22 00:39:46 -05:00
coah
961a1b0431 Merge pull request #114 from coah80/agent/continue-0922/tools-misc
[codex] Match MSL misc IO hook
2026-09-22 00:38:57 -05:00
coah
e65297484f Match MSL misc IO hook 2026-09-22 05:37:53 +00:00
coah
10f3bbc57c Merge pull request #113 from coah80/agent/refill-0922/nwc24manage-pr
[codex] Link NWC24Manage
2026-09-22 00:36:05 -05:00
coah
747e87959f Link matching CDB filesystem utilities 2026-09-22 05:35:39 +00:00
coah
0f89a4218d Link RevoEX NWC24 CH jump unit 2026-09-22 05:34:33 +00:00
coah
d0127008b2 Link NWC24Manage 2026-09-22 05:33:12 +00:00
coah
8f31470be5 Merge pull request #102 from coah80/agent/continue-0922/04-iplSystem
Match iplSystem unit
2026-09-22 00:32:43 -05:00
coah
8a46eaae2d Merge pull request #112 from coah80/agent/continue-0922/tools-buffer
[codex] Link matching MSL buffer IO
2026-09-22 00:32:04 -05:00
coah
55946192bf Merge pull request #111 from coah80/agent/continue-0922/65-qsort
Match MSL qsort
2026-09-22 00:31:17 -05:00
coah
f5486c85f4 Link matching MSL buffer IO 2026-09-22 05:31:04 +00:00
coah
bcbffb2c06 Match MSL qsort 2026-09-22 05:28:43 +00:00
coah
3793ce8c4e Match iplSystem unit 2026-09-22 05:28:25 +00:00
coah
5cd7bcb31f Merge pull request #110 from coah80/agent/refill05/next-unit
Match NWC24 friend list
2026-09-22 00:27:48 -05:00
coah
c6ae812dd3 Match NWC24 friend list 2026-09-22 05:24:44 +00:00
coah
eeb6e310cf Merge pull request #109 from coah80/agent/continue-0922/refill03-next
Match RevoEX NWC24MsgObj
2026-09-22 00:24:40 -05:00
coah
2242c861de Merge pull request #108 from coah80/agent/continue-0922/tools-bsearch
[codex] Match MSL bsearch
2026-09-22 00:22:43 -05:00
coah
ded8d62531 Match MSL bsearch 2026-09-22 05:21:31 +00:00
coah
2c9e8eb028 Merge pull request #107 from coah80/agent/refill-0922/zi8ZHuwd
[codex] Match Zi8GetZHuwdPtr
2026-09-22 00:20:10 -05:00
coah
a8c6bcf550 Match Zi8GetZHuwdPtr 2026-09-22 05:19:33 +00:00
coah
aa72085db7 Match NWC24 message object 2026-09-22 05:19:14 +00:00
coah
4f747f363b Merge pull request #106 from coah80/agent/continue-0922/65-HBMBase
Match MSL math_sun
2026-09-22 00:19:12 -05:00
coah
2dce7103d1 Merge pull request #105 from coah80/agent/continue-0922/cdb-database
[codex] Match CDBDatabase
2026-09-22 00:17:34 -05:00
coah
f812a3bf87 Match MSL math_sun 2026-09-22 05:16:12 +00:00
coah
25177c690e Match CDBDatabase 2026-09-22 05:14:14 +00:00
coah
912546fd58 Merge pull request #104 from coah80/integrate/audio-wave-0922
Match and link AudioWavePlayer
2026-09-22 00:13:48 -05:00
coah
39aef1c7c0 Link matching AudioWavePlayer unit 2026-09-22 05:13:22 +00:00
coah
872f55c573 Merge pull request #103 from coah80/integrate/letterwriter-0922
Match and link iplLetterWriter
2026-09-22 00:12:44 -05:00
coah
ba46047e4d Match LetterWriter init calculation 2026-09-22 05:12:31 +00:00
coah
3e41051d36 Merge pull request #101 from coah80/agent/continue-0922/tools-arith
[codex] Match MSL arithmetic helpers
2026-09-22 00:10:58 -05:00
coah
fa2c5714ad Match MSL arithmetic helpers 2026-09-22 05:09:50 +00:00
coah
cebdd7236d Merge pull request #99 from coah80/agent/continue-0922/iplCalendar
Match iplCalendar completely
2026-09-21 23:35:17 -05:00
coah
87cf5dacc3 Merge pull request #100 from coah80/agent/continue-0922/21-iplNwc24Manager
Match iplNwc24Manager
2026-09-21 23:34:51 -05:00
coah
9424c50f7b Match Calendar data padding 2026-09-22 04:32:20 +00:00
coah
020ba288c3 Match Calendar date positioning 2026-09-22 04:32:20 +00:00
coah
1ab4726f50 Merge pull request #98 from coah80/integrate/nwc24-manager-0922
Match and link NWC24 manager
2026-09-21 23:32:04 -05:00
coah
2b016f9144 Match iplNwc24Manager 2026-09-22 04:31:50 +00:00
coah
29984adbed Merge pull request #97 from coah80/integrate/wdscan-0922
Match and link WDScan
2026-09-21 23:30:58 -05:00
coah
e2832af0d2 Match RevoEX WDScan 2026-09-22 04:30:41 +00:00
coah
df3f27980e Merge pull request #96 from coah80/integrate/sd-drv-0922
Match and link SD driver
2026-09-21 23:30:24 -05:00
coah
28a693c7ad Match RevoEX SD driver 2026-09-22 04:30:16 +00:00
coah
1d16705416 Match iplNwc24Manager 2026-09-22 04:29:48 +00:00
coah
1ccf72e0d5 Merge pull request #95 from coah80/integrate/archivefont-0922
Match and link NW4R ArchiveFont
2026-09-21 23:29:14 -05:00
coah
11b63fc609 Match NW4R ArchiveFont 2026-09-22 04:29:02 +00:00
coah
3ae7c32d1c Merge pull request #94 from coah80/integrate/iplDate-0922
Match and link iplDate
2026-09-21 23:25:56 -05:00
coah
1171037c9b Match iplDate static data 2026-09-22 04:25:34 +00:00
coah
0a6a722237 Match and link www_window (#93)
* Match BrowserWindow tile blit

* Match BrowserWindow tile row setup

* Link matching BrowserWindow unit
2026-09-21 23:23:06 -05:00
coah
18e76c8e59 Revert "Match MSL printf (#91)" (#92)
This reverts commit b9ceb6a11a.
2026-09-21 23:20:59 -05:00
coah
0391409f25 Match iplSystem init (#90) 2026-09-21 23:17:29 -05:00
coah
b9ceb6a11a Match MSL printf (#91)
* Match MSL printf

* Link MSL printf match
2026-09-21 23:17:03 -05:00
coah
cc637c0b19 Match MSL allocator (#89) 2026-09-21 23:15:28 -05:00
coah
7c26f15caa Match systemmenu CSPane (#88) 2026-09-21 23:13:23 -05:00
coah
e505b1cf9e Require complete data gates for workers (#87) 2026-09-21 23:10:16 -05:00
coah
39c8fe9e3a Match WPAD storage and SDA layout (#86)
* Match WPAD BSS storage layout

* Match WPAD SDA operands
2026-09-21 23:08:09 -05:00
coah
b5423d6815 Match MSL ansi files (#85) 2026-09-21 23:06:19 -05:00
coah
cf00659e46 Match iplController data (#84) 2026-09-21 23:03:41 -05:00
coah
0eedd89260 Match tiInputForm helper functions (#83) 2026-09-21 23:02:58 -05:00
coah
69ff7c2582 Match and link iplSaveDataManager (#82)
* Match save data manager initialization

* Match save data manager empty string
2026-09-21 22:57:22 -05:00
coah
a95c8a4b1d Match and link RsoSystem (#79) 2026-09-21 22:45:45 -05:00
coah
953b301d76 Link matching iplUtility unit (#77)
* Link matching iplUtility unit

* Mark utility constructor shim weak
2026-09-21 22:29:28 -05:00
coah
5166ef739e Match PlayTimeLog record creation (#76) 2026-09-21 22:27:54 -05:00
coah
f86495f54a Update worker capacity guidelines in AGENTS.md 2026-09-21 20:15:45 -05:00
coah
537c072886 Merge pull request #73 from coah80/agent/scroller-calc-20260922
Match Scroller calc
2026-09-21 20:11:20 -05:00
coah
1e9dd58f0d Match Scroller calc 2026-09-22 01:10:49 +00:00
coah
e174009388 Merge pull request #72 from coah80/agent/update-agent-cap-20260922
Raise worker pool guidance
2026-09-21 20:09:21 -05:00
coah
7760bedf22 Raise worker pool guidance 2026-09-22 01:09:09 +00:00
coah
e55aea86ee Merge pull request #71 from coah80/agent/scene-manager-link-20260922
Link SceneManager
2026-09-21 20:07:25 -05:00
coah
8b42d4167b Link SceneManager 2026-09-22 01:07:01 +00:00
coah
d05fcb1f10 Merge pull request #70 from coah80/agent/button-link-20260922
Link matching iplButton
2026-09-21 20:05:01 -05:00
coah
532b492c2a Link matching iplButton 2026-09-22 01:04:35 +00:00
coah
3ec0698529 Merge pull request #69 from coah80/agent/cdbcrypt-link-20260922
Link CDBCrypt
2026-09-21 20:03:35 -05:00
coah
649ad2fe37 Link CDBCrypt 2026-09-22 01:03:18 +00:00
coah
a1be1860d9 Merge pull request #68 from coah80/agent/update-agents-workflow-20260922
Update agent matching workflow
2026-09-21 20:02:53 -05:00
coah
af7a696da6 Update agent matching workflow 2026-09-22 01:02:42 +00:00
coah
0105e3de85 Merge pull request #67 from coah80/agent/odh-decompress-loop-20260922
Match cdj_d_decompressLoop
2026-09-21 19:59:05 -05:00
coah
a1167cd128 Match cdj_d_decompressLoop 2026-09-22 00:58:39 +00:00
coah
1bb030e16a Merge pull request #66 from coah80/agent/www-surface-link-20260922
Link www surface unit
2026-09-21 19:42:53 -05:00
coah
41f01f5012 Link www surface unit 2026-09-22 00:42:23 +00:00
coah
4b24a65552 Merge pull request #65 from coah80/agent/textwriter-link-20260922
Link TextWriter unit
2026-09-21 19:22:18 -05:00
coah
44e895f70b Link TextWriter unit 2026-09-22 00:21:42 +00:00
coah
42173aa970 Merge pull request #64 from coah80/agent/nand-shared-link-20260922
Link iplNandShared
2026-09-21 19:16:24 -05:00
coah
c936e893db Link iplNandShared 2026-09-22 00:15:55 +00:00
coah
4fdd7f9cd5 Merge pull request #51 from coah80/codex/nwc24-friend-search-exact-20260921
Match NWC24 friend search
2026-09-21 18:56:45 -05:00
coah
914007736f Merge pull request #63 from coah80/agent/candidate-box-next-20260921
Match candidate page navigation
2026-09-21 18:53:10 -05:00
coah
def5006961 Match candidate page navigation 2026-09-21 23:52:49 +00:00
coah
a5b26387d3 Merge pull request #62 from coah80/agent/ti-input-form-exact-20260921
Match tiInputForm input paths
2026-09-21 18:50:58 -05:00
coah
e46089fbb9 Match tiInputForm input paths 2026-09-21 23:50:28 +00:00
coah
1683c2bb9c Merge pull request #61 from coah80/agent/board-object-20260921
Match BoardObject stt_create
2026-09-21 18:48:24 -05:00
coah
1f04477528 Match BoardObject stt_create 2026-09-21 23:48:04 +00:00
coah
87377fa984 Merge pull request #60 from coah80/agent/channel-title-20260921
Match ChannelTitle module loader
2026-09-21 18:47:50 -05:00
coah
2a2f0f8868 Match ChannelTitle module loader 2026-09-21 23:47:14 +00:00
coah
cd729d24cb Merge PR #59: Match channel object helpers
Match channel object helpers
2026-09-21 18:45:17 -05:00
coah
a6ac7282b7 Match channel object helpers 2026-09-21 23:45:01 +00:00
coah
bd1ebcb624 Merge PR #58: Match keyboard save
Match keyboard save
2026-09-21 18:44:18 -05:00
coah
cfe2a8bc1a Match keyboard save 2026-09-21 23:44:04 +00:00
coah
b62e543654 Merge PR #57: Match board key table
Match board key table
2026-09-21 18:40:46 -05:00
coah
349e33fb24 Match board key table 2026-09-21 23:40:35 +00:00
coah
1eaf680f40 Merge PR #56: Match system warning loop
Match system warning loop
2026-09-21 18:34:26 -05:00
coah
3e35807542 Match system warning loop 2026-09-21 23:34:11 +00:00
coah
bbce167648 Merge PR #55: Match TVRC data
Match TVRC data
2026-09-21 18:30:49 -05:00
coah
2c1b255aa2 Match TVRC data 2026-09-21 23:30:38 +00:00
coah
171cd52bab Merge PR #54: Match EGG DVD archive open
Match EGG DVD archive open
2026-09-21 18:27:49 -05:00
coah
7f1fb7e588 Match EGG DVD archive open 2026-09-21 23:27:36 +00:00
coah
aa825369da Merge PR #53: Fix CDB filesystem build
Fix CDB filesystem build
2026-09-21 18:27:14 -05:00
coah
42390e0343 Fix CDB filesystem build 2026-09-21 23:26:58 +00:00
coah
5c1af96b02 Merge PR #52: Match CDB filesystem helpers
Match CDB filesystem helpers
2026-09-21 18:24:54 -05:00
coah
ce15782426 Match CDB filesystem helpers 2026-09-21 23:24:41 +00:00
coah
cb232daee1 Match NWC24 friend search 2026-09-21 23:21:48 +00:00
coah
46c6772ada Merge PR #50: Match button data
Match button data
2026-09-21 18:18:02 -05:00
coah
50d3800599 Match button data 2026-09-21 23:17:50 +00:00
coah
bfd99258d8 Merge PR #49: Match ISD_GetCardSize
Match ISD_GetCardSize
2026-09-21 18:13:02 -05:00
coah
5c278171eb Match ISD_GetCardSize 2026-09-21 23:12:48 +00:00
coah
3167c713a7 Match LetterWriter create (#48)
Match LetterWriter create
2026-09-21 18:02:49 -05:00
coah
269aa867e6 Merge remote-tracking branch 'origin/main' into codex/letterwriter-create-exact-20260921 2026-09-21 23:02:09 +00:00
coah
e912ed5b65 Match LetterWriter create 2026-09-21 23:02:09 +00:00
coah
02ffffbcb4 Match hardware keyboard input update (#47)
Match hardware keyboard input update
2026-09-21 17:57:44 -05:00
coah
a5120f43ca Merge remote-tracking branch 'origin/main' into codex/ti-hw-keyboard-exact-20260921 2026-09-21 22:57:10 +00:00
coah
d8a2813275 Merge remote-tracking branch 'origin/main' into HEAD 2026-09-21 22:54:55 +00:00
coah
3cac5fe6a8 Match AddressEdit string methods (#46)
Match AddressEdit string methods
2026-09-21 17:53:20 -05:00
coah
cd6d734f5a Merge remote-tracking branch 'origin/main' into codex/address-edit-exact-only-20260921 2026-09-21 22:52:47 +00:00
coah
7b3e17ba9a Restore AddressEdit data pool 2026-09-21 22:52:25 +00:00
coah
33a25be480 Match Address button helpers (#45)
Match Address button helpers
2026-09-21 17:52:15 -05:00
coah
88e8008fb1 Merge remote-tracking branch 'origin/main' into codex/address-button-helpers-20260921 2026-09-21 22:51:39 +00:00
coah
0f1c1e5a1e Match Address button helpers 2026-09-21 22:51:39 +00:00
coah
f288c94074 Match ChannelSelect layout builders (#44)
Match ChannelSelect layout builders
2026-09-21 17:50:22 -05:00
coah
36bca5b314 Match AddressEdit exact string methods 2026-09-21 22:50:16 +00:00
coah
7b63614e4a Merge remote-tracking branch 'origin/main' into codex/channel-select-exact-20260921 2026-09-21 22:48:48 +00:00
coah
1c6ec5abf9 Match ChannelSelect control flow 2026-09-21 22:48:48 +00:00
coah
a9c087b860 Match hardware keyboard input update 2026-09-21 22:46:02 +00:00
coah
a7e33d7893 Match FocusObject parsed text (#43)
Match FocusObject parsed text
2026-09-21 17:43:05 -05:00
coah
350d7bee1e Merge remote-tracking branch 'origin/main' into codex/focus-object-make-parsed-text-local-20260921 2026-09-21 22:42:41 +00:00
coah
cc8d401cd7 Match BoardObject stand transition (#42)
Match BoardObject stand transition
2026-09-21 17:42:27 -05:00
coah
1490ae7346 Merge remote-tracking branch 'origin/main' into codex/boardobject-stt-stand-20260921 2026-09-21 22:41:47 +00:00
coah
561d041cea Match focus object parsed text 2026-09-21 22:41:06 +00:00
coah
f2e18ec171 Match BoardObject stand transition 2026-09-21 22:40:59 +00:00
coah
8c747e2e39 Match AddressEdit state helpers (#41)
Match AddressEdit state helpers
2026-09-21 17:40:47 -05:00
coah
99054ddeb3 Merge remote-tracking branch 'origin/main' into codex/address-edit-focus-20260921 2026-09-21 22:40:08 +00:00
coah
0f72acdb1f Match AddressEdit state helpers 2026-09-21 22:40:08 +00:00
coah
3e620d7f91 Match UrlProcessor focus lookup (#40)
Match UrlProcessor focus lookup
2026-09-21 17:39:01 -05:00
coah
0fa0bbe036 Match UrlProcessor focus lookup 2026-09-21 22:38:38 +00:00
coah
bc81843471 Merge pull request #39 from coah80/codex/worker-focus-object-20260921
Match remaining focus object helpers
2026-09-21 17:27:48 -05:00
coah
39735a35a9 Merge pull request #38 from coah80/codex/letterwriter-sendtopc-20260921
Match LetterWriter sendToPC
2026-09-21 17:27:35 -05:00
coah
12bdbae0a6 Match remaining focus object helpers 2026-09-21 22:27:18 +00:00
coah
684625d3c7 Merge pull request #35 from coah80/codex/address-edit-wiiid-20260921
Match AddressEdit wiiid_utf16
2026-09-21 17:27:14 -05:00
coah
c65c81c340 Merge pull request #36 from coah80/codex/text-writer-create-20260921
Match TextWriter create
2026-09-21 17:26:59 -05:00
coah
676712c9e4 Improve LetterWriter sendToPC matching 2026-09-21 22:26:40 +00:00
coah
efd0dd659f Merge pull request #37 from coah80/codex/worker-chan-edit-measured-20260921
Improve ChanAppEdit interpolation matching
2026-09-21 17:26:37 -05:00
coah
643c463068 Improve ChanAppEdit interpolation match 2026-09-21 22:25:42 +00:00
coah
51dc92b480 Match TextWriter create 2026-09-21 22:25:20 +00:00
coah
16d9f96370 Match AddressEdit wiiid_utf16 2026-09-21 22:25:16 +00:00
coah
df19d00c38 Merge pull request #34 from coah80/codex/channelobj-measured-20260921
Match ChannelObj bindNewAnm
2026-09-21 16:54:19 -05:00
coah
4af87bd899 Merge ODH flash buffer match
Merge validated exact ODH bit-buffer matching
2026-09-21 16:53:58 -05:00
coah
2d3dee5b8d Match ODH flash buffer 2026-09-21 21:53:38 +00:00
coah
39370e3cbd Match ChannelObj bindNewAnm 2026-09-21 21:53:36 +00:00
coah
79d77aad4c Merge pull request #32 from coah80/codex/worker-keyboard-20260921
Match hardware keyboard conversion
2026-09-21 16:47:37 -05:00
coah
73a310d318 Match hardware keyboard conversion 2026-09-21 21:45:45 +00:00
coah
51196ba66d Merge pull request #31 from coah80/codex/ti-input-form-remaining-20260921
Match tiInputForm helper methods
2026-09-21 16:42:26 -05:00
coah
8113aa6203 Merge remote-tracking branch 'origin/main' into codex/ti-input-form-remaining-20260921 2026-09-21 21:41:59 +00:00
coah
c960a59d3b Match tiInputForm helper methods 2026-09-21 21:41:24 +00:00
coah
987113df0b Merge pull request #30 from coah80/codex/worker-board-focus-20260921
Improve board and focus object matching
2026-09-21 16:40:17 -05:00
coah
f193888cd7 Improve board object matching 2026-09-21 21:39:24 +00:00
coah
1dd0ee0666 Merge pull request #29 from coah80/codex/worker-address-miiobj-20260921
Match address Mii helpers
2026-09-21 16:39:21 -05:00
coah
11a0fedecd Match address Mii helpers 2026-09-21 21:38:50 +00:00
coah
27ce4969a0 Merge pull request #28 from coah80/codex/worker-utility-20260921
Improve iplUtility matching
2026-09-21 16:01:44 -05:00
coah
e42af3a3f3 Improve iplUtility matching 2026-09-21 21:00:19 +00:00
coah
a77574585d Improve ESMisc matching
Match TMDFile::Exist and improve DeleteUnauthorizedData code generation.
2026-09-21 15:50:59 -05:00
coah
71467b26a7 Improve candidate box matching
Match additional tiCandidateBox codegen.
2026-09-21 15:27:08 -05:00
coah
c43d4c4fdd Match address edit helpers (#25)
Recover 11 matching helpers in iplAddressEdit.cpp.

Verified with the 43U build, objdiff, ctxdiff, and DOL SHA1.
2026-09-21 15:23:37 -05:00
coah
513eb4dca2 Improve ChannelTitle matching
Match additional ChannelTitle functions.
2026-09-21 15:23:21 -05:00
coah
2bde61b433 Decompile tiInputForm
Add the verified tiInputForm implementation.
2026-09-21 15:22:16 -05:00
coah
d4f60828c1 Match BS2 title loading helpers (#22)
Add exact BS2 title partition and NAND ticket helpers.
2026-09-21 15:20:34 -05:00
coah
922d97580a Match ChannelTitle RSO control flow (#21)
Match ChannelTitle RSO control flow to the 43U reference.
2026-09-21 15:07:43 -05:00
coah
512b9b2bf2 Link iplCSAnim
Mark the exact iplCSAnim translation unit as Matching.
2026-09-21 15:07:07 -05:00
coah
f93b82a8c4 Merge remote-tracking branch 'origin/main' into agent/channel-title-20260921 2026-09-21 20:06:38 +00:00
coah
b57b33b0e0 Match ChannelTitle RSO control flow 2026-09-21 20:06:34 +00:00
coah
319ebb97a8 Link iplCdbBackup (#18)
Mark the exact iplCdbBackup unit as Matching so it is linked into the 43U DOL.
2026-09-21 15:05:52 -05:00
coah
bfa80305a6 Link iplPlayTimeLog
Link the verified exact iplPlayTimeLog unit.
2026-09-21 15:05:22 -05:00
coah
8d0d30631e Link iplChannelManager
Mark the exact iplChannelManager unit as Matching.
2026-09-21 15:04:01 -05:00
coah
4dc1df10c5 Improve iplAddress matching
Match fistt_wait_open in iplAddress.
2026-09-21 15:00:56 -05:00
coah
bcfdd1655a Match ODH header generation
Implement the exact ODH JPEG header generation sequence.
2026-09-21 15:00:44 -05:00
coah
eff27d2db4 Match iplAPScanThread
Promote the exact 43U AP scan thread object to Matching.
2026-09-21 14:58:13 -05:00
coah
9b43ff5d9b Link iplException
Link the verified exact iplException unit.
2026-09-21 14:56:37 -05:00
coah
72daa44000 Match rvl_dec
Match rvl_dec and link the verified unit.
2026-09-21 14:47:26 -05:00
coah
084fc4b944 Match ESMisc meta content deletion
Apply the duplicate worker's equivalent DeleteMetaContent match.
2026-09-21 14:28:13 -05:00
coah
38568f101d Improve DeleteUnauthorizedData matching
Apply the measured source-shape improvement for DeleteUnauthorizedData.
2026-09-21 14:28:09 -05:00
coah
671814b4a1 Match NumInodesSaveDirRoot
Reproduce the original MWCC instruction stream for NumInodesSaveDirRoot.
2026-09-21 14:27:59 -05:00
coah
97e706ba33 Match CheckSafeDeleteTitle
Reproduce the original MWCC instruction stream for CheckSafeDeleteTitle.
2026-09-21 14:27:55 -05:00
coah
801597a0ff Match ESMisc checkContentsNum
Reproduce the original MWCC instruction stream for checkContentsNum.
2026-09-21 14:27:49 -05:00
coah
aca83cf265 Match DeleteEmptyTitles
Reproduce the original MWCC instruction stream for DeleteEmptyTitles.
2026-09-21 14:27:44 -05:00
coah
575bd94eaf Match GetValidTicketIndex
Reproduce the original MWCC instruction stream for GetValidTicketIndex.
2026-09-21 14:27:38 -05:00
coah
5586153226 Match ESMisc meta content deletion
Reproduce the original MWCC instruction stream for DeleteMetaContent.
2026-09-21 14:27:33 -05:00
coah
ddf9f5051d Match ESMisc savedata deletion
Reproduce the original MWCC instruction stream for DeleteSavedata.
2026-09-21 14:27:28 -05:00
coah
0752113968 Match ESMisc NumPrivateContents
Reproduce the original MWCC instruction stream for NumPrivateContents.
2026-09-21 14:27:23 -05:00
coah
c5210e467f ci: harden decomp workflow gates 2026-09-21 06:10:34 +00:00
coah
ddc11fd289 docs: define worktree cleanup flow 2026-09-21 05:45:42 +00:00
coah
f749e7b354 docs: isolate orchestrator responsibilities 2026-09-21 05:43:46 +00:00
coah
4efebf25a2 docs: persist workers until full link 2026-09-21 05:41:24 +00:00
coah
be162a25ff docs: define ten-worker match workflow 2026-09-21 05:37:28 +00:00
coah
0b47d3afb8 Match LetterWriter sendToWii 2026-09-21 05:19:00 +00:00
coah
ff7244d65a Match NW4R window frame material 2026-09-21 04:49:17 +00:00
coah
94de001828 Match HomeButton black fader draw 2026-09-21 04:31:06 +00:00
coah
3a259b7948 Match CHANS VM float formatting 2026-09-21 04:01:50 +00:00
coah
b7323a8619 Match NWC24 add download task 2026-09-21 03:54:01 +00:00
coah
e9386909fe Match ChannelObj empty thumbnail 2026-09-21 03:53:35 +00:00
coah
81dec6d39f Match HomeButton reset gui manager 2026-09-21 03:51:17 +00:00
coah
1072f18500 docs: clarify parent validation workflow 2026-09-21 03:26:33 +00:00
coah
32a48b254a Match ChannelObj initBalloon 2026-09-21 03:02:35 +00:00
coah
2f55367ceb Match ChannelObj initCursor 2026-09-21 02:45:42 +00:00
coah
cc517d209f Match tiGUI drawLine 2026-09-21 02:13:35 +00:00
coah
cc490a9aba Match focus pane resize 2026-09-21 01:43:58 +00:00
coah
f9e4831910 Match ChannelTitle parental dialog 2026-09-21 01:37:16 +00:00
coah
83bffff685 Match System root heap setup 2026-09-20 21:42:25 +00:00
coah
fde09f951d Match Revolution DPD projection bounds 2026-09-20 21:34:49 +00:00
coah
f2f3624e2c Document ReAgent matching workflow 2026-09-20 21:34:05 +00:00
coah
fb72a90755 Match NWC24 user ID CRC 2026-09-20 20:49:01 +00:00
coah
4da5fd1919 Match CDB record pool init 2026-09-20 20:47:05 +00:00
coah
cb409bca54 Match CDBCrypt buffer helpers 2026-09-20 20:32:08 +00:00
coah
cd339e71e6 Match SDI block write path 2026-09-20 20:13:21 +00:00
coah
7e3f020cf7 Match SDI block read path 2026-09-20 20:09:23 +00:00
coah
0bf438aa49 Match ChannelSelect start drag 2026-09-20 20:04:53 +00:00
coah
cdc1f8ccce Match ISD_InitCard 2026-09-20 19:54:16 +00:00
coah
060c93428a Match SD physical I/O 2026-09-20 19:54:04 +00:00
coah
72a129648f Match candidate box focus reset 2026-09-20 19:23:58 +00:00
coah
9200d779c6 Match ChannelObj disk layout 2026-09-20 19:19:01 +00:00
coah
0c1954dd51 Match NWC24 scheduler error analysis 2026-09-20 18:54:03 +00:00
coah
7cc980a1be Match d_vf_sys SD device setup 2026-09-20 18:45:03 +00:00
coah
4841d25bd3 Match ChannelSelect drag state 2026-09-20 18:29:54 +00:00
coah
595122c9d0 Match BrowserWindow event reporting 2026-09-20 18:26:20 +00:00
coah
341a46cb4e Match homebutton controller constructor 2026-09-20 18:20:47 +00:00
coah
ad59adf8fd Limit CI to 43U 2026-09-20 17:59:48 +00:00
coah
43868e7253 docs: link live decomp status 2026-09-20 17:56:33 +00:00
coah
ee17d0fdb2 Expand decomp status metrics 2026-09-20 17:47:40 +00:00
coah
24d121918f Match ChannelSelect button event 2026-09-20 17:46:54 +00:00
coah
a626636f6b Match ChannelSelect finishDrag 2026-09-20 17:45:51 +00:00
coah
eb0cda8d33 Match ChannelSelect updateDiskState 2026-09-20 17:45:21 +00:00
coah
763bee01ce Match PaneComponent draw 2026-09-20 17:43:01 +00:00
coah
cccb435398 Fix controller rumble default 2026-09-20 17:36:16 +00:00
coah
a765fc12e0 Match SD menu event handler 2026-09-20 17:34:14 +00:00
coah
a85947dc01 Match calcNormalMoveChanOut 2026-09-20 17:33:30 +00:00
coah
873a7d04e6 Match candidate box updateCandidate 2026-09-20 17:30:11 +00:00
coah
1753e0712b Match ChannelObj setBalloonText 2026-09-20 17:21:40 +00:00
coah
9da4886642 Match focus scroller init 2026-09-20 17:21:06 +00:00
coah
7744b5f27d Match ChannelObj calcBalloon 2026-09-20 17:20:48 +00:00
coah
f3d98ee9f6 Match candidate box makeEmpty 2026-09-20 17:13:59 +00:00
coah
26aff4efc3 Match candidate box init 2026-09-20 17:13:25 +00:00
coah
93b1001f8e Match HomeButton update 2026-09-20 17:11:48 +00:00
coah
e4859d5d81 Match ChannelSelect calcNormal 2026-09-20 17:09:49 +00:00
coah
6930df8b38 Match ChannelSelect calcNormalRestart 2026-09-20 17:07:03 +00:00
coah
3397a5c2da Match ChannelObj bindRsoAnm 2026-09-20 17:00:09 +00:00
coah
601c1faff9 Match ChannelObj setBalloonAnim 2026-09-20 16:59:38 +00:00
coah
eb24be327d Match ChannelSelect event 2026-09-20 16:57:51 +00:00
coah
674d627210 Match UITextArea GUI event 2026-09-20 16:43:51 +00:00
coah
b1dc27b07b Match BrowserWindow event execution 2026-09-20 16:39:05 +00:00
coah
043a9e68e2 Match BrowserWindow CreateWindow 2026-09-20 16:38:47 +00:00
coah
460f4595ff Match candidate box setLanguage 2026-09-20 16:38:27 +00:00
coah
11a1a06015 Match candidate box event handler 2026-09-20 16:24:38 +00:00
coah
6e7d49e1ea Match candidate box start turn-on 2026-09-20 16:24:08 +00:00
coah
ccf83e6994 Match candidate box on-off button 2026-09-20 16:22:17 +00:00
coah
c761d374a2 Match ChannelSelect draw 2026-09-20 16:21:02 +00:00
coah
86843ba593 Match ChannelSelect calcCommon 2026-09-20 16:16:11 +00:00
coah
0474984a09 Match Calendar set_textbox_month 2026-09-20 16:09:31 +00:00
coah
221f115fe2 Match BrowserWindow notify handler 2026-09-20 16:02:02 +00:00
coah
539fa6d4b4 Match BrowserWindow notify handler 2026-09-20 16:00:56 +00:00
coah
37dffc9bab Match holdSEwithPosDis 2026-09-20 15:54:19 +00:00
coah
77ccaf13b9 Match OptOutButton point event 2026-09-20 15:53:54 +00:00
coah
b3d83632ff Match OptOutButton setText 2026-09-20 15:53:33 +00:00
coah
64612b1f44 Match Classic getDpdPos 2026-09-20 15:51:53 +00:00
coah
25b1340c7e Match ChannelObj calcExtModule 2026-09-20 15:48:11 +00:00
coah
279edef5ca Match controller manager read 2026-09-20 15:22:44 +00:00
coah
fa0352dc4d Match controller manager constructor 2026-09-20 15:21:44 +00:00
coah
912d6dedd3 Match Classic controller projection 2026-09-20 15:15:32 +00:00
coah
f0ff822c35 Match Revolution controller read 2026-09-20 15:15:11 +00:00
coah
21df50c805 Match AutoLock constructor 2026-09-20 15:08:20 +00:00
coah
570e7a9355 Match Revolution controller read 2026-09-20 14:59:07 +00:00
coah
a03f6eec13 Match save data channel lookup 2026-09-20 14:52:39 +00:00
coah
c50d5a6e61 Match save data channel comparison 2026-09-20 14:51:31 +00:00
coah
78158d13f9 Match save data free slot lookup 2026-09-20 14:51:02 +00:00
coah
e7d9b15b30 Match save data channel count 2026-09-20 14:50:23 +00:00
coah
bf8634146c Match save data title cache lookup 2026-09-20 14:49:19 +00:00
coah
e30f0b1473 Match save data title cache update 2026-09-20 14:48:31 +00:00
coah
5284aabd88 Match TVRC loop zero handler 2026-09-20 14:46:20 +00:00
coah
dba6badf95 Match save data channel updates 2026-09-20 14:46:03 +00:00
coah
ca81b694b6 Match save data title integration 2026-09-20 14:45:15 +00:00
coah
17dd7370e8 Match save data temporary list 2026-09-20 14:44:11 +00:00
coah
c12509242a Match TVRC start sender 2026-09-20 14:43:47 +00:00
coah
72485c85b9 Match hardware keyboard language setter 2026-09-20 14:42:31 +00:00
coah
bb9007a379 Match save data title migration 2026-09-20 14:41:40 +00:00
coah
7d48c70da0 Match controller rect constructor 2026-09-20 14:41:38 +00:00
coah
9061c67c6f Match freestyle controller destructor 2026-09-20 14:40:59 +00:00
coah
6cbb115b34 Match core controller destructor 2026-09-20 14:40:42 +00:00
coah
5ef3a0cd98 Match classic controller destructor 2026-09-20 14:40:25 +00:00
coah
d1ebf4f8c9 Match sound reset path 2026-09-20 14:38:54 +00:00
coah
762a635f20 Match sound effect stop wrapper 2026-09-20 14:38:02 +00:00
coah
4966bff509 Match BGM pause-off path 2026-09-20 14:37:15 +00:00
coah
5b74e2b584 Match BGM pause-on path 2026-09-20 14:36:52 +00:00
coah
00acf903d6 Match SE pause-off loop 2026-09-20 14:36:11 +00:00
coah
bd23b9f514 Match SE pause-on loop 2026-09-20 14:35:45 +00:00
coah
6d74c2692c Match BGM mute-off wrapper 2026-09-20 14:35:21 +00:00
coah
1fd48c6a96 Match BGM mute-on wrapper 2026-09-20 14:35:07 +00:00
coah
c467f18569 Match BGM stop wrapper 2026-09-20 14:34:45 +00:00
coah
3410cc4a6e Match sound block array destructor 2026-09-20 14:33:05 +00:00
coah
97026036d3 Match channel title lookup 2026-09-20 14:30:27 +00:00
coah
e019f271f5 Match BGM block destructor 2026-09-20 14:29:12 +00:00
coah
cd331706ee Match sound effect block destructor 2026-09-20 14:28:55 +00:00
coah
6c3b058a9f Match sound system constructor 2026-09-20 14:27:54 +00:00
coah
a0cbcb74da Match System sound construction 2026-09-20 14:27:25 +00:00
coah
ed22eadd23 Match RSO animator helper 2026-09-20 14:25:47 +00:00
coah
7b21c801f8 Match keyboard controller helper 2026-09-20 14:25:35 +00:00
coah
7246396283 Match HBM allocator helper 2026-09-20 14:25:24 +00:00
coah
380b3afe96 Match revolution controller constructor 2026-09-20 14:18:50 +00:00
coah
9560a26349 Match controller master invalidation 2026-09-20 14:17:58 +00:00
coah
e8eb752bc9 Match controller master decide 2026-09-20 14:17:29 +00:00
coah
21354e8095 Match revolution controller triggers 2026-09-20 14:16:51 +00:00
coah
ba9d2f8547 Match classic controller triggers 2026-09-20 14:16:20 +00:00
coah
f91c2aa1ab Match classic controller down 2026-09-20 14:15:49 +00:00
coah
10527d7457 Match revolution repeat helper 2026-09-20 14:14:14 +00:00
coah
e0c1ed552b Match revolution pinch helpers 2026-09-20 14:13:55 +00:00
coah
181a66a81b Match revolution position accessors 2026-09-20 14:12:18 +00:00
coah
ba97f21836 Match address helper accessors 2026-09-20 14:09:21 +00:00
coah
215ddd3195 Match controller stick accessors 2026-09-20 14:09:01 +00:00
coah
b7bd6ce519 Match controller main stick accessor 2026-09-20 14:08:41 +00:00
coah
06b833a14b Match address destroy 2026-09-20 14:03:20 +00:00
coah
66c5778d46 Match nigaoe name accessor 2026-09-20 14:03:17 +00:00
coah
cce6b4dfd5 Match BS2 update suffix helper 2026-09-20 14:02:35 +00:00
coah
4677c53f34 Match controller young lookup 2026-09-20 13:58:22 +00:00
coah
3e8e1567b2 Match controller master helpers 2026-09-20 13:58:08 +00:00
coah
aafb419bd1 Match controller free 2026-09-20 13:50:09 +00:00
coah
70f1333484 Match address Mii constructor 2026-09-20 13:49:54 +00:00
coah
736ec5bb5a Match address common after 2026-09-20 13:49:43 +00:00
coah
51280ede56 Match address fadeout setup 2026-09-20 13:49:29 +00:00
coah
b251212a27 Match friend cache delete 2026-09-20 13:49:14 +00:00
coah
0e8b09b0b9 Match friend cache finalizer 2026-09-20 13:48:59 +00:00
coah
7c194d2ba6 Match controller lookup 2026-09-20 13:44:20 +00:00
coah
821d728536 Match master controller accessor 2026-09-20 13:44:10 +00:00
coah
4cf0436c1a Match controller allocator 2026-09-20 13:43:51 +00:00
coah
99ef448175 Match keyboard setting constructor 2026-09-20 13:43:41 +00:00
coah
72280d4ee3 Match address NWC24 state 2026-09-20 13:43:26 +00:00
coah
bd8334a741 Match address parental state 2026-09-20 13:43:13 +00:00
coah
ef6987878b Match address edit message state 2026-09-20 13:43:02 +00:00
coah
71cf69bb1b Match address add message state 2026-09-20 13:42:50 +00:00
coah
3db8b9f7c5 Match friend error accessor 2026-09-20 13:42:35 +00:00
coah
3ab8bcb3bd Match friend id validation 2026-09-20 13:42:23 +00:00
coah
7890fedcaf Match BGM info constructor 2026-09-20 13:40:59 +00:00
coah
05393ead82 Match sound info constructor 2026-09-20 13:38:04 +00:00
coah
e41786f08f Match hardware keyboard input 2026-09-20 13:36:42 +00:00
coah
36a2835fa2 Match controller rumble 2026-09-20 13:36:35 +00:00
coah
81ed31027c Match controller horizon 2026-09-20 13:36:14 +00:00
coah
067c45de77 Match controller DPD projection 2026-09-20 13:36:04 +00:00
coah
49f5555ede Match controller DPD position 2026-09-20 13:35:51 +00:00
coah
f7107e23bb Match controller DPD validity 2026-09-20 13:35:39 +00:00
coah
2bda744b9a Match address common state 2026-09-20 13:35:23 +00:00
coah
adc98e78d7 Match address prepare hook 2026-09-20 13:34:59 +00:00
coah
59503a93f5 Match address ready state 2026-09-20 13:34:45 +00:00
coah
7a4a6206de Match address reset policy 2026-09-20 13:34:35 +00:00
coah
309ab28cd7 Match address reset completion 2026-09-20 13:34:20 +00:00
coah
fa405951c1 Match Hermite interpolation constructor 2026-09-20 13:29:19 +00:00
coah
e83b5bf2bc Match controller pinch release 2026-09-20 13:29:03 +00:00
coah
379008eb53 Match controller pinch trigger 2026-09-20 13:28:51 +00:00
coah
d630e6eadd Match address reset hook 2026-09-20 13:28:28 +00:00
coah
291f1687b9 Match address parent wrapper 2026-09-20 13:28:17 +00:00
coah
7d6ea9da6a Match random float accessor 2026-09-20 13:25:46 +00:00
coah
eceeba4be0 Match sound handle constructor 2026-09-20 13:23:49 +00:00
coah
f051f83348 Match address string clear 2026-09-20 13:22:01 +00:00
coah
44c95c2f5c Match controller repeat accessor 2026-09-20 13:21:54 +00:00
coah
4c66dc415e Match address next wrapper 2026-09-20 13:21:11 +00:00
coah
9fd301c8fd Match address display code 2026-09-20 13:19:33 +00:00
coah
3b1a718a85 Match controller interface read 2026-09-20 13:19:24 +00:00
coah
2fd6c7ad77 Match address prev wrapper 2026-09-20 13:19:17 +00:00
coah
740c9b2d1d Match address child wrapper 2026-09-20 13:16:43 +00:00
coah
0769de3e97 Match BS2 abort state 2026-09-20 13:11:20 +00:00
coah
73a284a263 Match BS2 update accessors 2026-09-20 13:11:08 +00:00
coah
3840594f86 Match board child wait state 2026-09-20 12:54:59 +00:00
coah
c0e6edd6d4 Match controller release trigger 2026-09-20 12:46:53 +00:00
coah
dbaa9286f3 Match controller type wrapper 2026-09-20 12:45:13 +00:00
coah
bbe84d7f0b Match sound memory initialization 2026-09-20 12:45:03 +00:00
coah
8741e22b89 Match controller channel wrapper 2026-09-20 12:33:58 +00:00
coah
20abc4f110 Match banner sound startup 2026-09-20 12:33:53 +00:00
coah
91203b261d Match Revolution button flags 2026-09-20 12:12:10 +00:00
coah
4c6c630aca Match free sound block lookup 2026-09-20 12:12:05 +00:00
coah
fb7316232a Match Revolution KPAD getter 2026-09-20 12:02:33 +00:00
coah
3baffabc22 Match indexed sound lookup 2026-09-20 12:02:28 +00:00
coah
58b285637f Match Revolution DPD distance 2026-09-20 11:55:42 +00:00
coah
4e78be0ffd Match active sound lookup 2026-09-20 11:55:35 +00:00
coah
a3631e8073 Match controller DPD distance 2026-09-20 11:46:05 +00:00
coah
b5fd6a46b6 Match sound output mode 2026-09-20 11:46:01 +00:00
coah
6e0952ad2a Match BS2 callback 2026-09-20 11:45:55 +00:00
coah
e67450a2b2 Match BS2 allocator setter 2026-09-20 11:39:09 +00:00
coah
aae6ed6362 Match BS2 banner availability 2026-09-20 11:34:03 +00:00
coah
5687e7aa3d Match BS2 banner buffer length 2026-09-20 11:29:27 +00:00
coah
030bf6d6a0 Match BS2 banner buffer getter 2026-09-20 11:24:45 +00:00
coah
9c4d7ec939 Match controller cancel rumbling 2026-09-20 11:24:00 +00:00
coah
5a33eba25b Match BS2 title availability 2026-09-20 11:18:57 +00:00
coah
76e95d75b3 Match controller pad status 2026-09-20 11:18:36 +00:00
coah
3ef25ba6df Match BS2 diagnostic disc check 2026-09-20 11:13:44 +00:00
coah
9c0cadac93 Match indexed sound activity query 2026-09-20 11:13:32 +00:00
coah
e905430c75 Match controller release flag 2026-09-20 11:13:09 +00:00
coah
8c471f4d78 Match BS2 banner buffer setter 2026-09-20 11:08:29 +00:00
coah
c9fe195d72 Match controller trigger flag 2026-09-20 11:06:46 +00:00
coah
445a9235d5 Match sound activity query 2026-09-20 11:03:27 +00:00
coah
04e723a4dc Match controller hold flag 2026-09-20 11:02:51 +00:00
coah
5e69380b74 Match stop all sound 2026-09-20 10:58:22 +00:00
coah
3076147af9 Match CDBRecordFree 2026-09-20 10:57:53 +00:00
coah
8493629780 Match NWC24 attached message setter 2026-09-20 10:13:46 +00:00
coah
31c76c40ff Match candidate box update 2026-09-20 09:41:18 +00:00
coah
0cb0e2974c Match eZiText work data layout 2026-09-20 08:55:56 +00:00
coah
e962b530a0 Match CDB record key dictionary find 2026-09-20 08:55:56 +00:00
coah
a867f0a91c Match CDB record key array full 2026-09-20 08:47:07 +00:00
coah
bc76d69382 Match CDB record key arrays 2026-09-20 08:30:35 +00:00
coah
c2c9377acb Match NWC24 message fields 2026-09-20 08:21:49 +00:00
coah
a6aa8bf93e Match CDB attribute creation 2026-09-20 08:21:49 +00:00
coah
149d9b4cd8 Match SDI interrupt handlers 2026-09-20 08:21:49 +00:00
coah
0a9a85bd55 Match NWC24 message getters 2026-09-20 08:13:30 +00:00
coah
59f644f64b Match SD card size 2026-09-20 08:02:10 +00:00
coah
2a2d8ad6a1 Match NWC24SetMsgFaceData 2026-09-20 08:02:09 +00:00
coah
d15f435bb6 Match SDI block wrappers 2026-09-20 08:02:06 +00:00
coah
0b8684a352 Match NWC24GetMsgTextSize 2026-09-20 07:57:00 +00:00
coah
f62768d36d Match NWC24SetMsgToAddr 2026-09-20 07:52:26 +00:00
coah
5eac683d2d Match Util_xtoi 2026-09-20 07:19:07 +00:00
coah
5301a5e53b Match Mail_strncmp 2026-09-20 07:12:51 +00:00
coah
31ab10cb00 Match strtok 2026-09-20 07:11:11 +00:00
coah
f706602ae6 Match NWC24iInitMsgBoxDir 2026-09-20 07:10:59 +00:00
coah
c0b3379756 Match NWC24SetMsgSubject 2026-09-20 07:09:09 +00:00
coah
afd42b92ab Match NWC24 InitAllFiles 2026-09-20 07:06:21 +00:00
coah
46e17b36eb Match Mail_strcat 2026-09-20 07:05:30 +00:00
coah
bd4f604dde Match MSL strcspn 2026-09-20 07:04:48 +00:00
coah
9d235d9577 Match NWC24GetMsgSubjectSize 2026-09-20 07:04:24 +00:00
coah
6d1411942f Match NWC24InitFiles 2026-09-20 07:02:11 +00:00
coah
ebc7cbe423 Match Mail_tolower 2026-09-20 07:00:29 +00:00
coah
e22844914e Match MSL strspn 2026-09-20 07:00:07 +00:00
coah
3d4fc256e5 Match NWC24InitFilesIndividually 2026-09-20 06:57:29 +00:00
coah
612367db61 Match MSL strpbrk 2026-09-20 06:55:57 +00:00
coah
4fc77e3a96 Match NWC24GetMsgNumAttached 2026-09-20 06:54:56 +00:00
coah
393c0e7738 Match Mail_isdigit 2026-09-20 06:54:28 +00:00
coah
3e118bf331 Match MSL strncat 2026-09-20 06:52:16 +00:00
coah
b30ffee367 Match NWC24GetMsgGroupId 2026-09-20 06:50:37 +00:00
coah
06a367e71c Match NWC24GetErrorCode 2026-09-20 06:44:42 +00:00
coah
dcc219095c Match ISD_ReadBlock 2026-09-20 06:44:24 +00:00
coah
c41984096a Match NWC24GetMsgAppId 2026-09-20 06:44:03 +00:00
coah
9c927daf7c Match Board stt_wait_child_dst 2026-09-20 06:30:18 +00:00
coah
41808cc9ef Match ChannelSelect updateDiskState 2026-09-20 06:29:49 +00:00
coah
bfae2f0e4a Match CARDFreeBlock 2026-09-20 06:22:34 +00:00
coah
379e26ba47 Match CARDAllocBlock 2026-09-20 06:19:13 +00:00
coah
12d2d9f084 Match MSL setvbuf 2026-09-20 06:15:14 +00:00
coah
f62a09fae0 Match Zi8GetTableData 2026-09-20 06:13:40 +00:00
coah
231cb7fb26 Match BoardObject create_picture 2026-09-20 06:07:05 +00:00
coah
78704754f6 Match Calendar set_textbox_date 2026-09-20 05:54:12 +00:00
coah
fc6d9df7af Match VEC2 division helper 2026-09-20 05:52:30 +00:00
coah
3c2c764327 Match nw4r Color assignment 2026-09-20 05:35:00 +00:00
coah
ed5ee14d5e Match wiisetting wiiOSReport 2026-09-20 05:31:17 +00:00
coah
0de36f1839 Match PlayTimeLog create_new_record 2026-09-20 05:24:19 +00:00
coah
0e554d1c4e Match UrlProcessor make_collision 2026-09-20 05:21:29 +00:00
coah
db3416689e Match BoardObject change_ltrtex 2026-09-20 05:13:04 +00:00
coah
8c4aedc249 Match CandidateBox Base updateCandidate 2026-09-20 05:12:11 +00:00
coah
1730ec55f5 Match OptOutButton start_left_event 2026-09-20 04:55:14 +00:00
coah
475a193e9d Match Board return_to_freelist_if_diff_date 2026-09-20 04:45:30 +00:00
coah
e1e9762018 Match VmArrayJoinSub 2026-09-20 04:00:15 +00:00
coah
4407eeb982 Match HomeButton startPointEvent 2026-09-20 03:57:01 +00:00
coah
2197fddf86 Match HomeButton fadeout_sound 2026-09-20 03:52:15 +00:00
coah
e34b952318 Match UITextArea StartScrollPageToIdx 2026-09-20 03:43:34 +00:00
coah
69ff459b95 Match CSPane get_vec 2026-09-20 03:42:43 +00:00
coah
f3d763268b Match HomeButton init 2026-09-20 03:40:22 +00:00
coah
ebad2bc3ac Match CSPane get_scale 2026-09-20 03:40:12 +00:00
coah
2626650607 Match PlayTimeLog write_record 2026-09-20 03:38:25 +00:00
coah
f40b44fd34 Match HomeButton setAdjustFlag 2026-09-20 03:37:25 +00:00
coah
9c3365eb3f Match CHANSVmConvertToStrFromInt 2026-09-20 03:36:04 +00:00
coah
e7fd665754 Match CHANSVmDebugPrintf 2026-09-20 03:32:17 +00:00
coah
65331d1af2 Match CSPane get_size 2026-09-20 03:27:31 +00:00
coah
87aaf4ce7e Match CHANSVmInit 2026-09-20 03:27:27 +00:00
coah
0669c0b95a Match CHANSVmNewImageObject 2026-09-20 03:19:03 +00:00
coah
f18ecc5cd4 Match keyboard Manager calc 2026-09-20 03:18:51 +00:00
coah
eff2e0618f Match Board read_task 2026-09-20 02:50:36 +00:00
coah
e68eb862b8 Match CARDUpdateFatBlock 2026-09-20 02:41:24 +00:00
coah
7e325e7edd Match Board draw 2026-09-20 02:39:16 +00:00
coah
430786429c Match SaveDataManager checkValidApp 2026-09-20 02:34:19 +00:00
coah
b812e7b09e Match Board stt_init_lfadeaway 2026-09-20 02:16:01 +00:00
coah
e7ae34e540 Match Board stt_init_rfadeaway 2026-09-20 02:13:03 +00:00
coah
b94408923c Match ChannelTitle calcChannelCS 2026-09-20 01:53:38 +00:00
coah
a994bcadd5 Match Board fwd_search_task 2026-09-20 01:51:49 +00:00
coah
cf83b59b1d Match ChannelSelect reserveSceneChangeDerived 2026-09-20 01:38:43 +00:00
coah
e639858574 Match ChannelObj calcBalloonAnim 2026-09-20 01:30:47 +00:00
coah
76898ceee7 Match Board destroy 2026-09-20 01:15:28 +00:00
coah
1e870eb9f8 Match TMCCJPEGDecGetInfoEXIF 2026-09-20 01:13:03 +00:00
coah
d59f929a2c Match CHANSVmCopyObject 2026-09-20 01:06:39 +00:00
coah
747fe8e05e Match BoardObject stt_pinch 2026-09-20 01:05:05 +00:00
coah
5df3c980e9 Match NWC24GetCHJumpBlockData 2026-09-20 00:54:52 +00:00
coah
c9aea37b89 Match EGG setupMemoryArchive 2026-09-20 00:43:19 +00:00
coah
067e300421 Match TMCJPEGDEC ThumbnailCheck 2026-09-20 00:39:49 +00:00
coah
eceea9ce0b Match NWC24SetMsgText 2026-09-20 00:37:21 +00:00
coah
5235792d68 Match CSPane become_youngest_pane 2026-09-20 00:36:43 +00:00
coah
be1d18141a Match ChannelObj setBalloonText 2026-09-20 00:29:09 +00:00
coah
df4b04336b Match BoardObject get_nigaoe_name 2026-09-20 00:26:13 +00:00
coah
ef9c62b49f Match focus_object change_ltrtex 2026-09-20 00:21:02 +00:00
coah
5c2f6febac Match Calendar search_task 2026-09-20 00:07:45 +00:00
coah
3910c074ba Match EGG openNandArchive 2026-09-20 00:05:00 +00:00
coah
d73e48e5ee Match ArchiveFontBase ConstructOpAnalyzeTGLP 2026-09-19 23:49:44 +00:00
coah
72c1d710f5 Match ChannelTitle searchChannel 2026-09-19 23:36:46 +00:00
coah
988845f883 Match VmPushFuncReturnInfo 2026-09-19 23:31:59 +00:00
coah
2e4c1c054f Match TMCJPEGDEC_set_HuffmanTable 2026-09-19 23:27:21 +00:00
coah
ac9a45d114 Match OSInit 2026-09-19 23:23:57 +00:00
coah
9498c17ab0 Match WPADiManageHandler 2026-09-19 23:15:52 +00:00
coah
f98fb55af1 Match cdb_backup_move_task 2026-09-19 23:03:49 +00:00
coah
a02f65c556 Match cdb_backup_delete_task 2026-09-19 23:02:31 +00:00
coah
7d36577c82 Match _MountPrfFile 2026-09-19 22:58:38 +00:00
coah
77316c0ff1 Match TMCJPEGDEC_make_huffdec 2026-09-19 22:50:03 +00:00
coah
36cadb8c76 Match Exception::exception_callback 2026-09-19 22:45:53 +00:00
coah
65806fe8fd Match TMCJPEGDEC_err_restart 2026-09-19 22:45:24 +00:00
coah
b24b120231 Match TMCJPEGDEC_restart_interval 2026-09-19 22:44:14 +00:00
coah
745e49ecfe Match TMCJPEGDEC_imagestart 2026-09-19 22:43:10 +00:00
coah
149eba0fb5 Match TMCJPEGDEC_parse_sos 2026-09-19 22:42:02 +00:00
coah
58bbf4688e Match NWC24Check exact encoding 2026-09-19 22:41:36 +00:00
coah
8b254ee99c Match TMCJPEGDEC_parse_para 2026-09-19 22:40:47 +00:00
coah
2b7a60b905 Match NWC24Check 2026-09-19 22:40:12 +00:00
coah
a3cf6727f5 Match makePriorTitleIDList 2026-09-19 22:40:05 +00:00
coah
9fb0ca8123 Match TMCJPEGDEC_init_buff_thumbnail 2026-09-19 22:39:25 +00:00
coah
776188b174 Match TMCJPEGDEC_parse_sof 2026-09-19 22:37:49 +00:00
coah
c7a20454d5 Match TMCJPEGDEC_parse_dht 2026-09-19 22:35:35 +00:00
coah
810e494f85 Match TMCJPEGDEC_decode_iquant_rc 2026-09-19 22:33:35 +00:00
coah
82288be583 Match TMCJPEGDEC_scan_varinit 2026-09-19 22:31:15 +00:00
coah
1991751095 Match TMCJPEGDEC_parse_dqt 2026-09-19 22:26:17 +00:00
coah
ae79db87b0 Match Rvl_decode_asr 2026-09-19 21:55:48 +00:00
coah
50fc7d260c Match Rvl_decode_ash 2026-09-19 21:54:31 +00:00
coah
94bc16ef56 Match Rvl_decode_szs 2026-09-19 21:13:42 +00:00
159 changed files with 32223 additions and 2316 deletions

View File

@@ -4,6 +4,12 @@ on:
push:
pull_request:
workflow_dispatch:
inputs:
require_complete:
description: Fail unless 43U code, data, functions, units, and links are all 100%
required: false
default: false
type: boolean
jobs:
build:
@@ -14,7 +20,7 @@ jobs:
strategy:
fail-fast: false
matrix:
version: [43U, 43E, 43J, 43K]
version: [43U]
steps:
# Checkout the repository
@@ -56,8 +62,27 @@ jobs:
--binutils /binutils --compilers /compilers
ninja all_source progress build/${{ matrix.version }}/report.json
- name: Test workflow guards
run: python tools/test_workflow_guards.py
- name: Calculate decomp status
if: matrix.version == '43U'
run: |
python tools/decomp_status.py \
build/${{ matrix.version }}/report.json \
--output build/${{ matrix.version }}/decomp-status.json \
--summary "$GITHUB_STEP_SUMMARY"
- name: Enforce completion gate
if: matrix.version == '43U' && github.event_name == 'workflow_dispatch' && inputs.require_complete == true
run: |
python tools/check_decomp_complete.py \
build/${{ matrix.version }}/report.json \
--dol build/${{ matrix.version }}/main.dol
# Upload map files
- name: Upload map
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.version }}_maps
@@ -65,7 +90,15 @@ jobs:
# Upload progress report
- name: Upload report
if: always()
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.version }}_report
path: build/${{ matrix.version }}/report.json
- name: Upload decomp status
if: always() && matrix.version == '43U'
uses: actions/upload-artifact@v4
with:
name: decomp_status
path: build/${{ matrix.version }}/decomp-status.json

1
.gitignore vendored
View File

@@ -6,6 +6,7 @@
__pycache__
.mypy_cache
.cache/
.unlazy/
# Original files
orig/*/*

197
AGENTS.md
View File

@@ -2,6 +2,8 @@
Guidance for AI agents working in this repository.
Keep code comments to cases where they are necessary.
## CRITICAL RULE: never touch upstream
**Do not open a pull request against `koopthekoopa/wii-ipl`. Do not push to it.
@@ -14,7 +16,8 @@ at all.
Concretely:
- `origin` is this fork, `coah80/wii-ipl`. Push here.
- `origin` is this fork, `coah80/wii-ipl`. Only the orchestrator pushes
validated leaf branches here.
- `upstream` is `koopthekoopa/wii-ipl`. Its push URL is intentionally set to
the sentinel `DISABLED_never_push_to_upstream` so an accidental
`git push upstream` fails instead of uploading.
@@ -22,7 +25,8 @@ Concretely:
`--repo koopthekoopa/wii-ipl` to any `gh` command.
- If a task appears to require contacting upstream, stop and ask the human.
If you are reading this because you are about to open a PR: don't.
If you are reading this because you are about to open a PR against upstream:
don't. PRs for validated leaf branches belong only to this fork.
## What this repository is
@@ -79,6 +83,23 @@ Helper tools live in `tools/decomp-assist/`:
- `export_pyghidra.py` — regenerates `ghidra_decomp.txt`, decompiled C for the
functions still missing.
The final completion assertion is machine-checkable:
```
python3 tools/check_decomp_complete.py build/43U/report.json \
--dol build/43U/main.dol
```
It must pass before claiming full completion. GitHub Actions runs the same
assertion when manually dispatched with `require_complete=true`.
Normal push and pull-request builds publish progress without failing on the
current incomplete state. Use the manual `require_complete=true` dispatch for
the terminal all-100% gate.
`tools/test_workflow_guards.py` exercises the completion checker, and
`tools/worktree_check.py` validates the main, leaf, and cleanup states before
integration.
## The single most useful finding: the string pool
MWCC emits a translation unit's string literals into `.data` in the order the
@@ -137,6 +158,166 @@ and `splits.txt`), not in whatever order looks convenient.
7. `ctxdiff.py` next. Work through the instruction diff.
8. Only then look at register allocation.
## Subagent and PR workflow
This repository targets only Wii Menu 4.3U. Do not configure or build 43E,
43J, or 43K while doing matching work.
Most workers should pursue exact matching or safe linking; assign the remainder
to decompilation. Keep up to 75 live workers when the runtime allows it, while
reserving capacity for fixer and validation workers. Fill completed slots with
disjoint tasks. Never duplicate a source file or function
range. Workers return changed paths, exact objdiff measurements, and validation
results. Fuzzy-only results are not accepted.
### Worker loop
Workers iterate until exact-name `objdiff` reports `100.0%`. They must not stop
at a fuzzy score, push, open a PR, or merge. A local commit is fine. Compiler
tie-breaks should be reported with evidence, not hidden behind artificial
assembly or uninitialized values. Exact matching is the handoff point, not
acceptance. A candidate is incomplete until every owned code and data section
and its link metrics are 100%; matching a few functions alone is not enough.
Write new matches as readable C or C++ and keep new inline assembly out of the
source unless the existing target structure makes it unavoidable.
Worker measurements are advisory. Only a fresh orchestrator verification can
accept, push, open, or merge a candidate. Workers are persistent across
validation. After reaching a candidate result,
the worker enters a paused or awaiting-parent state while the orchestrator
performs its checks. Keep the worker handle and its leaf assignment alive. If
pool, ctxdiff, source review, or any other gate fails, send the failure evidence
back to that same worker and resume it on the same leaf. Do not discard a
near-match and silently replace it with a new worker. A worker may be closed
only after its leaf is accepted, explicitly abandoned, or the orchestrator is
stopping the entire goal. A wait timeout is not worker termination; poll the
same handle or inspect its authoritative status before taking recovery action.
The orchestrator must independently rebuild the owned object and verify:
1. `pool_diff.py` reports identical pools, with no first divergence.
2. Exact-name `objdiff` reports `100.0%` for the requested symbol.
3. `ctxdiff.py` reports `diffs 0` and identical instruction counts.
4. Unit-level code, data, function, and link measures for the owned range are
100%, including every owned section.
5. The focused source diff is minimal, readable, and free of artificial
assembly, uninitialized values, or unrelated edits.
6. The full 4.3U build passes and `build/43U/main.dol` has SHA1
`26116613f624061ba99c8d1a299aaa6efa85670d`.
If any orchestrator gate fails, do not promote, push, open a PR, or merge the
candidate. Restore it or send the same disjoint task back to its worker with
the failing evidence. Stage the candidate branch for a PR only after every
gate passes, then regenerate the live progress report before accepting the
next candidate.
For each candidate, the worker must:
1. Run `pool_diff.py` before tuning code generation.
2. Build the 43U object with `/home/cole/projects/tests/.venv/bin/ninja -C . build/43U/src/src/<path>.o`.
3. Require `objdiff` to report `100.0%` for the function and `ctxdiff.py` to report `diffs 0`.
4. Iterate until exact-name objdiff reaches `100.0%`, while preserving the
pool and source-quality requirements above.
5. Return the focused exact match to the parent agent for review. The parent
reruns every gate, runs `tools/decomp_status.py` and
`tools/check_decomp_complete.py`, and runs `/home/cole/projects/tests/.venv/bin/ninja -C . build/43U/ok`;
the worker does not push, open a PR, or merge.
The main agent reviews every worker result before accepting it. After each
accepted merge, record the new report from `build/43U/report.json` and keep
the DOL hash at `26116613f624061ba99c8d1a299aaa6efa85670d`. Never push to
`upstream`; only the fork's `origin` is in scope.
### Orchestrator ownership boundary
The orchestrator does not perform decompilation or hand-tune worker source.
All source-level reverse engineering, implementation, compiler experiments,
and match iteration belong to the persistent subagents. The orchestrator may
only select disjoint leaves, start and pause workers, resume a worker with
failure evidence, run independent verification commands, review diffs, record
wave state, commit validated leaf-branch changes, push the leaf branch, open
and merge the PR, fast-forward `origin/main`, and publish progress. If a
candidate fails validation, return it to its worker; do not fix the candidate
inline in the orchestrator.
A new thread must begin by reading this file, checking the live 43U report and
remote branch, and dispatching the worker pool. The parent must not claim a
match without fresh independent verification.
### Worktrees, branches, and PR integration
Every leaf gets its own worktree and branch created from the latest
`origin/main`, for example `agent/<wave>/<leaf>`. No two workers may share a
worktree, branch, or source file. A worker may commit locally on its leaf branch
if that is needed to preserve its exact result, but it must not push, open a PR,
or merge.
Use the repository worktree checker before integration and cleanup:
```
python3 tools/worktree_check.py main --synced
python3 tools/worktree_check.py leaf <leaf-worktree> agent/<wave>/<leaf>
python3 tools/worktree_check.py cleanup <leaf-worktree> agent/<wave>/<leaf>
```
The cleanup check is read-only. It succeeds only for a clean leaf branch that
is already an ancestor of `origin/main`; the orchestrator then performs the
explicit `git worktree remove` and local branch deletion.
After the worker reaches its handoff point, the orchestrator validates the
worker's worktree from a fresh build. If every gate passes, the orchestrator
pushes that leaf branch to the fork, opens a PR against `coah80/wii-ipl:main`,
and merges it only after the same gates are recorded in the PR. Never create a
PR against `koopthekoopa/wii-ipl`.
Merge one accepted leaf at a time. After each merge, fetch the new
`origin/main`, regenerate progress, and rebase or recreate all not-yet-merged
leaf branches before their next validation. Re-run objdiff, pool, ctxdiff, the
full build, and the DOL hash after rebasing. The PR itself is not acceptance;
the post-merge main branch is the authority.
The orchestrator may resolve mechanical branch conflicts such as unchanged
context or generated bookkeeping. It must not resolve a semantic source
conflict by inventing decompilation. Send semantic conflicts back to the same
leaf worker, resume it in its worktree, and require the full gates again. Keep
the worktree and worker handle until the leaf is merged, explicitly abandoned,
or the whole goal is stopped; clean them up only after that terminal state.
After a successful merge:
1. Confirm the PR is merged into the fork's `main` and the leaf worktree has no
uncommitted changes.
2. In the integration/main worktree, run `git fetch origin` followed by
`git merge --ff-only origin/main` (or an equivalent non-destructive fast
forward). Do not use `git reset --hard` or overwrite unrelated user work.
3. Re-run the live progress report and the full 4.3U/DOL gates on the updated
main branch.
4. Rebase each still-active leaf branch onto the new `origin/main` in its own
worktree, resolve only mechanical conflicts centrally, and send semantic
conflicts back to that leaf's worker.
5. Only after the leaf is merged, clean, and no longer needed, remove its
worktree and local branch. A failed or conflicted leaf keeps its worktree
and worker alive.
## Goal completion contract
The decompilation loop does not stop after a successful wave, a convenient
near-match, or a code-only milestone. Keep dispatching and resuming workers
until the live 43U report proves all of the following:
- Code is 100.00% exact-matched, not merely fuzzy-matched.
- Code is 100.00% fully linked, with no remaining unlinked code units.
- Data is 100.00% extracted/decompiled and 100.00% fully linked.
- Every source unit and function in the 4.3U target is accounted for; no
`NonMatching`, missing, fuzzy-only, or unlinked unit remains.
- The final full build passes, the DOL hash remains correct, and the report,
object files, and linked DOL agree.
Until every condition is true and independently verified, the goal remains
active. A worker wave with zero accepted matches is a failed attempt, not a
completion condition; preserve useful workers, resume fixable leaves, and
dispatch the next disjoint batch.
## Things that do NOT work
- **Frame pragmas.** `#pragma ppc_iro_level 0` fixed exactly one function out
@@ -155,14 +336,12 @@ the instruction count already matches and the surviving differences are
callee-saved register names, you are probably looking at a tie-break. Record it
and move on rather than thrashing.
## Current status at the time of writing
## Current status
- 8690 functions matched, zero regressions against the pristine baseline.
- `main.dol` byte-identical to the original throughout.
- `iplESMisc.cpp` is `NonMatching` and unlinked, so all work there is DOL-safe.
- 6 functions still missing from `iplESMisc.cpp`: `DeleteEmptyTitles`,
`DeleteDownloadTask`, `DeleteTitleContent`, `PrepareTitleDir`,
`DeleteSavedata`, `DeleteUnauthorizedData`.
Do not copy a progress number from this file. Regenerate the live 43U report
with `ninja -C . progress build/43U/report.json`; the report and DOL hash are
the authority for current status. `iplESMisc.cpp` remains `NonMatching` and
unlinked, so work there is DOL-safe.
## Reference

View File

@@ -7,8 +7,8 @@
<!--- Github Actions Badge -->
[Build Status]: https://github.com/koopthekoopa/wii-ipl/actions/workflows/build.yml/badge.svg
[actions]: https://github.com/koopthekoopa/wii-ipl/actions/workflows/build.yml
[Build Status]: https://github.com/coah80/wii-ipl/actions/workflows/build.yml/badge.svg
[actions]: https://github.com/coah80/wii-ipl/actions/workflows/build.yml
<!--- Discord Badge -->
@@ -18,9 +18,6 @@
<!-- Progress links -->
[V43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U
[V43E]: https://decomp.dev/koopthekoopa/wii-ipl/43E
[V43J]: https://decomp.dev/koopthekoopa/wii-ipl/43J
[V43K]: https://decomp.dev/koopthekoopa/wii-ipl/43K
<!--- Version 4.3U progress Badge -->
@@ -28,24 +25,6 @@
[LinkBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=complete_code&label=Linked&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
[FuncBadgeV43U]: https://decomp.dev/koopthekoopa/wii-ipl/43U.svg?&measure=functions&label=Functions&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
<!--- Version 4.3E progress Badge -->
[DecompBadgeV43E]: https://decomp.dev/koopthekoopa/wii-ipl/43E.svg?measure=code&label=Decompiled&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
[LinkBadgeV43E]: https://decomp.dev/koopthekoopa/wii-ipl/43E.svg?measure=complete_code&label=Linked&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
[FuncBadgeV43E]: https://decomp.dev/koopthekoopa/wii-ipl/43E.svg?measure=functions&label=Functions&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
<!--- Version 4.3J progress Badge -->
[DecompBadgeV43J]: https://decomp.dev/koopthekoopa/wii-ipl/43J.svg?&measure=code&label=Decompiled&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
[LinkBadgeV43J]: https://decomp.dev/koopthekoopa/wii-ipl/43J.svg?&measure=complete_code&label=Linked&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
[FuncBadgeV43J]: https://decomp.dev/koopthekoopa/wii-ipl/43J.svg?&measure=functions&label=Functions&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
<!--- Version 4.3K progress Badge -->
[DecompBadgeV43K]: https://decomp.dev/koopthekoopa/wii-ipl/43K.svg?&measure=code&label=Decompiled&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
[LinkBadgeV43K]: https://decomp.dev/koopthekoopa/wii-ipl/43K.svg?&measure=complete_code&label=Linked&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
[FuncBadgeV43K]: https://decomp.dev/koopthekoopa/wii-ipl/43K.svg?&measure=functions&label=Functions&mode=shield&labelColor=%237c7c7c&color=%2333b8ff&style=plastic
<!--- Header -->
![](./misc/logo.png)
@@ -59,20 +38,21 @@ A work-in-progress decompilation of the Wii Menu (4.3)
This repository does **not** contain any assets or assembly of the executable whatsoever. An existing WAD of the Wii Menu is required.
Live decomp status
==================
[![Build status]][actions]
Open the latest successful [Build workflow run][actions] and check its summary for the current objdiff metrics. It includes perfect-match/decompiled, fuzzy-match, fully linked, data, function, unit, and category breakdowns. The run also publishes the 43U report artifact and generated decomp-status report.
Supported versions:
- `43U` - Version **4.3U** (USA)
- `43E` - Version **4.3E** (Europe)
- `43J` - Version **4.3J** (Japan)
- `43K` - Version **4.3K** (Korean)
Progress
========
| Version | Progress |
|-----------------------|------------------------------------------------------------------------------|
| [Wii Menu 4.3U][V43U] | [![FuncBadgeV43U]][V43U] [![DecompBadgeV43U]][V43U] [![LinkBadgeV43U]][V43U] |
| [Wii Menu 4.3E][V43E] | [![FuncBadgeV43E]][V43E] [![DecompBadgeV43E]][V43E] [![LinkBadgeV43E]][V43E] |
| [Wii Menu 4.3J][V43J] | [![FuncBadgeV43J]][V43J] [![DecompBadgeV43J]][V43J] [![LinkBadgeV43J]][V43J] |
| [Wii Menu 4.3K][V43K] | [![FuncBadgeV43K]][V43K] [![DecompBadgeV43K]][V43K] [![LinkBadgeV43K]][V43K] |
> You can see the full progress and its history by clicking on one of the versions in the table.

View File

@@ -8,6 +8,7 @@ MEMORY {
}
SECTIONS {
IPL_WWW_SURFACE_ZERO__Q37ext_ead3www5print = 0;
GROUP: {
.init ALIGN(0x20): {}
extab ALIGN(0x20): {}

View File

@@ -621,27 +621,27 @@ config.libs = [
# Main
IPLSection("system", [
Object(Matching, "system/enc_dummy.c"),
Object(NonMatching, "system/rvl_dec.c"),
Object(Matching, "system/rvl_dec.c"),
Object(Matching, "system/RIPL_BoardRecord.c"),
Object(Equivalent, "system/iplSystem.cpp"),
Object(Matching, "system/iplSystem.cpp"),
Object(NonMatching, "system/iplController.cpp"),
Object(Equivalent, "system/iplChannelManager.cpp"),
Object(Matching, "system/iplChannelManager.cpp"),
Object(Matching, "system/iplChannelScriptManager.cpp"),
Object(Matching, "system/iplNand.cpp"),
Object(NonMatching, "system/iplNandShared.cpp"),
Object(Matching, "system/iplNandShared.cpp"),
Object(Matching, "system/iplNandMeta.cpp"),
Object(Matching, "system/iplNandManager.cpp"),
Object(Matching, "system/iplNandWall.cpp"),
Object(Matching, "system/iplFramework.cpp"),
Object(NonMatching, "system/iplException.cpp"),
Object(Matching, "system/iplException.cpp"),
Object(Matching, "system/iplMessage.cpp"),
Object(Matching, "system/iplMessageManager.cpp"),
Object(Matching, "system/iplNigaoeManager.cpp"),
Object(Matching, "system/iplNigaoe.cpp"),
Object(Matching, "system/iplCdbManager.cpp"),
Object(Matching, "system/iplCdbWrapper.cpp"),
Object(Equivalent, "system/iplPlayTimeLog.cpp"),
Object(Equivalent, "system/iplNwc24Manager.cpp"),
Object(Matching, "system/iplPlayTimeLog.cpp"),
Object(Matching, "system/iplNwc24Manager.cpp"),
Object(Matching, "system/iplPointer.cpp"),
Object(Matching, "system/iplPointerCore.cpp"),
Object(Matching, "system/iplDialogWindow.cpp"),
@@ -655,14 +655,14 @@ config.libs = [
Object(Matching, "system/iplPostmanManager.cpp"),
Object(NonMatching, "system/iplSaveDataManager.cpp"),
Object(Matching, "system/iplChannelRsoThread.cpp"),
Object(Equivalent, "system/RsoSystem.cpp"),
Object(Equivalent, "system/iplCdbBackup.cpp"),
Object(Matching, "system/RsoSystem.cpp"),
Object(Matching, "system/iplCdbBackup.cpp"),
Object(NonMatching, "system/odh.cpp"),
Object(Matching, "system/iplSDVFWorker.cpp"),
Object(Matching, "system/iplNandWrapper.cpp"),
Object(Matching, "system/main.cpp"),
Object(Matching, "system/iplBS2Manager.cpp"),
Object(NonMatching, "system/TVRC.cpp"),
Object(Matching, "system/TVRC.cpp"),
Object(Matching, "system/iplTVRCManager.cpp"),
Object(Matching, "system/_DATA_.c"),
]
@@ -673,7 +673,7 @@ config.libs = [
Object(Matching, "utility/iplFrameController.cpp"),
Object(Equivalent, "utility/iplGraphics.cpp"),
Object(Matching, "utility/iplCapture.cpp"),
Object(Equivalent, "utility/iplUtility.cpp"),
Object(Matching, "utility/iplUtility.cpp"),
Object(Matching, "utility/iplThread.cpp"),
Object(Matching, "utility/iplMessageBase.cpp"),
Object(Matching, "utility/iplJpegDecoder.cpp"),
@@ -692,12 +692,12 @@ config.libs = [
]
),
IPLSection("iplwww", [
Object(Equivalent, "iplwww/www_browser.cpp"),
Object(Matching, "iplwww/www_browser.cpp"),
Object(Matching, "iplwww/www_message.cpp"),
Object(Equivalent, "iplwww/www_surface.cpp"),
Object(Matching, "iplwww/www_surface.cpp"),
Object(Matching, "iplwww/www_thread.cpp"),
Object(Matching, "iplwww/www_print.cpp"),
Object(Equivalent, "iplwww/www_window.cpp"),
Object(Matching, "iplwww/www_window.cpp"),
Object(Matching, "iplwww/www_trasition.cpp"),
Object(Equivalent, "iplwww/www_wiisetting.cpp"),
Object(Matching, "iplwww/www_arcreader.cpp"),
@@ -740,24 +740,24 @@ config.libs = [
Object(Equivalent, "scene/board/iplBoard.cpp"),
Object(Equivalent, "scene/board/iplBoardObject.cpp"),
Object(Matching, "scene/board/iplBoardSD.cpp"),
Object(Equivalent, "scene/board/iplUrlProcessor.cpp"),
Object(Matching, "scene/board/iplUrlProcessor.cpp"),
Object(Equivalent, "scene/board/iplFocusObject.cpp"),
]
),
IPLSection("button", [
Object(Equivalent, "scene/button/iplButton.cpp"),
Object(Matching, "scene/button/iplButton.cpp"),
Object(Matching, "scene/button/iplArrow.cpp"),
]
),
IPLSection("calendar", [
Object(Equivalent, "scene/calendar/iplCalendar.cpp"),
Object(Equivalent, "scene/calendar/iplDate.cpp"),
Object(Matching, "scene/calendar/iplDate.cpp"),
]
),
IPLSection("channelEdit", [
Object(Matching, "scene/channelEdit/iplChannelEdit.cpp"),
Object(Equivalent, "scene/channelEdit/iplChanAppBase.cpp"),
Object(Equivalent, "scene/channelEdit/iplChanAppBox.cpp"),
Object(Matching, "scene/channelEdit/iplChanAppBox.cpp"),
Object(Equivalent, "scene/channelEdit/iplChanAppEdit.cpp"),
Object(Matching, "scene/channelEdit/iplAnmController.cpp"),
Object(Matching, "scene/channelEdit/iplNandSDCardManager.cpp"),
@@ -783,7 +783,7 @@ config.libs = [
]
),
IPLSection("kitayamaTest", [
Object(Equivalent, "scene/kitayamaTest/iplKitayamaTest.cpp"),
Object(Matching, "scene/kitayamaTest/iplKitayamaTest.cpp"),
Object(Matching, "scene/kitayamaTest/nandsdworker_autotest.cpp"),
]
),
@@ -871,7 +871,7 @@ config.libs = [
Object(NonMatching, "scene/setting/iplSensitivity.cpp"),
Object(Matching, "scene/setting/iplNCDSetting.cpp"),
Object(Matching, "scene/setting/iplParental.cpp"),
Object(NonMatching, "scene/setting/iplAPScanThread.cpp"),
Object(Matching, "scene/setting/iplAPScanThread.cpp"),
Object(NonMatching, "scene/setting/iplUSBAP.cpp"),
Object(NonMatching, "scene/setting/iplUSBAPThread.cpp"),
Object(NonMatching, "scene/setting/iplAOSSThread.cpp"),
@@ -890,16 +890,16 @@ config.libs = [
IPLSection("sceneSystem", [
Object(Matching, "scene/sceneSystem/iplSceneBase.cpp"),
Object(Matching, "scene/sceneSystem/iplSceneCreator.cpp"),
Object(Equivalent, "scene/sceneSystem/iplSceneManager.cpp"),
Object(Matching, "scene/sceneSystem/iplSceneManager.cpp"),
Object(Matching, "scene/sceneSystem/iplFaderSceneBase.cpp"),
]
),
IPLSection("textWriter", [
Object(Equivalent, "scene/textWriter/iplTextWriter.cpp"),
Object(Matching, "scene/textWriter/iplTextWriter.cpp"),
]
),
IPLSection("bannerSound", [
Object(Equivalent, "bannerSound/AudioWavePlayer.cpp"),
Object(Matching, "bannerSound/AudioWavePlayer.cpp"),
Object(Equivalent, "bannerSound/AxAdpcmPlayer.cpp"),
Object(Matching, "bannerSound/BannerSoundPlayer.cpp"),
Object(Matching, "bannerSound/AudioWaveUtility.cpp"),
@@ -931,7 +931,7 @@ config.libs = [
Object(NonMatching, "keyboard/MyTiLetterForm.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/MyTiBg.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiDebug.cpp", extra_cflags=["-O4,p"]),
Object(Equivalent, "keyboard/tiGUIManager.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiGUIManager.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiHKBManager.cpp", extra_cflags=["-O4,p"]),
Object(NonMatching, "keyboard/tiHwKeyboard.cpp", extra_cflags=["-O4,p"]),
Object(Matching, "keyboard/tiLayout.cpp", extra_cflags=["-O4,p"]),
@@ -944,7 +944,7 @@ config.libs = [
Object(Matching, "channelScript/systemmenu/VmSystem.c"),
Object(Matching, "channelScript/systemmenu/iplCSSystem.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSLayout.cpp"),
Object(Equivalent, "channelScript/systemmenu/iplCSPane.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSPane.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSMaterial.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSTexture.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSSavedata.cpp"),
@@ -957,7 +957,7 @@ config.libs = [
Object(Matching, "channelScript/systemmenu/iplCSRect.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSColor.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSSize.cpp"),
Object(Equivalent, "channelScript/systemmenu/iplCSAnim.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSAnim.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSSound.cpp"),
Object(Matching, "channelScript/systemmenu/iplCSImage.cpp"),
]
@@ -980,7 +980,7 @@ config.libs = [
]
),
ZI8Lib("zi8clib", [
Object(NonMatching, "clib/zaddress.c"),
Object(Matching, "clib/zaddress.c"),
Object(NonMatching, "clib/zconvert.c"),
Object(NonMatching, "clib/zi81key.c"),
Object(NonMatching, "clib/zi8alpha.c"),
@@ -1001,7 +1001,7 @@ config.libs = [
Object(NonMatching, "clib/zi8space.c"),
Object(NonMatching, "clib/zi8uwd.c"),
Object(Matching, "clib/zi8ver.c"),
Object(NonMatching, "clib/zi8ZHuwd.c"),
Object(Matching, "clib/zi8ZHuwd.c"),
Object(NonMatching, "clib/zidawg1.c"),
Object(NonMatching, "clib/zikorean.c"),
Object(NonMatching, "clib/ziswordw.c"),
@@ -1016,14 +1016,14 @@ config.libs = [
RevoEXLib("cdb", [
Object(Matching, "cdb/cdb.c"),
Object(Equivalent, "cdb/CDBConv.c"), # hmm
Object(NonMatching, "cdb/CDBDatabase.c"),
Object(Equivalent, "cdb/CDBFileSystemUtils.c"),
Object(Matching, "cdb/CDBDatabase.c"),
Object(Matching, "cdb/CDBFileSystemUtils.c"),
Object(Matching, "cdb/CDBFileSystem.c"),
Object(Matching, "cdb/CDBFileSystemVF.c"),
Object(Matching, "cdb/CDBFileSystemSD.c"),
Object(NonMatching, "cdb/CDBRecord.c"),
Object(Matching, "cdb/CDBRecordFile.c"),
Object(NonMatching, "cdb/CDBRecordKey.c"),
Object(Matching, "cdb/CDBRecordKey.c"),
Object(NonMatching, "cdb/CDBIntArray.c"),
Object(NonMatching, "cdb/CDBSystem.c"),
Object(Equivalent, "cdb/CDBAttr.c"),
@@ -1031,7 +1031,7 @@ config.libs = [
Object(Matching, "cdb/CDBFBridgeVF.c"),
Object(Matching, "cdb/CDBFBridgeSD.c"),
Object(Matching, "cdb/CDBId.c"),
Object(NonMatching, "cdb/CDBCrypt.c"),
Object(Matching, "cdb/CDBCrypt.c"),
]
),
RevoEXLib("ncd", [
@@ -1068,12 +1068,12 @@ config.libs = [
]
),
RevoEXLib("nwc24", [
Object(NonMatching, "nwc24/NWC24StdAPI.c"),
Object(Matching, "nwc24/NWC24StdAPI.c"),
Object(Matching, "nwc24/NWC24FileAPI.c"),
Object(Matching, "nwc24/NWC24Config.c"),
Object(Matching, "nwc24/NWC24Utils.c"),
Object(NonMatching, "nwc24/NWC24Manage.c"),
Object(NonMatching, "nwc24/NWC24MsgObj.c"),
Object(Matching, "nwc24/NWC24Manage.c"),
Object(Matching, "nwc24/NWC24MsgObj.c"),
Object(NonMatching, "nwc24/NWC24MBoxCtrl.c"),
Object(NonMatching, "nwc24/NWC24Mime.c"),
Object(Matching, "nwc24/NWC24Stream.c"),
@@ -1083,18 +1083,18 @@ config.libs = [
Object(NonMatching, "nwc24/NWC24MsgSubject.c"),
Object(Matching, "nwc24/NWC24Schedule.c"),
Object(NonMatching, "nwc24/NWC24DateParser.c"),
Object(Equivalent, "nwc24/NWC24FriendList.c"),
Object(Matching, "nwc24/NWC24FriendList.c"),
Object(Matching, "nwc24/NWC24SecretFList.c"),
Object(NonMatching, "nwc24/NWC24UserId.c"),
Object(Matching, "nwc24/NWC24UserId.c"),
Object(Matching, "nwc24/NWC24Time.c"),
Object(Matching, "nwc24/NWC24Ipc.c"),
Object(NonMatching, "nwc24/NWC24Download.c"),
Object(Equivalent, "nwc24/NWC24CHJump.c"),
Object(Matching, "nwc24/NWC24CHJump.c"),
Object(NonMatching, "nwc24/NWC24System.c"),
]
),
RevoEXLib("so", [
Object(NonMatching, "so/SOCommon.c"),
Object(Matching, "so/SOCommon.c"),
Object(NonMatching, "so/SOBasic.c"),
Object(NonMatching, "so/SOInformation.c"),
Object(NonMatching, "so/SOOption.c"),
@@ -1159,19 +1159,19 @@ config.libs = [
Object(Matching, "vf/system/pf_system.c"),
Object(Matching, "vf/develop/d_vf.c"),
Object(NonMatching, "vf/develop/d_vf_sys.c"),
Object(Matching, "vf/develop/d_vf_sys.c"),
Object(Matching, "vf/develop/d_hash.c"),
Object(Matching, "vf/develop/d_time.c"),
Object(Matching, "vf/develop/d_common.c"),
Object(NonMatching, "vf/develop/nand_drv.c"),
Object(NonMatching, "vf/develop/sd_drv.c"),
Object(Matching, "vf/develop/sd_drv.c"),
]
),
RevoEXLib("wd", [
Object(Matching, "wd/wd_misc.c"),
Object(Matching, "wd/wd_request.c"),
Object(Matching, "wd/wd_init.c"),
Object(NonMatching, "wd/WDScan.c"),
Object(Matching, "wd/WDScan.c"),
]
),
# RVLFaceLib
@@ -1197,20 +1197,20 @@ config.libs = [
# TMC JPEG
TMCJpegLib(
[
Object(NonMatching, "buffer/mkhdec3.c"),
Object(Matching, "buffer/mkhdec3.c"),
Object(Matching, "buffer/buffer_system.c"),
Object(Equivalent, "buffer/getcode.c"),
Object(Matching, "buffer/getcode.c"),
Object(NonMatching, "buffer/idct_block_var.c"),
Object(Matching, "api/decapi.c"),
Object(Matching, "jpegdec/jdec.c"),
Object(NonMatching, "jpegdec/jdec_main.c"),
Object(Matching, "jpegdec/jdec_main.c"),
Object(Matching, "jpegdec/jpformat.c"),
Object(NonMatching, "exif/exif_parse.c"),
Object(Equivalent, "reschange/iqdec_resolution_change_a3.c"),
Object(Matching, "reschange/iqdec_resolution_change_a3.c"),
Object(NonMatching, "reschange/idct_resolution_change_var.c"),
Object(NonMatching, "texturecvtr/Texture_MCUtoY8U8V8.c"),
@@ -1299,7 +1299,7 @@ config.libs = [
Object(Matching, "ut/ut_ResFontBase.cpp"),
Object(Matching, "ut/ut_ResFont.cpp"),
Object(NonMatching, "ut/ut_ArchiveFontBase.cpp"),
Object(NonMatching, "ut/ut_ArchiveFont.cpp"),
Object(Matching, "ut/ut_ArchiveFont.cpp"),
Object(Matching, "ut/ut_CharWriter.cpp"),
Object(Matching, "ut/ut_TextWriterBase.cpp"),
]
@@ -1446,7 +1446,7 @@ config.libs = [
RVLSDKLib("axfx", [
Object(Matching, "axfx/AXFXReverbHi.c"),
Object(Matching, "axfx/AXFXReverbHiDpl2.c"),
Object(NonMatching, "axfx/AXFXReverbHiExp.c"),
Object(Matching, "axfx/AXFXReverbHiExp.c"),
Object(NonMatching, "axfx/AXFXReverbHiExpDpl2.c"),
Object(Matching, "axfx/AXFXDelay.c"),
Object(Matching, "axfx/AXFXReverbStd.c"),
@@ -1483,7 +1483,7 @@ config.libs = [
Object(Matching, "card/CARDBios.c"),
Object(Matching, "card/CARDUnlock.c"),
Object(Matching, "card/CARDRdwr.c"),
Object(Equivalent, "card/CARDBlock.c"),
Object(Matching, "card/CARDBlock.c"),
Object(Matching, "card/CARDDir.c"),
Object(Matching, "card/CARDCheck.c"),
Object(Matching, "card/CARDMount.c"),
@@ -1699,7 +1699,7 @@ config.libs = [
Object(NonMatching, "fa/pf_fat12.c"),
Object(NonMatching, "fa/pf_fat16.c"),
Object(NonMatching, "fa/pf_fat32.c"),
Object(NonMatching, "fa/pf_fatfs.c"),
Object(Matching, "fa/pf_fatfs.c"),
Object(NonMatching, "fa/pf_file.c"),
Object(NonMatching, "fa/pf_path.c"),
Object(NonMatching, "fa/pf_sector.c"),
@@ -1714,7 +1714,7 @@ config.libs = [
Object(NonMatching, "fa/pf_chdmod.c"),
Object(NonMatching, "fa/pf_chmod.c"),
Object(NonMatching, "fa/pf_cinsert.c"),
Object(NonMatching, "fa/pf_closedir.c"),
Object(Matching, "fa/pf_closedir.c"),
Object(NonMatching, "fa/pf_combine.c"),
Object(NonMatching, "fa/pf_create.c"),
Object(NonMatching, "fa/pf_createdir.c"),
@@ -1722,27 +1722,27 @@ config.libs = [
Object(NonMatching, "fa/pf_derrnum.c"),
Object(NonMatching, "fa/pf_detach.c"),
Object(NonMatching, "fa/pf_divide.c"),
Object(NonMatching, "fa/pf_errnum.c"),
Object(Matching, "fa/pf_errnum.c"),
Object(NonMatching, "fa/pf_fadjust.c"),
Object(NonMatching, "fa/pf_fappend.c"),
Object(NonMatching, "fa/pf_fchdir.c"),
Object(NonMatching, "fa/pf_fclose.c"),
Object(Matching, "fa/pf_fclose.c"),
Object(NonMatching, "fa/pf_fconcat.c"),
Object(NonMatching, "fa/pf_feof.c"),
Object(NonMatching, "fa/pf_ferror.c"),
Object(Matching, "fa/pf_feof.c"),
Object(Matching, "fa/pf_ferror.c"),
Object(NonMatching, "fa/pf_finfo.c"),
Object(NonMatching, "fa/pf_flock.c"),
Object(Matching, "fa/pf_flock.c"),
Object(NonMatching, "fa/pf_fopen.c"),
Object(NonMatching, "fa/pf_format.c"),
Object(NonMatching, "fa/pf_fread.c"),
Object(Matching, "fa/pf_fread.c"),
Object(NonMatching, "fa/pf_fseek.c"),
Object(NonMatching, "fa/pf_fsetclstlink.c"),
Object(NonMatching, "fa/pf_fsexec.c"),
Object(NonMatching, "fa/pf_fsfirst.c"),
Object(NonMatching, "fa/pf_fsnext.c"),
Object(NonMatching, "fa/pf_fstat.c"),
Object(NonMatching, "fa/pf_fsync.c"),
Object(NonMatching, "fa/pf_fwrite.c"),
Object(Matching, "fa/pf_fsync.c"),
Object(Matching, "fa/pf_fwrite.c"),
Object(NonMatching, "fa/pf_getdev.c"),
Object(NonMatching, "fa/pf_getvol.c"),
Object(NonMatching, "fa/pf_getvolcfg.c"),
@@ -1831,19 +1831,19 @@ config.libs = [
Object(NonMatching, "fa/api/FACreatedir.c"),
Object(NonMatching, "fa/api/FADetach.c"),
Object(NonMatching, "fa/api/FAErrnum.c"),
Object(NonMatching, "fa/api/FAFclose.c"),
Object(NonMatching, "fa/api/FAFinfo.c"),
Object(Matching, "fa/api/FAFclose.c"),
Object(Matching, "fa/api/FAFinfo.c"),
Object(NonMatching, "fa/api/FAFopen.c"),
Object(NonMatching, "fa/api/FAFormat.c"),
Object(NonMatching, "fa/api/FAFread.c"),
Object(Matching, "fa/api/FAFread.c"),
Object(NonMatching, "fa/api/FAFseek.c"),
Object(NonMatching, "fa/api/FAFsfirst.c"),
Object(NonMatching, "fa/api/FAFsnext.c"),
Object(NonMatching, "fa/api/FAFstat.c"),
Object(NonMatching, "fa/api/FAFwrite.c"),
Object(Matching, "fa/api/FAFwrite.c"),
Object(NonMatching, "fa/api/FAGetdev.c"),
Object(NonMatching, "fa/api/FAInit.c"),
Object(NonMatching, "fa/api/FAInitDiskManager.c"),
Object(Matching, "fa/api/FAInitDiskManager.c"),
Object(NonMatching, "fa/api/FAMount.c"),
Object(NonMatching, "fa/api/FARegistCB.c"),
Object(NonMatching, "fa/api/FARemove.c"),
@@ -1863,7 +1863,7 @@ config.libs = [
]
),
RVLSDKLib("sdi", [
Object(NonMatching, "sdi/sdi_api.c"),
Object(Matching, "sdi/sdi_api.c"),
]
),
RVLSDKLib("nup", [
@@ -1906,10 +1906,10 @@ config.libs = [
EGGLib(
[
Object(Matching, "core/eggAllocator.cpp"),
Object(Equivalent, "core/eggAudioArcPlayerMgr.cpp"),
Object(Equivalent, "core/eggAudioExpMgr.cpp"),
Object(Matching, "core/eggAudioArcPlayerMgr.cpp"),
Object(Matching, "core/eggAudioExpMgr.cpp"),
Object(Matching, "core/eggAudioFxMgr.cpp"),
Object(Equivalent, "core/eggAudioMgr.cpp"),
Object(Matching, "core/eggAudioMgr.cpp"),
Object(Matching, "core/eggAudioHeapMgr.cpp"),
Object(Matching, "core/eggColorFader.cpp"),
Object(Matching, "core/eggDisposer.cpp"),
@@ -1940,44 +1940,44 @@ config.libs = [
),
# MSL Library
MSLLib("MSL_C.PPCEABI.bare.H", [
Object(NonMatching, "MSL_Common/alloc.c"),
Object(Matching, "MSL_Common/alloc.c"),
Object(Matching, "MSL_Common/errno.c"),
Object(NonMatching, "MSL_Common/ansi_files.c"),
Object(Matching, "MSL_Common/ansi_files.c"),
Object(NonMatching, "MSL_Common_Embedded/ansi_fp.c"),
Object(Matching, "MSL_Common/ctype.c"),
Object(NonMatching, "MSL_Common/locale.c"),
Object(NonMatching, "MSL_Common/arith.c"),
Object(NonMatching, "MSL_Common/bsearch.c"),
Object(NonMatching, "MSL_Common/buffer_io.c"),
Object(NonMatching, "MSL_Common/direct_io.c"),
Object(Matching, "MSL_Common/arith.c"),
Object(Matching, "MSL_Common/bsearch.c"),
Object(Matching, "MSL_Common/buffer_io.c"),
Object(Matching, "MSL_Common/direct_io.c", extra_cflags=["-Cpp_exceptions on"]),
Object(NonMatching, "MSL_Common/file_io.c"),
Object(NonMatching, "MSL_Common/FILE_POS.c"),
Object(NonMatching, "MSL_Common/mbstring.c"),
Object(Matching, "MSL_Common/FILE_POS.c"),
Object(Matching, "MSL_Common/mbstring.c"),
Object(Matching, "MSL_Common/mem.c"),
Object(Matching, "MSL_Common/mem_funcs.c"),
Object(Matching, "MSL_Common/math_api.c"),
Object(NonMatching, "MSL_Common/misc_io.c"),
Object(Matching, "MSL_Common/misc_io.c"),
Object(NonMatching, "MSL_Common/printf.c"),
Object(NonMatching, "MSL_Common/qsort.c"),
Object(Matching, "MSL_Common/qsort.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/rand.c"),
Object(NonMatching, "MSL_Common/scanf.c"),
Object(NonMatching, "MSL_Common/signal.c"),
Object(NonMatching, "MSL_Common/string.c"),
Object(Matching, "MSL_Common/signal.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/string.c"),
Object(Matching, "MSL_Common/float.c"),
Object(NonMatching, "MSL_Common/strtold.c"),
Object(NonMatching, "MSL_Common/strtoul.c"),
Object(NonMatching, "MSL_Common/time.c"),
Object(NonMatching, "MSL_Common/wctype.c"),
Object(Matching, "MSL_Common/wctype.c"),
Object(Matching, "MSL_Common/wmem.c"),
Object(NonMatching, "MSL_Common/wprintf.c"),
Object(NonMatching, "MSL_Common/wstring.c"),
Object(NonMatching, "MSL_Common/wchar_io.c"),
Object(Matching, "MSL_Common/wstring.c"),
Object(Matching, "MSL_Common/wchar_io.c"),
Object(Matching, "PPC_EABI/time.dolphin.c"),
Object(Matching, "PPC_EABI/sysenv.GCN.c"),
Object(Matching, "PPC_EABI/uart_console_io_gcn.c"),
Object(Matching, "PPC_EABI/abort_exit_ppc_eabi.c"),
Object(NonMatching, "MSL_Common/math_sun.c"),
Object(NonMatching, "MSL_Common/extras.c"),
Object(Matching, "MSL_Common/math_sun.c", extra_cflags=["-Cpp_exceptions on"]),
Object(Matching, "MSL_Common/extras.c"),
Object(Matching, "MSL_Common_Embedded/Math/e_acos.c"),
Object(Matching, "MSL_Common_Embedded/Math/e_asin.c"),

View File

@@ -48,13 +48,21 @@ namespace ext_ead {
extern const char* Message[6];
// TODO: sort out this messy match hack
#ifdef IPL_WWW_SURFACE_MESSAGE
#define IPL_WWW_SURFACE_ZERO_DECL __declspec(weak) extern const char IPL_WWW_SURFACE_ZERO[];
#define IPL_WWW_STRIPPED_MESSAGE print::IPL_WWW_SURFACE_ZERO
#else
#define IPL_WWW_SURFACE_ZERO_DECL
#define IPL_WWW_STRIPPED_MESSAGE ""
#endif
IPL_WWW_SURFACE_ZERO_DECL
#define IPL_WWW_REPORT_REDEFINE_MESSAGE(RESPECT_STRIP) \
char MSG_TICK_TIMER_TAG[12] = "[TickTimer]"; \
char MSG_WARNING_TAG[10] = "[Warning]"; \
char MSG_EVENT_TAG[10] = "[[Event]]"; \
const char* Message[] = { \
RESPECT_STRIP ? NULL : MSG_TICK_TIMER_TAG, RESPECT_STRIP ? NULL : MSG_WARNING_TAG, RESPECT_STRIP ? NULL : "[Info]", \
RESPECT_STRIP ? NULL : "[Debug]", RESPECT_STRIP ? "" : MSG_EVENT_TAG, RESPECT_STRIP ? NULL : "", \
RESPECT_STRIP ? NULL : "[Debug]", RESPECT_STRIP ? IPL_WWW_STRIPPED_MESSAGE : MSG_EVENT_TAG, RESPECT_STRIP ? NULL : "", \
};
} // namespace print
} // namespace www

View File

@@ -290,7 +290,7 @@ namespace textinput {
public:
PaneComponent(u32 id) : GUIComponent(id) { mpPane = NULL; }
virtual ~PaneComponent() {} // 0x08
virtual ~PaneComponent(); // 0x08
virtual void draw(); // 0x1C

View File

@@ -15,6 +15,7 @@ namespace textinput {
virtual void init();
virtual void updateInput(int chan, f32 x, f32 y, u32 trig, u32 hold, u32 release, void* data);
virtual bool updateInput(input::HKBManager& hkbManager);
private:

View File

@@ -162,6 +162,7 @@ namespace textinput {
virtual void autoScroll();
virtual bool doWordWrap(const wchar_t* string, u32, f32);
f32 getWordWrapRectWidth() const { return mRect.right - mRect.left; }
virtual void drawFixString(u32);
virtual void onSE(sound::SE seId);

View File

@@ -79,7 +79,7 @@ namespace textinput {
virtual void isEnableCursorCache();
virtual void getDrawModifyStartLine();
virtual void getDrawModifyEndLine();
virtual void getDrawCacheStartPos();
virtual u32 getDrawCacheStartPos() const;
virtual void dirtyDrawCache();
virtual void dirtyCursorCache();

View File

@@ -30,10 +30,14 @@ namespace gui {
virtual void draw(Mtx& mtx) {} // 0x14 (0x05)
virtual void draw() {} // 0x18 (0x06)
virtual ~Interface() {} // 0x1C (0x07)
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
virtual ~Interface(); // 0x1C (0x07)
#else
virtual ~Interface() {} // 0x1C (0x07)
#endif
};
class EventHandler {
class __declspec(novtable) EventHandler {
public:
enum {
ON_TRIG = 0,

View File

@@ -11,14 +11,18 @@
namespace ipl {
namespace gui {
class PaneComponent : public ::gui::PaneComponent {};
class PaneManager : public ::gui::PaneManager {
class PaneManager : public ::gui::PaneManager {
public:
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) {}
#ifdef IPL_CHANNEL_TITLE_NOVTABLE
virtual ~PaneManager();
#else
virtual ~PaneManager() {}
#endif
void update();
void update(int chan);

View File

@@ -45,32 +45,29 @@ namespace ipl {
};
template <typename T>
class HermiteIntp : public Interporation<T> {
class __declspec(novtable) HermiteIntp : public utility::FrameController {
public:
HermiteIntp() {}
virtual ~HermiteIntp();
void init(const T& start, const T& end, f32 maxFrame, f32 param_5, f32 param_6, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f) {
mStart = start;
mEnd = end;
utility::FrameController::init(playback, maxFrame, 0.0f, speed);
unkVal0 = param_5;
unkVal1 = param_6;
}
void init(const T& start, const T& end, f32 maxFrame, f32 param_5, f32 param_6, int playback = ANIM_TYPE_FORWARD, f32 speed = 1.0f);
T get() const {
f32 var_f27 = mFrame;
f32 var_f28 = 1.0f / mMaxFrame;
f32 t1t2 =
(var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) - (var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)));
T r = (mStart * (1.0f + t1t2)) - (mEnd * t1t2);
f32 temp_f4 = var_f27 * var_f27;
f32 temp_f7 = var_f28 * (var_f28 * (var_f27 * temp_f4));
f32 temp_f3 =
(unkVal0 * (var_f27 + (temp_f7 - (var_f28 * (2.0f * var_f27 * var_f27))))) + (unkVal1 * (temp_f7 - (var_f28 * temp_f4)));
r = r + temp_f3;
T r =
(mStart *
(1.0f + ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))))) -
(mEnd * ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))));
r +=
(unkVal0 *
(var_f27 +
((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) -
(var_f28 * (2.0f * var_f27 * var_f27))))) +
(unkVal1 * ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) -
(var_f28 * (var_f27 * var_f27))));
return r;
@@ -91,9 +88,49 @@ namespace ipl {
}
protected:
T mStart;
T mEnd;
f32 unkVal0;
f32 unkVal1;
};
template <>
class HermiteIntp<f32> : public utility::FrameController {
public:
HermiteIntp() {}
virtual ~HermiteIntp();
void init(const f32& start, const f32& end, f32 maxFrame, f32 param_5, f32 param_6, int playback = ANIM_TYPE_FORWARD,
f32 speed = 1.0f);
f32 get() const {
f32 var_f27 = mFrame;
f32 var_f28 = 1.0f / mMaxFrame;
f32 r =
(mStart *
(1.0f + ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))))) -
(mEnd * ((var_f28 * (var_f28 * (var_f28 * (var_f27 * (2.0f * var_f27 * var_f27))))) -
(var_f28 * (var_f28 * (3.0f * var_f27 * var_f27)))));
r +=
(unkVal0 *
(var_f27 + ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) -
(var_f28 * (2.0f * var_f27 * var_f27))))) +
(unkVal1 * ((var_f28 * (var_f28 * (var_f27 * (var_f27 * var_f27)))) -
(var_f28 * (var_f27 * var_f27))));
return r;
}
protected:
f32 mStart;
f32 mEnd;
f32 unkVal0;
f32 unkVal1;
};
#pragma dont_instantiate HermiteIntp<float>
} // namespace math
} // namespace ipl

View File

@@ -9,6 +9,7 @@ namespace ipl {
namespace scene {
class FriendListCache {
public:
void fin();
const NWC24FriendInfo& getInfo(int index) const { return mInfos[index]; }
private:
@@ -18,6 +19,7 @@ namespace ipl {
FADER_SCENE_CLASS(Address) {
public:
Address(EGG::Heap * heap, int);
virtual void destroy() override;
enum {
SCENE_ADD_WII = 1,

View File

@@ -9,6 +9,17 @@ namespace ipl {
public:
AddressEdit(EGG::Heap * heap, int friendCode);
void stt_msg_code_add();
void stt_msg_code_edit();
void stt_msg_parental();
void stt_msg_nwc24_error();
class String {
public:
void clear();
const wchar_t* getDispCodeLong() const;
};
enum {
SCENE_ADD_WII = 1,
SCENE_ADD_EMAIL,

View File

@@ -7,6 +7,12 @@
namespace ipl {
namespace scene {
class MaxDate : public utility::Date {
public:
u8 padding[0x10];
MaxDate(int year, int month, int day) : utility::Date(year, month, day) {}
};
class Date : ::gui::EventHandler {
public:
typedef struct AnmFrame {
@@ -82,7 +88,7 @@ namespace ipl {
static const char* mscAnimPanes[ANIM_PANE_MAX];
static utility::Date mscMinDate;
static utility::Date mscMaxDate;
static MaxDate mscMaxDate;
nw4r::ut::Link mNode1; // 0x40
nw4r::ut::Link mNode2; // 0x48

View File

@@ -404,7 +404,12 @@ namespace ipl {
int mModuleIndex; // 0x400
EGG::ExpHeap* mpCSHeap; // 0x404
static ESTicketView msTicketView;
struct TicketViewStorage {
ESTicketView view;
u8 pad[8];
};
static TicketViewStorage msTicketView;
static ESTicketView msUnlockTicket;
static const char* mscBtnNames[BTN_MAX];

View File

@@ -11,6 +11,12 @@
namespace ipl {
namespace snd {
enum EAudioOutputMode {
AUDIO_OUTPUT_MODE_STEREO = 0,
AUDIO_OUTPUT_MODE_SURROUND = 1,
AUDIO_OUTPUT_MODE_MONO = 2,
};
struct tagSSeInfo;
class System : EGG::SimpleAudioMgrWithFx {
@@ -18,7 +24,7 @@ namespace ipl {
System();
void initOnMemory(const void* data, EGG::Heap* heap, u32 soundSize);
void initFx();
void initFx() NO_INLINE;
void shutup(BOOL shutUpDMA);
@@ -48,6 +54,8 @@ namespace ipl {
int pauseOnSE();
int pauseOffSE();
void setOutputMode(EAudioOutputMode mode);
BOOL isSEActive(const char* sndName);
BOOL isSEActive(u32 id);
@@ -55,7 +63,7 @@ namespace ipl {
tagSSeInfo* FIsSEActive(u32 id);
tagSSeInfo* getFreeSEBlock(bool force);
void startBannerSound(void*, u32, bool ignoreSize = false);
BOOL startBannerSound(void*, u32, bool ignoreSize = false);
void stopBannerSound(int unk = 0);
BOOL checkTmpSoundFile(void*, u32);

View File

@@ -25,7 +25,7 @@ namespace ipl {
void closeDatabase();
BOOL createNewRecord(const char* recordName, const char* recordFileType, const OSCalendarTime* dateTime, u32* gameCode, u16* makerCode,
const math::VEC2& recordPos, u32 recordFlags, const NWC24FriendAddr& addr, u16 addrType, u16 noReplyFlag,
const math::VEC2& recordPos, u32 recordFlags, const NWC24FriendAddr& addr, NWC24FriendType addrType, u16 noReplyFlag,
const wchar_t* titleText, const wchar_t* bodyText, const void* faceData, const void** attachData, u32* attachSize,
RBRAttachmentType* attachType);

View File

@@ -83,14 +83,14 @@ namespace ipl {
virtual ~Base(); // 0x08
virtual int getType() const; // 0x0C
virtual int getChannel() const; // 0x10
virtual int down(u32 button) const; // 0x14
virtual int downTrg(u32 button) const; // 0x18
virtual int upTrg(u32 button) const; // 0x1C
virtual bool down(u32 button) const; // 0x14
virtual bool downTrg(u32 button) const; // 0x18
virtual bool upTrg(u32 button) const; // 0x1C
virtual int pinch() const; // 0x20
virtual int pinchTrg() const; // 0x24
virtual int pinchOffTrg() const; // 0x28
virtual int decide() const; // 0x2C
virtual int repeat(u32 button) const; // 0x30
virtual bool repeat(u32 button) const; // 0x30
virtual BOOL rumble(int timer = 0); // 0x34
virtual void cancelRumbling(); // 0x38
virtual int getHoldFlag() const; // 0x3C
@@ -110,7 +110,7 @@ namespace ipl {
* @return The Horizon X and Y as `ipl::math::VEC2`.
*/
virtual math::VEC2 getHorizon() const; // 0x5C
virtual int getDpdDistance() const; // 0x60
virtual f32 getDpdDistance() const; // 0x60
virtual KPADStatus* getKPADStatus() const; // 0x64
virtual PADStatus* getPADStatus() const; // 0x68
virtual bool isValidBtn() const; // 0x6C
@@ -145,25 +145,79 @@ namespace ipl {
~Interface() {}
virtual int down(u32 button) const override; // 0x10
virtual int downTrg(u32 button) const override; // 0x18
virtual bool down(u32 button) const override; // 0x10
virtual bool downTrg(u32 button) const override; // 0x18
virtual bool upTrg(u32 button) const override;
virtual int pinch() const override; // 0x1C
virtual int pinchTrg() const override;
virtual int pinchOffTrg() const override;
virtual bool repeat(u32 button) const override;
virtual int getClassicHoldFlag() const override; // 0x48
virtual int getClassicTrigFlag() const override; // 0x4C
virtual int getClassicReleaseFlag() const override; // 0x50
virtual KPADStatus* getKPADStatus() const override; // 0x64
virtual PADStatus* getPADStatus() const override; // 0x68
virtual f32 getDpdDistance() const override; // 0x60
virtual bool isValidBtn() const override; // 0x6C
virtual int getReleaseFlag() const override;
virtual int getHoldFlag() const override;
virtual int getTrigFlag() const override;
virtual void cancelRumbling() override;
virtual int getChannel() const override;
virtual int getType() const override;
virtual bool isValidDpd() const override;
virtual math::VEC2 getDpdPos() const override;
virtual math::VEC2 getDpdProjectionPos() const override;
virtual math::VEC2 getHorizon() const override;
virtual f32 getMainStickX() const override;
virtual f32 getMainStickY() const override;
virtual f32 getSubStickX() const override;
virtual f32 getSubStickY() const override;
virtual BOOL rumble(int type = 0) override;
virtual void read() override;
};
class Master {
public:
virtual ~Master();
virtual bool down(u32 button) const;
virtual bool downTrg(u32 button) const;
virtual bool upTrg(u32 button) const;
virtual bool repeat(u32 button) const;
virtual int decide() const;
virtual void setForceInvalid(bool flag);
private:
bool call(u32 button, bool (Interface::*func)(u32) const) const;
Interface** mpControllers;
};
class Revolution : public Interface {
public:
Revolution(int chan, KPADStatus& arg1) : Interface(chan, arg1) {}
Revolution(int chan, int type, KPADStatus& arg1);
virtual ~Revolution();
virtual int down(u32 button) const override; // 0x10
virtual bool down(u32 button) const override; // 0x10
virtual bool downTrg(u32 button) const override;
virtual bool upTrg(u32 button) const override;
virtual int pinch() const override;
virtual int pinchTrg() const override;
virtual int pinchOffTrg() const override;
virtual bool repeat(u32 button) const override;
virtual f32 getDpdDistance() const override; // 0x60
virtual KPADStatus* getKPADStatus() const override; // 0x64
virtual int getReleaseFlag() const override;
virtual int getTrigFlag() const override;
virtual int getHoldFlag() const override;
virtual math::VEC2 getDpdPos() const override;
virtual math::VEC2 getDpdProjectionPos() const override; // 0x58
virtual math::VEC2 getHorizon() const override;
virtual bool isValidBtn() const override; // 0x6C
virtual bool isValidDpd() const override; // 0x70
@@ -175,6 +229,9 @@ namespace ipl {
public:
Classic(int arg0, KPADStatus& arg1);
virtual bool down(u32 button) const override;
virtual bool downTrg(u32 button) const override;
virtual bool upTrg(u32 button) const override;
virtual int getClassicHoldFlag() const override; // 0x48
virtual int getClassicTrigFlag() const override; // 0x4C
virtual int getClassicReleaseFlag() const override; // 0x50
@@ -204,7 +261,11 @@ namespace ipl {
Interface* getMasterController();
Interface* getYoungController();
static void* alloc(u32 size);
static int free(void* ptr);
private:
static EGG::Allocator* mpAllocator;
u8 dummy[0x2F8];
};
} // namespace controller

View File

@@ -82,6 +82,8 @@ namespace ipl {
void makePriorTitleIDList(ESTitleId* titleIdsOut, ESTitleId* titleIdsIn, u32 titleCount);
void integrateTitleIDList(ESTitleId* titleIdsOut, ESTitleId* titleIdsIn, u32 titleCount);
void makeTmpList(ESTitleId* titleIdsOut, u32 availableCount, ESTitleId* titleIdsIn, u32 titleCount);
void moveTitleTmpToPrior(ESTitleId* titleIdsOut, const ESTitleId* titleIdsIn);
BOOL doUpdateChanInfos(ESTitleId* titleIds);

View File

@@ -44,32 +44,32 @@ namespace EGG {
mpArchive = &mDvdSoundArchive;
if (pDvdArchive->Open(pPath)) {
u32 headerSize;
u32 setupSize;
u32 strmSize;
u32 stringSize;
mbIsOpeningArchive = true;
headerSize = pDvdArchive->GetHeaderSize();
u32 headerSize = pDvdArchive->GetHeaderSize();
void* pHeaderBuffer = pHeap->Alloc(headerSize, NULL, NULL);
if (!pDvdArchive->LoadHeader(pHeaderBuffer, headerSize)) {
if (!pDvdArchive->LoadHeader(pHeap->Alloc(headerSize, NULL, NULL), headerSize)) {
return NULL;
}
u32 setupSize = mSoundArchivePlayer.GetRequiredMemSize(pDvdArchive);
u32 strmSize = mSoundArchivePlayer.GetRequiredStrmBufferSize(pDvdArchive);
void* pSetupBuffer = pHeap->Alloc(setupSize, NULL, NULL);
void* pStrmBuffer = pHeap->Alloc(strmSize, NULL, NULL);
setupSize = mSoundArchivePlayer.GetRequiredMemSize(pDvdArchive);
strmSize = mSoundArchivePlayer.GetRequiredStrmBufferSize(pDvdArchive);
if (!mSoundArchivePlayer.Setup(pDvdArchive, pSetupBuffer, setupSize, pStrmBuffer, strmSize)) {
if (!mSoundArchivePlayer.Setup(pDvdArchive, pHeap->Alloc(setupSize, NULL, NULL), setupSize,
pHeap->Alloc(strmSize, NULL, NULL), strmSize)) {
mbIsOpeningArchive = false;
return NULL;
}
u32 stringSize = pDvdArchive->GetLabelStringDataSize();
void* pStringBuffer = pHeap->Alloc(stringSize, NULL, NULL);
stringSize = pDvdArchive->GetLabelStringDataSize();
pDvdArchive->LoadLabelStringData(pStringBuffer, stringSize);
pDvdArchive->LoadLabelStringData(pHeap->Alloc(stringSize, NULL, NULL), stringSize);
mStorage = SARC_STORAGE_DVD;
mbIsOpeningArchive = false;
mStorage = SARC_STORAGE_DVD;
return &mSoundArchivePlayer;
}
@@ -82,7 +82,7 @@ namespace EGG {
}
nw4r::snd::NandSoundArchive* pNandArchive = &mNandSoundArchive;
mpArchive = pNandArchive;
mpArchive = &mNandSoundArchive;
if (pNandArchive->Open(pPath)) {
mbIsOpeningArchive = true;
@@ -94,10 +94,14 @@ namespace EGG {
return NULL;
}
u32 setupSize = mSoundArchivePlayer.GetRequiredMemSize(pNandArchive);
u32 strmSize = mSoundArchivePlayer.GetRequiredStrmBufferSize(pNandArchive);
void* pStrmBuffer = pHeap->Alloc(strmSize, NULL, NULL);
void* pSetupBuffer = pHeap->Alloc(setupSize, NULL, NULL);
void* pStrmBuffer;
u32 setupSize;
u32 strmSize;
void* pSetupBuffer;
setupSize = mSoundArchivePlayer.GetRequiredMemSize(pNandArchive);
strmSize = mSoundArchivePlayer.GetRequiredStrmBufferSize(pNandArchive);
pStrmBuffer = pHeap->Alloc(strmSize, NULL, NULL);
pSetupBuffer = pHeap->Alloc(setupSize, NULL, NULL);
if (!mSoundArchivePlayer.Setup(pNandArchive, pSetupBuffer, setupSize, pStrmBuffer, strmSize)) {
mbIsOpeningArchive = false;
@@ -122,17 +126,20 @@ namespace EGG {
pHeap = mpSoundHeap;
}
void* pStrmBuffer;
nw4r::snd::MemorySoundArchive* pMemoryArchive = &mMemorySoundArchive;
mpArchive = pMemoryArchive;
if (pMemoryArchive->Setup(pBinary)) {
mbIsOpeningArchive = true;
u32 mramSize = mSoundArchivePlayer.GetRequiredMemSize(pMemoryArchive);
u32 strmSize = mSoundArchivePlayer.GetRequiredStrmBufferSize(pMemoryArchive);
void* pStrmBuffer = pHeap->Alloc(strmSize, NULL, NULL);
void* pMramBuffer = pHeap->Alloc(mramSize, NULL, NULL);
u32 mramSize;
u32 strmSize;
void* pMramBuffer;
mramSize = mSoundArchivePlayer.GetRequiredMemSize(pMemoryArchive);
strmSize = mSoundArchivePlayer.GetRequiredStrmBufferSize(pMemoryArchive);
pStrmBuffer = pHeap->Alloc(strmSize, NULL, NULL);
pMramBuffer = pHeap->Alloc(mramSize, NULL, NULL);
if (!mSoundArchivePlayer.Setup(pMemoryArchive, pMramBuffer, mramSize, pStrmBuffer, strmSize)) {
mbIsOpeningArchive = false;

View File

@@ -5,6 +5,19 @@
extern "C" {
#endif
#define SIGNAL_ACTION_DEFAULT ((__signal_func_ptr)0)
#define SIGNAL_ACTION_IGNORE ((__signal_func_ptr)1)
#define SIGNAL_ABORT 1
#define SIGNAL_UNK2 2
#define SIGNAL_UNK3 3
#define SIGNAL_UNK4 4
#define SIGNAL_UNK5 5
#define SIGNAL_UNK6 6
#define SIGNAL_UNK7 7
typedef void (*__signal_func_ptr)(int);
int raise(int signal);
#ifdef __cplusplus

View File

@@ -0,0 +1,112 @@
#include <errno.h>
#include <internal/file_struct.h>
#include <stdio.h>
enum file_kinds {
file_closed,
file_disk,
file_console,
file_unavailable
};
enum io_states {
neutral,
writing,
reading,
rereading
};
enum io_modes {
io_read = 1,
io_write = 2,
io_append = 4
};
int __flush_buffer(FILE* file, size_t* pos);
long _ftell(FILE* file) {
int buf = 0;
int pos;
unsigned char file_kind = file->mode.file_kind;
if (!(file_kind == file_disk || file_kind == file_console) || file->state.error) {
errno = EFPOS;
return -1;
}
if (file->state.io_state == neutral) {
return file->pos;
}
pos = file->buffer_pos + (file->buffer_ptr - file->buffer);
if (file->state.io_state >= rereading) {
buf = file->state.io_state - reading;
pos -= buf;
}
if (!file->mode.binary_io) {
int n = file->buffer_ptr - file->buffer - buf;
unsigned char* p = file->buffer;
while (n-- != 0) {
if (*p++ == '\n') {
pos++;
}
}
}
return pos;
}
long ftell(FILE* stream) {
return _ftell(stream);
}
int _fseek(FILE* file, long offset, int whence) {
if (file->mode.file_kind != file_disk || file->state.error != 0) {
errno = EFPOS;
return -1;
}
if (file->state.io_state == writing) {
if (__flush_buffer(file, 0) != 0) {
file->state.error = 1;
file->buffer_len = 0;
errno = EFPOS;
return -1;
}
}
if (whence == 1) {
whence = 0;
offset += _ftell(file);
}
if ((whence != 2) && file->mode.io_mode != (io_read | io_write) && (file->state.io_state == reading || file->state.io_state == rereading)) {
if ((offset >= file->pos) || offset < file->buffer_pos) {
file->state.io_state = neutral;
} else {
file->buffer_ptr = file->buffer + (offset - file->buffer_pos);
file->buffer_len = file->pos - offset;
file->state.io_state = reading;
}
} else {
file->state.io_state = neutral;
}
if (file->state.io_state == neutral) {
if (file->pos_proc != 0 && (*file->pos_proc)(file->handle, &offset, whence, file->ref)) {
file->state.error = 1;
file->buffer_len = 0;
errno = EFPOS;
return -1;
}
file->state.eof = 0;
file->pos = offset;
file->buffer_len = 0;
}
return 0;
}

View File

@@ -3,144 +3,151 @@
#pragma exceptions on
extern void __sys_free(void* ptr);
typedef struct Block {
struct Block* prev;
struct Block* next;
unsigned int max_size;
unsigned int size;
} Block;
typedef struct SubBlock {
unsigned int size;
Block* block;
struct SubBlock* prev;
struct SubBlock* next;
} SubBlock;
struct FixSubBlock;
typedef struct FixBlock {
struct FixBlock* prev_;
struct FixBlock* next_;
unsigned int client_size_;
struct FixSubBlock* start_;
unsigned int n_allocated_;
} FixBlock;
typedef struct FixSubBlock {
FixBlock* block_;
struct FixSubBlock* next_;
} FixSubBlock;
typedef struct FixStart {
FixBlock* tail_;
FixBlock* head_;
} FixStart;
typedef struct __mem_pool_obj {
Block* start_;
FixStart fix_start[6];
} __mem_pool_obj;
extern void* __sys_alloc(unsigned int size);
typedef struct __mem_pool {
void* reserved[14];
} __mem_pool;
typedef int tag_word;
typedef struct Block {
struct Block* pPrev;
struct Block* pNext;
unsigned int maxSize;
unsigned int size;
} Block;
typedef struct block_header {
tag_word tag;
struct block_header* prev;
struct block_header* next;
} block_header;
typedef struct SubBlock {
unsigned int size;
Block* pBlock;
struct SubBlock* pPrev;
struct SubBlock* pNext;
} SubBlock;
typedef struct list_header {
block_header* rover;
block_header header;
} list_header;
struct FixSubBlock;
typedef struct heap_header {
struct heap_header* prev;
struct heap_header* next;
} heap_header;
typedef struct FixBlock {
struct FixBlock* pPrev;
struct FixBlock* pNext;
unsigned int clientSize;
struct FixSubBlock* pStart;
unsigned int allocatedSize;
} FixBlock;
struct mem_pool_obj;
typedef void* (*sys_alloc_ptr)(unsigned int, struct mem_pool_obj*);
typedef void (*sys_free_ptr)(void*, struct mem_pool_obj*);
typedef struct FixSubBlock {
FixBlock* pBlock;
struct FixSubBlock* pNext;
} FixSubBlock;
typedef struct pool_options {
sys_alloc_ptr sys_alloc_func;
sys_free_ptr sys_free_func;
unsigned int min_heap_size;
int always_search_first;
} pool_options;
typedef struct FixStart {
FixBlock* pTail;
FixBlock* pHead;
} FixStart;
typedef struct mem_pool_obj {
list_header free_list;
pool_options options;
heap_header* heap_list;
void* userData;
} mem_pool_obj;
mem_pool_obj __malloc_pool;
static int initialized = 0;
typedef struct __mem_pool_obj {
Block* pStart;
FixStart fixStart[6];
} __mem_pool_obj;
static SubBlock* SubBlock_merge_prev(SubBlock*, SubBlock**);
static void SubBlock_merge_next(SubBlock*, SubBlock**);
static SubBlock* Block_subBlock(Block*, unsigned int, unsigned int*);
static void* allocate_from_var_pools(__mem_pool_obj*, unsigned int, unsigned int*);
static void* soft_allocate_from_var_pools(__mem_pool_obj*, unsigned int, unsigned int*);
static void FixBlock_construct(FixBlock*, FixBlock*, FixBlock*, unsigned int, void*, unsigned int);
static void* allocate_from_fixed_pools(__mem_pool_obj*, unsigned int, unsigned int*);
static unsigned int __pool_allocate_resize(__mem_pool_obj*, void*, unsigned int, unsigned int*);
static const unsigned int fix_pool_sizes[] = {4, 12, 20, 36, 52, 68};
const unsigned int fix_pool_sizes[] = {4, 12, 20, 36, 52, 68};
#define SubBlock_size(ths) ((ths)->size & 0xFFFFFFF8)
#define SubBlock_block(ths) ((Block*)((unsigned int)((ths)->block) & ~0x1))
#define SubBlock_block(ths) ((Block*)((unsigned int)((ths)->pBlock) & ~0x1))
#define Block_size(ths) ((ths)->size & 0xFFFFFFF8)
#define Block_start(ths) (*(SubBlock**)((char*)(ths) + Block_size((ths)) - sizeof(unsigned int)))
#define SubBlock_set_free(ths) \
unsigned int this_size = SubBlock_size((ths)); \
(ths)->size &= ~0x2; \
*(unsigned int*)((char*)(ths) + this_size) &= ~0x4; \
((SubBlock*)((char*)(ths) + this_size))->size &= ~0x4; \
*(unsigned int*)((char*)(ths) + this_size - sizeof(unsigned int)) = this_size
#define SubBlock_is_free(ths) !((ths)->size & 2)
#define SubBlock_set_size(ths, sz) \
(ths)->size &= ~0xFFFFFFF8; \
(ths)->size |= (sz) & 0xFFFFFFF8; \
if (SubBlock_is_free((ths))) \
*(unsigned int*)((char*)(ths) + (sz) - sizeof(unsigned int)) = (sz)
if (SubBlock_is_free((ths))) { \
*(unsigned int*)((char*)(ths) + (sz) - sizeof(unsigned int)) = (sz); \
}
#define SubBlock_from_pointer(ptr) ((SubBlock*)((char*)(ptr) - 8))
#define FixSubBlock_from_pointer(ptr) ((FixSubBlock*)((char*)(ptr) - 4))
#define FixBlock_client_size(ths) ((ths)->client_size_)
#define FixSubBlock_size(ths) (FixBlock_client_size((ths)->block_))
#define FixBlock_client_size(ths) ((ths)->clientSize)
#define FixSubBlock_size(ths) (FixBlock_client_size((ths)->pBlock))
#define classify(ptr) (*(unsigned int*)((char*)(ptr) - sizeof(unsigned int)) & 1)
#define classify(ptr) ((unsigned int)FixSubBlock_from_pointer(ptr)->pBlock & 1)
#define __msize_inline(ptr) (!classify(ptr) ? FixSubBlock_size(FixSubBlock_from_pointer(ptr)) : SubBlock_size(SubBlock_from_pointer(ptr)) - 8)
#define Block_empty(ths) (_sb = (SubBlock*)((char*)(ths) + 16)), SubBlock_is_free(_sb) && SubBlock_size(_sb) == Block_size((ths)) - 24
#define Block_empty(ths) (_sb = (SubBlock*)(ths + 1)), SubBlock_is_free(_sb) && SubBlock_size(_sb) == Block_size((ths)) - 24
void Block_link(Block* ths, SubBlock* sb) {
SubBlock** st;
SubBlock_set_free(sb);
st = &Block_start(ths);
void Block_link(Block*, SubBlock*);
void deallocate_from_fixed_pools(__mem_pool_obj*, void*, unsigned int);
void* malloc(unsigned int);
void* calloc(unsigned int, unsigned int);
void* realloc(void*, unsigned int);
void free(void*);
if (*st != 0) {
sb->prev = (*st)->prev;
sb->prev->next = sb;
sb->next = *st;
(*st)->prev = sb;
*st = sb;
*st = SubBlock_merge_prev(*st, st);
SubBlock_merge_next(*st, st);
} else {
*st = sb;
sb->prev = sb;
sb->next = sb;
static void SubBlock_construct(SubBlock* ths, unsigned int size, Block* bp, int prev_alloc, int this_alloc) {
ths->pBlock = (Block*)((unsigned int)bp | 1);
ths->size = size;
if (prev_alloc) {
ths->size |= 4;
}
if (this_alloc) {
ths->size |= 2;
((SubBlock*)((char*)ths + size))->size |= 4;
} else {
*(unsigned int*)((char*)ths + size - sizeof(unsigned int)) = size;
}
}
static SubBlock* SubBlock_split(SubBlock* ths, unsigned int sz) {
unsigned int origsize;
int isfree;
int isprevalloc;
SubBlock* np;
Block* bp;
origsize = SubBlock_size(ths);
isfree = SubBlock_is_free(ths);
isprevalloc = (int)(ths->size & 4);
np = (SubBlock*)((char*)ths + sz);
bp = SubBlock_block(ths);
SubBlock_construct(ths, sz, bp, isprevalloc, !isfree);
SubBlock_construct(np, origsize - sz, bp, !isfree, !isfree);
if (isfree) {
np->pNext = ths->pNext;
np->pNext->pPrev = np;
np->pPrev = ths;
ths->pNext = np;
}
return np;
}
static void Block_unlink(Block* ths, SubBlock* sb) {
SubBlock** st;
unsigned int this_size = SubBlock_size(sb);
sb->size |= 2;
((SubBlock*)((char*)sb + this_size))->size |= 4;
st = &Block_start(ths);
if (*st == sb) {
*st = sb->pNext;
}
if (*st == sb) {
*st = NULL;
ths->maxSize = 0;
} else {
sb->pNext->pPrev = sb->pPrev;
sb->pPrev->pNext = sb->pNext;
}
if (ths->max_size < SubBlock_size(*st))
ths->max_size = SubBlock_size(*st);
}
static SubBlock* SubBlock_merge_prev(SubBlock* ths, SubBlock** start) {
@@ -149,72 +156,39 @@ static SubBlock* SubBlock_merge_prev(SubBlock* ths, SubBlock** start) {
if (!(ths->size & 0x04)) {
prevsz = *(unsigned int*)((char*)ths - sizeof(unsigned int));
if (prevsz & 0x2)
if (prevsz & 0x2) {
return ths;
}
p = (SubBlock*)((char*)ths - prevsz);
SubBlock_set_size(p, prevsz + SubBlock_size(ths));
if (*start == ths)
*start = (*start)->next;
ths->next->prev = ths->prev;
ths->next->prev->next = ths->next;
if (*start == ths) {
*start = (*start)->pNext;
}
ths->pNext->pPrev = ths->pPrev;
ths->pNext->pPrev->pNext = ths->pNext;
return p;
}
return ths;
}
static void SubBlock_merge_next(SubBlock* pBlock, SubBlock** pStart) {
SubBlock* next_sub_block;
unsigned int this_cur_size;
next_sub_block = (SubBlock*)((char*)pBlock + (pBlock->size & 0xFFFFFFF8));
if (!(next_sub_block->size & 2)) {
this_cur_size = (pBlock->size & 0xFFFFFFF8) + (next_sub_block->size & 0xFFFFFFF8);
pBlock->size &= ~0xFFFFFFF8;
pBlock->size |= this_cur_size & 0xFFFFFFF8;
if (!(pBlock->size & 2)) {
*(unsigned int*)((char*)(pBlock) + (this_cur_size)-4) = (this_cur_size);
}
if (!(pBlock->size & 2)) {
*(unsigned int*)((char*)pBlock + this_cur_size) &= ~4;
} else {
*(unsigned int*)((char*)pBlock + this_cur_size) |= 4;
}
if (*pStart == next_sub_block) {
*pStart = (*pStart)->next;
}
if (*pStart == next_sub_block) {
*pStart = 0;
}
next_sub_block->next->prev = next_sub_block->prev;
next_sub_block->prev->next = next_sub_block->next;
}
}
static Block* __unlink(__mem_pool_obj* pool_obj, Block* bp) {
Block* result = bp->next;
Block* result = bp->pNext;
if (result == bp) {
result = 0;
result = NULL;
}
if (pool_obj->start_ == bp) {
pool_obj->start_ = result;
if (pool_obj->pStart == bp) {
pool_obj->pStart = result;
}
if (result != 0) {
result->prev = bp->prev;
result->prev->next = result;
if (result != NULL) {
result->pPrev = bp->pPrev;
result->pPrev->pNext = result;
}
bp->next = 0;
bp->prev = 0;
bp->pNext = NULL;
bp->pPrev = NULL;
return result;
}
@@ -231,12 +205,13 @@ static void deallocate_from_var_pools(__mem_pool_obj* pool_obj, void* ptr) {
}
}
void __init_pool_obj(__mem_pool* pool_obj) {
static void __init_pool_obj(__mem_pool* pool_obj) {
memset(pool_obj, 0, sizeof(__mem_pool_obj));
}
__mem_pool protopool;
static __mem_pool* get_malloc_pool() {
static __mem_pool protopool;
static unsigned char init = 0;
if (!init) {
__init_pool_obj(&protopool);
@@ -246,67 +221,11 @@ static __mem_pool* get_malloc_pool() {
return &protopool;
}
void deallocate_from_fixed_pools(__mem_pool_obj* pool_obj, void* ptr, unsigned int size) {
unsigned int i = 0;
FixSubBlock* p;
FixBlock* b;
FixStart* fs;
while (size > fix_pool_sizes[i]) {
++i;
}
fs = &pool_obj->fix_start[i];
p = FixSubBlock_from_pointer(ptr);
b = p->block_;
if (b->start_ == 0 && fs->head_ != b) {
if (fs->tail_ == b) {
fs->head_ = fs->head_->prev_;
fs->tail_ = fs->tail_->prev_;
} else {
b->prev_->next_ = b->next_;
b->next_->prev_ = b->prev_;
b->next_ = fs->head_;
b->prev_ = b->next_->prev_;
b->prev_->next_ = b;
b->next_->prev_ = b;
fs->head_ = b;
}
}
p->next_ = b->start_;
b->start_ = p;
if (--b->n_allocated_ == 0) {
if (fs->head_ == b) {
fs->head_ = b->next_;
}
if (fs->tail_ == b) {
fs->tail_ = b->prev_;
}
b->prev_->next_ = b->next_;
b->next_->prev_ = b->prev_;
if (fs->head_ == b) {
fs->head_ = 0;
}
if (fs->tail_ == b) {
fs->tail_ = 0;
}
deallocate_from_var_pools(pool_obj, b);
}
}
void __pool_free(__mem_pool* pool, void* ptr) {
static void __pool_free(__mem_pool* pool, void* ptr) {
__mem_pool_obj* pool_obj;
unsigned int size;
if (ptr == 0) {
if (ptr == NULL) {
return;
}
@@ -320,6 +239,559 @@ void __pool_free(__mem_pool* pool, void* ptr) {
}
}
static void link(__mem_pool_obj* pool, Block* bp) {
if (pool->pStart != NULL) {
bp->pPrev = pool->pStart->pPrev;
bp->pPrev->pNext = bp;
bp->pNext = pool->pStart;
pool->pStart->pPrev = bp;
pool->pStart = bp;
} else {
pool->pStart = bp;
bp->pPrev = bp;
bp->pNext = bp;
}
}
static void Block_construct(Block* ths, unsigned int size) {
SubBlock* sb;
ths->size = size | 3;
((SubBlock*)((char*)ths + size - 8))->size = ths->size;
sb = (SubBlock*)(ths + 1);
sb->pBlock = (Block*)((unsigned int)ths | 1);
sb->size = size - 0x18;
*(unsigned int*)((char*)sb + (size - 0x18) - sizeof(unsigned int)) = size - 0x18;
ths->maxSize = size - 0x18;
Block_start(ths) = NULL;
Block_link(ths, sb);
}
static Block* link_new_block(__mem_pool_obj* pool, unsigned int size) {
Block* bp;
size = (size + 31) & ~7;
if (size < 0x10000) {
size = 0x10000;
}
bp = (Block*)__sys_alloc(size);
if (bp == NULL) {
return NULL;
}
Block_construct(bp, size);
link(pool, bp);
return bp;
}
static SubBlock* Block_subBlock(Block* bp, unsigned int size, unsigned int* out) {
SubBlock* st;
SubBlock* sb;
unsigned int sb_size;
unsigned int max_found;
st = Block_start(bp);
if (st == NULL) {
bp->maxSize = 0;
return NULL;
}
sb = st;
sb_size = SubBlock_size(sb);
max_found = sb_size;
while (sb_size < size) {
sb = sb->pNext;
sb_size = SubBlock_size(sb);
if (max_found < sb_size) {
max_found = sb_size;
}
if (sb == st) {
bp->maxSize = max_found;
if (out != NULL) {
*out = max_found - 8;
}
return NULL;
}
}
if (sb_size - size >= 0x50) {
SubBlock_split(sb, size);
}
Block_start(bp) = sb->pNext;
Block_unlink(bp, sb);
if (out != NULL) {
*out = SubBlock_size(sb) - 8;
}
return sb;
}
static void Block_link(Block* ths, SubBlock* sb) {
SubBlock** st;
SubBlock_set_free(sb);
st = &Block_start(ths);
if (*st != NULL) {
sb->pPrev = (*st)->pPrev;
sb->pPrev->pNext = sb;
sb->pNext = *st;
(*st)->pPrev = sb;
*st = sb;
*st = SubBlock_merge_prev(*st, st);
SubBlock_merge_next(*st, st);
} else {
*st = sb;
sb->pPrev = sb;
sb->pNext = sb;
}
if (ths->maxSize < SubBlock_size(*st)) {
ths->maxSize = SubBlock_size(*st);
}
}
static void SubBlock_merge_next(SubBlock* pBlock, SubBlock** pStart) {
SubBlock* next_sub_block;
unsigned int this_cur_size;
next_sub_block = (SubBlock*)((char*)pBlock + (pBlock->size & 0xFFFFFFF8));
if (!(next_sub_block->size & 2)) {
this_cur_size = (pBlock->size & 0xFFFFFFF8) + (next_sub_block->size & 0xFFFFFFF8);
pBlock->size &= ~0xFFFFFFF8;
pBlock->size |= this_cur_size & 0xFFFFFFF8;
if (!(pBlock->size & 2)) {
*(unsigned int*)((char*)pBlock + this_cur_size - sizeof(unsigned int)) = this_cur_size;
}
if (!(pBlock->size & 2)) {
((SubBlock*)((char*)pBlock + this_cur_size))->size &= ~4;
} else {
((SubBlock*)((char*)pBlock + this_cur_size))->size |= 4;
}
if (*pStart == next_sub_block) {
*pStart = (*pStart)->pNext;
}
if (*pStart == next_sub_block) {
*pStart = NULL;
}
next_sub_block->pNext->pPrev = next_sub_block->pPrev;
next_sub_block->pPrev->pNext = next_sub_block->pNext;
}
}
static void* allocate_from_var_pools(__mem_pool_obj* pool, unsigned int size, unsigned int* out) {
Block* bp;
SubBlock* ptr;
if (out != NULL) {
*out = 0;
}
size = (size + 15) & ~7;
if (size < 0x50) {
size = 0x50;
}
bp = pool->pStart != NULL ? pool->pStart : link_new_block(pool, size);
if (bp == NULL) {
return NULL;
}
do {
if (size <= bp->maxSize) {
ptr = Block_subBlock(bp, size, out);
if (ptr != NULL) {
pool->pStart = bp;
break;
}
}
bp = bp->pNext;
if (bp == pool->pStart) {
bp = link_new_block(pool, size);
if (bp == NULL) {
return NULL;
}
ptr = Block_subBlock(bp, size, out);
break;
}
} while (1);
return (char*)ptr + 8;
}
static void* soft_allocate_from_var_pools(__mem_pool_obj* pool, unsigned int size, unsigned int* out) {
register Block* bp;
register SubBlock* ptr;
size = (size + 15) & ~7;
if (size < 0x50) {
size = 0x50;
}
*out = 0;
bp = pool->pStart;
if (bp == NULL) {
return NULL;
}
do {
if (size <= bp->maxSize) {
ptr = Block_subBlock(bp, size, NULL);
if (ptr != NULL) {
pool->pStart = bp;
break;
}
}
if (bp->maxSize > 8 && *out < bp->maxSize - 8) {
*out = bp->maxSize - 8;
}
bp = bp->pNext;
if (bp == pool->pStart) {
return NULL;
}
} while (1);
return (char*)ptr + 8;
}
static void FixBlock_construct(FixBlock* this, FixBlock* prev, FixBlock* next, unsigned int poolIdx, void* start, unsigned int totalSize) {
unsigned int fixSubBlockSize;
unsigned int n;
char* p;
unsigned int i;
char* np;
this->pPrev = prev;
this->pNext = next;
prev->pNext = this;
next->pPrev = this;
this->clientSize = fix_pool_sizes[poolIdx];
fixSubBlockSize = fix_pool_sizes[poolIdx] + 4;
n = totalSize / fixSubBlockSize;
p = (char*)start;
for (i = 0; i < n - 1; ++i) {
np = p + fixSubBlockSize;
((FixSubBlock*)p)->pBlock = this;
((FixSubBlock*)p)->pNext = (FixSubBlock*)np;
p = np;
}
((FixSubBlock*)p)->pBlock = this;
((FixSubBlock*)p)->pNext = NULL;
this->pStart = (FixSubBlock*)start;
this->allocatedSize = 0;
}
static void* allocate_from_fixed_pools(__mem_pool_obj* pool, unsigned int size, unsigned int* out) {
unsigned int i = 0;
FixSubBlock* p;
FixStart* fs;
while (size > fix_pool_sizes[i]) {
++i;
}
fs = &pool->fixStart[i];
if (fs->pHead == NULL || fs->pHead->pStart == NULL) {
unsigned int size_requested = 0x1000;
char* newblock;
unsigned int size_received;
unsigned int n, nsave, size_has;
n = (size_requested - sizeof(FixBlock)) / (fix_pool_sizes[i] + 4);
if (n > 0x100) {
n = 0x100;
}
nsave = n;
while (n >= 10) {
size_requested = n * (fix_pool_sizes[i] + 4) + sizeof(FixBlock);
newblock = (char*)soft_allocate_from_var_pools(pool, size_requested, &size_has);
if (newblock != NULL) {
break;
}
if (size_has > sizeof(FixBlock)) {
n = (size_has - sizeof(FixBlock)) / (fix_pool_sizes[i] + 4);
} else {
n = 0;
}
}
if (newblock == NULL) {
unsigned int cr_backup;
n = nsave;
while (1) {
size_requested = n * (fix_pool_sizes[i] + 4) + sizeof(FixBlock);
newblock = (char*)allocate_from_var_pools(pool, size_requested, &cr_backup);
if (newblock != NULL) {
break;
}
n = cr_backup / (fix_pool_sizes[i] + sizeof(FixBlock) + 4);
if (n < 10) {
if (out != NULL) {
*out = 0;
}
return NULL;
}
}
}
size_received = __msize_inline(newblock);
if (fs->pHead == NULL) {
fs->pHead = (FixBlock*)newblock;
fs->pTail = (FixBlock*)newblock;
}
FixBlock_construct((FixBlock*)newblock, fs->pTail, fs->pHead, i, (FixSubBlock*)((FixBlock*)newblock + 1), size_received - sizeof(FixBlock));
fs->pHead = (FixBlock*)newblock;
}
p = fs->pHead->pStart;
fs->pHead->pStart = p->pNext;
++fs->pHead->allocatedSize;
if (fs->pHead->pStart == NULL) {
fs->pHead = fs->pHead->pNext;
fs->pTail = fs->pTail->pNext;
}
if (out != NULL) {
*out = fix_pool_sizes[i];
}
return (char*)p + 4;
}
void deallocate_from_fixed_pools(__mem_pool_obj* pool_obj, void* ptr, unsigned int size) {
unsigned int i = 0;
FixSubBlock* p;
FixBlock* b;
FixStart* fs;
while (size > fix_pool_sizes[i]) {
++i;
}
fs = &pool_obj->fixStart[i];
p = FixSubBlock_from_pointer(ptr);
b = p->pBlock;
if (b->pStart == NULL && fs->pHead != b) {
if (fs->pTail == b) {
fs->pHead = fs->pHead->pPrev;
fs->pTail = fs->pTail->pPrev;
} else {
b->pPrev->pNext = b->pNext;
b->pNext->pPrev = b->pPrev;
b->pNext = fs->pHead;
b->pPrev = b->pNext->pPrev;
b->pPrev->pNext = b;
b->pNext->pPrev = b;
fs->pHead = b;
}
}
p->pNext = b->pStart;
b->pStart = p;
if (--b->allocatedSize == 0) {
if (fs->pHead == b) {
fs->pHead = b->pNext;
}
if (fs->pTail == b) {
fs->pTail = b->pPrev;
}
b->pPrev->pNext = b->pNext;
b->pNext->pPrev = b->pPrev;
if (fs->pHead == b) {
fs->pHead = NULL;
}
if (fs->pTail == b) {
fs->pTail = NULL;
}
deallocate_from_var_pools(pool_obj, b);
}
}
static unsigned int __pool_allocate_resize(__mem_pool_obj* pool, void* ptr, unsigned int size, unsigned int* out) {
unsigned int sz;
unsigned int this_size;
unsigned int orig_size;
SubBlock* sb;
SubBlock* next_sub;
orig_size = __msize_inline(ptr);
if (size == orig_size) {
if (out != NULL) {
*out = orig_size;
}
return 1;
}
if (classify(ptr)) {
if (size > 0xFFFFFF7F) {
size = 0xFFFFFF7F;
}
sz = size + 8;
sz = (sz + 7) & ~7;
if (sz < 0x50) {
sz = 0x50;
}
sb = SubBlock_from_pointer(ptr);
this_size = orig_size + 8;
next_sub = (SubBlock*)((char*)sb + this_size);
if (SubBlock_is_free(next_sub) && sz <= this_size + SubBlock_size(next_sub)) {
SubBlock_merge_next(sb, &Block_start(SubBlock_block(sb)));
this_size = SubBlock_size(sb);
}
if (this_size >= sz + 0x50) {
Block_link(SubBlock_block(sb), SubBlock_split(sb, sz));
this_size = SubBlock_size(sb);
}
this_size -= 8;
if (out != NULL) {
*out = this_size;
}
if (size > orig_size) {
if (out != NULL && size > this_size && SubBlock_is_free(next_sub)) {
*out += SubBlock_size(next_sub);
}
return size <= this_size;
}
return this_size < orig_size;
}
if (out != NULL) {
*out = orig_size;
}
return 0;
}
void* malloc(register unsigned int size) {
void* rv;
register __mem_pool_obj* pool_obj;
if (size == 0) {
goto null_return;
}
pool_obj = (__mem_pool_obj*)get_malloc_pool();
if (size > ~0x30u) {
return NULL;
}
if (size <= 68) {
rv = allocate_from_fixed_pools(pool_obj, size, NULL);
} else {
rv = allocate_from_var_pools(pool_obj, size, NULL);
}
return rv;
null_return:
return NULL;
}
void free(void* ptr) {
__pool_free(get_malloc_pool(), ptr);
}
void* realloc(void* ptr, unsigned int size) {
register unsigned int rv = size;
register __mem_pool_obj* pool;
unsigned int current_size;
unsigned int orig_size;
pool = (__mem_pool_obj*)get_malloc_pool();
if (ptr == NULL) {
if (rv > ~0x30u) {
return NULL;
}
if (rv <= 68) {
return allocate_from_fixed_pools(pool, rv, NULL);
}
return allocate_from_var_pools(pool, rv, NULL);
}
if (rv == 0) {
if (ptr != NULL) {
current_size = __msize_inline(ptr);
if (current_size <= 68) {
deallocate_from_fixed_pools(pool, ptr, current_size);
} else {
deallocate_from_var_pools(pool, ptr);
}
}
return NULL;
}
orig_size = __msize_inline(ptr);
{
unsigned int result = __pool_allocate_resize(pool, ptr, rv, NULL);
if (result || rv <= orig_size) {
return ptr;
}
}
if (rv > ~0x30u) {
rv = 0;
} else if (rv <= 68) {
rv = (unsigned int)allocate_from_fixed_pools(pool, rv, NULL);
} else {
rv = (unsigned int)allocate_from_var_pools(pool, rv, NULL);
}
if (rv != 0) {
memcpy((void*)rv, ptr, orig_size);
if (ptr != NULL) {
unsigned int cur_sz = __msize_inline(ptr);
if (cur_sz <= 68) {
deallocate_from_fixed_pools(pool, ptr, cur_sz);
} else {
deallocate_from_var_pools(pool, ptr);
}
}
}
return (void*)rv;
}
void* calloc(unsigned int nmemb, unsigned int size) {
register void* ptr;
register unsigned int total;
__mem_pool_obj* pool_obj;
pool_obj = (__mem_pool_obj*)get_malloc_pool();
total = size * nmemb;
if (total > ~0x30u) {
ptr = NULL;
} else if (total <= 68) {
ptr = allocate_from_fixed_pools(pool_obj, total, NULL);
} else {
ptr = allocate_from_var_pools(pool_obj, total, NULL);
}
if (ptr != NULL) {
memset(ptr, 0, total);
}
return ptr;
}

View File

@@ -0,0 +1,123 @@
#include <stdio.h>
#include <stdlib.h>
extern int __read_console(unsigned long, unsigned char*, size_t*, void*);
extern int __write_console(unsigned long, unsigned char*, size_t*, void*);
extern int __close_console(unsigned long);
#pragma exceptions on
unsigned char stdin_buff[0x100];
unsigned char stdout_buff[0x100];
unsigned char stderr_buff[0x100];
FILE __files[4] = {
{
0,
{0, 1, 1, 2, 0, 0},
{0, 0, 0, 0},
0,
0,
0,
{0, 0},
{0, 0},
0,
stdin_buff,
0x100,
stdin_buff,
0,
0,
0,
0,
0,
__read_console,
__write_console,
__close_console,
0,
&__files[1],
},
{
1,
{0, 2, 1, 2, 0, 0},
{0, 0, 0, 0},
0,
0,
0,
{0, 0},
{0, 0},
0,
stdout_buff,
0x100,
stdout_buff,
0,
0,
0,
0,
0,
__read_console,
__write_console,
__close_console,
0,
&__files[2],
},
{
2,
{0, 2, 0, 2, 0, 0},
{0, 0, 0, 0},
0,
0,
0,
{0, 0},
{0, 0},
0,
stderr_buff,
0x100,
stderr_buff,
0,
0,
0,
0,
0,
__read_console,
__write_console,
__close_console,
0,
&__files[3],
},
{0},
};
void __close_all(void) {
FILE* file;
FILE* current;
for (file = __files; file != 0;) {
if (file->mode.file_kind != 0) {
fclose(file);
}
current = file;
file = file->next_file;
if (current->is_dyn_alloc != 0) {
free(current);
} else {
current->mode.file_kind = 3;
if (file != 0 && file->is_dyn_alloc != 0) {
current->next_file = 0;
}
}
}
}
int __flush_all(void) {
int result = 0;
FILE* file;
for (file = __files; file != 0; file = file->next_file) {
if (file->mode.file_kind != 0 && fflush(file) != 0) {
result = -1;
}
}
return result;
}

View File

@@ -0,0 +1,142 @@
#include <limits.h>
#include <math.h>
typedef struct ldiv_t {
long quot;
long rem;
} ldiv_t;
#undef abs
int abs(int n) {
int mask = n >> 31;
return (mask ^ n) - mask;
}
long labs(long n) {
long mask = n >> 31;
return (mask ^ n) - mask;
}
div_t div(int numerator, int denominator) {
int n_sign, d_sign;
div_t value;
n_sign = 1;
d_sign = 1;
if (numerator < 0) {
numerator = -numerator;
n_sign = -1;
}
if (denominator < 0) {
denominator = -denominator;
d_sign = -1;
}
value.quot = (numerator / denominator) * (n_sign * d_sign);
value.rem = (numerator * n_sign) - (value.quot * denominator * d_sign);
return value;
}
int __msl_add(int* a, int b) {
int val = *a;
if (b < 0) {
if (val < 0 && b < (-LONG_MAX - 1) - val) {
return 0;
}
} else if (val > 0 && b > LONG_MAX - val) {
return 0;
}
*a = val + b;
return 1;
}
int __msl_ladd(long* a, long b) {
long val = *a;
if (b < 0) {
if (val < 0 && b < (-LONG_MAX - 1L) - val) {
return 0;
}
} else if (val > 0 && b > LONG_MAX - val) {
return 0;
}
*a = val + b;
return 1;
}
int __msl_lmul(long* a, long b) {
long val = *a;
int sign = (val < 0) ^ (b < 0) ? -1 : 1;
if (val < 0) {
val = -val;
}
if (b < 0) {
b = -b;
}
if (val > LONG_MAX / b) {
return 0;
}
*a = val * b * sign;
return 1;
}
ldiv_t __msl_div(long a, long b) {
ldiv_t ret;
long quotient, a_sign, b_sign, sign, remainder;
a_sign = 1;
b_sign = 1;
if (a < 0) {
a = -a;
a_sign = -1;
}
if (b < 0) {
b = -b;
b_sign = -1;
}
sign = a_sign * b_sign;
quotient = (a / b) * sign;
remainder = a * a_sign - b_sign * (quotient * b);
if (remainder != 0 && sign < 0) {
quotient--;
remainder += b * b_sign;
}
ret.quot = quotient;
ret.rem = remainder;
return ret;
}
int __msl_mod(int a, int b) {
int quotient, remainder, a_sign, b_sign, sign;
a_sign = 1;
b_sign = 1;
if (a < 0) {
a = -a;
a_sign = -1;
}
if (b < 0) {
b = -b;
b_sign = -1;
}
sign = a_sign * b_sign;
quotient = (a / b) * sign;
remainder = (a * a_sign) - (quotient * b * b_sign);
if (remainder && sign < 0) {
quotient -= 1;
remainder += b * b_sign;
}
return remainder;
}

View File

@@ -0,0 +1,43 @@
#include <search.h>
void* bsearch(const void* key, const void* ptr, size_t count, size_t size, COMPARE_FUNC comp) {
const char* p;
int cmp;
size_t low, high, mid;
if (key == NULL || ptr == NULL || count == 0 || size == 0 || comp == NULL) {
return NULL;
}
p = (const char*)ptr;
cmp = comp(key, p);
if (cmp == 0) {
return (void*)p;
}
if (cmp < 0) {
return NULL;
}
low = 1;
high = count - 1;
while (low <= high) {
mid = (low + high) >> 1;
p = (const char*)ptr + size * mid;
cmp = comp(key, p);
if (cmp == 0) {
return (void*)p;
}
if (cmp < 0) {
high = mid - 1;
} else {
low = mid + 1;
}
}
return NULL;
}

View File

@@ -1,4 +1,5 @@
#include <stdio.h>
#include <stdlib.h>
void __prep_buffer(FILE* pFile) {
pFile->buffer_ptr = pFile->buffer;
@@ -33,3 +34,50 @@ int __flush_buffer(FILE* pFile, size_t* pFlushed) {
return 0;
}
int setvbuf(FILE* pFile, char* buffer, int mode, size_t size) {
int file_kind = pFile->mode.file_kind;
if (mode == _IONBF) {
fflush(pFile);
}
if (pFile->state.io_state != 0 || file_kind == 0) {
return -1;
}
if (mode != _IONBF && mode != _IOLBF && mode != _IOFBF) {
return -1;
}
if (pFile->buffer != 0 && pFile->state.free_buffer != 0) {
free(pFile->buffer);
}
pFile->mode.buffer_mode = mode;
pFile->state.free_buffer = 0;
pFile->buffer = &pFile->char_buf;
pFile->buffer_ptr = pFile->buffer;
pFile->buffer_size = 1;
pFile->buffer_len = 0;
pFile->buffer_alignment = 0;
if (mode == _IONBF || size < 1) {
*pFile->buffer_ptr = 0;
return 0;
}
if (buffer == 0) {
buffer = malloc(size);
if (buffer == 0) {
return -1;
}
pFile->state.free_buffer = 1;
}
pFile->buffer = (unsigned char*)buffer;
pFile->buffer_ptr = (unsigned char*)buffer;
pFile->buffer_size = size;
pFile->buffer_alignment = 0;
return 0;
}

View File

@@ -0,0 +1,146 @@
#include <internal/file_struct.h>
#include <stddef.h>
#include <string.h>
#include <wchar.h>
enum file_kinds {
file_closed,
file_disk,
file_console,
file_unavailable
};
enum io_states {
neutral,
writing,
reading,
rereading
};
enum io_modes {
io_read = 1,
io_write = 2,
io_append = 4
};
enum buffer_modes {
buffer_none,
buffer_full,
buffer_line
};
void __prep_buffer(FILE* file);
int __flush_buffer(FILE* file, size_t* pos);
void __stdio_atexit(void);
int _fseek(FILE* file, long offset, int whence);
void* __memrchr(const void* ptr, int ch, size_t count);
size_t __fwrite(const void* ptr, size_t memb_size, size_t num_memb, FILE* file) {
unsigned char* cur_ptr;
size_t num_bytes, rem_bytes, bytes_written;
int res, buff;
if (fwide(file, 0) == 0) {
fwide(file, -1);
}
rem_bytes = memb_size * num_memb;
if (rem_bytes == 0 || file->state.error || file->mode.file_kind == file_closed) {
return 0;
}
if (file->mode.file_kind == file_console) {
__stdio_atexit();
}
buff = !file->mode.binary_io || file->mode.buffer_mode == buffer_line || file->mode.buffer_mode == buffer_full;
if (file->state.io_state == neutral && file->mode.io_mode & io_write) {
if (file->mode.io_mode & io_append) {
if (_fseek(file, 0, 2)) {
return 0;
}
}
file->state.io_state = writing;
__prep_buffer(file);
}
if (file->state.io_state != writing) {
file->state.error = 1;
file->buffer_len = 0;
return 0;
}
cur_ptr = (unsigned char*)ptr;
bytes_written = 0;
if (rem_bytes && (file->buffer_ptr != file->buffer || buff)) {
file->buffer_len = file->buffer_size - (file->buffer_ptr - file->buffer);
do {
unsigned char* nw = NULL;
num_bytes = file->buffer_len;
if (num_bytes > rem_bytes) {
num_bytes = rem_bytes;
}
if (file->mode.buffer_mode == buffer_full && num_bytes) {
if ((nw = (unsigned char*)__memrchr(cur_ptr, '\n', num_bytes)) != NULL) {
num_bytes = nw + 1 - cur_ptr;
}
}
if (num_bytes != 0) {
memcpy(file->buffer_ptr, cur_ptr, num_bytes);
cur_ptr += num_bytes;
rem_bytes -= num_bytes;
file->buffer_ptr += num_bytes;
file->buffer_len -= num_bytes;
}
if (file->buffer_len == 0 || nw != 0 || file->mode.buffer_mode == buffer_none) {
res = __flush_buffer(file, 0);
if (res != 0) {
file->state.error = 1;
file->buffer_len = 0;
rem_bytes = 0;
break;
}
}
bytes_written += num_bytes;
} while (rem_bytes && buff);
}
if (rem_bytes && buff == 0) {
unsigned char* save_buf = file->buffer;
size_t save_size = file->buffer_size;
file->buffer = cur_ptr;
file->buffer_size = rem_bytes;
file->buffer_ptr = cur_ptr + rem_bytes;
if (__flush_buffer(file, &num_bytes) != 0) {
file->state.error = 1;
file->buffer_len = 0;
} else {
bytes_written += num_bytes;
}
file->buffer = save_buf;
file->buffer_size = save_size;
__prep_buffer(file);
file->buffer_len = 0;
}
if (file->mode.buffer_mode != buffer_line) {
file->buffer_len = 0;
}
return bytes_written / memb_size;
}

View File

@@ -0,0 +1,73 @@
#include <ctype.h>
#include <internal/locale.h>
#include <stdbool.h>
#include <string.h>
extern int __msl_strnicmp(const char*, const char*, int);
extern char* __msl_itoa(int, char*, int);
int stricmp(const char* s1, const char* s2) {
char c1, c2;
while (true) {
c1 = tolower(*s1++);
c2 = tolower(*s2++);
if (c1 < c2) {
return -1;
}
if (c1 > c2) {
return 1;
}
if (c1 == 0) {
return 0;
}
}
}
int strnicmp(const char* s1, const char* s2, size_t n) {
return __msl_strnicmp(s1, s2, n);
}
int strcmpi(const char* s1, const char* s2) {
return stricmp(s1, s2);
}
char* itoa(int value, char* buffer, int radix) {
return __msl_itoa(value, buffer, radix);
}
int wcsnicmp(const char* s1, const char* s2, size_t n) {
const wchar_t* p1 = (const wchar_t*)s1;
const wchar_t* p2 = (const wchar_t*)s2;
unsigned int c1;
unsigned int c2;
struct _loc_ctype_cmpt* ctype_cmpt = _current_locale.ctype_cmpt_ptr;
size_t i;
for (i = 0; i < n; i++) {
c1 = *p1++;
c1 = (c1 >= 256) ? c1 : ctype_cmpt->wlower_map_ptr[(unsigned short)c1];
c1 &= 0xFFFF;
c2 = *p2++;
c2 = (c2 >= 256) ? c2 : ctype_cmpt->wlower_map_ptr[(unsigned short)c2];
c2 &= 0xFFFF;
if (c1 < c2) {
return -1;
}
if (c1 > c2) {
return 1;
}
if (c1 == 0) {
return 0;
}
}
return 0;
}

View File

@@ -0,0 +1,10 @@
#include <math.h>
double scalbn(double x, int n) {
double man;
int exponent;
man = frexp(x, &exponent);
exponent += n;
return ldexp(man, exponent);
}

View File

@@ -0,0 +1,97 @@
#include <internal/locale.h>
#include <string.h>
int mbtowc(wchar_t* pwc, const char* s, size_t n) {
return _current_locale.ctype_cmpt_ptr->decode_mb(pwc, s, n);
}
int __mbtowc_noconv(wchar_t* pwc, const char* s, size_t n) {
if (s == NULL) {
return 0;
}
if (n == 0) {
return -1;
}
if (pwc != NULL) {
*pwc = (unsigned char)*s;
}
if (!*s) {
return 0;
}
return 1;
}
int __wctomb_noconv(char* s, wchar_t wchar) {
if (s == NULL) {
return 0;
}
*s = (char)wchar;
return 1;
}
size_t mbstowcs(wchar_t* dest, const char* src, size_t len) {
int count;
char* src_ptr;
size_t slen;
slen = strlen(src);
if (dest != NULL) {
src_ptr = (char*)src;
for (count = 0; count < len; count++) {
if (*src_ptr) {
int res = mbtowc(dest++, src_ptr, slen);
if (res > 0) {
src_ptr += res;
slen -= res;
} else {
return -1;
}
} else {
*dest = 0;
break;
}
}
} else {
count = 0;
}
return count;
}
size_t wcstombs(char* s, const wchar_t* pwcs, size_t n) {
int result;
int chars_written = 0;
char temp[3];
wchar_t* source;
if (s == NULL || pwcs == NULL) {
return 0;
}
source = (wchar_t*)pwcs;
while (chars_written <= n) {
if (!*source) {
*(s + chars_written) = '\0';
break;
}
result = _current_locale.ctype_cmpt_ptr->encode_wc(temp, *source++);
if (chars_written + result > n) {
break;
}
strncpy(s + chars_written, temp, result);
chars_written += result;
}
return chars_written;
}

View File

@@ -0,0 +1,6 @@
extern void (*__stdio_exit)(void);
void __close_all(void);
void __stdio_atexit(void) {
__stdio_exit = __close_all;
}

View File

@@ -0,0 +1,73 @@
#include <search.h>
#define swap(dst, src, cnt) \
do { \
char* p; \
char* q; \
size_t n = cnt; \
unsigned long tmp; \
for (p = (char*)src - 1, q = (char*)dst - 1, n++; --n;) { \
tmp = *++q; \
*q = *++p; \
*p = tmp; \
} \
} while (0)
void qsort(void* table_base, size_t num_members, size_t member_size, COMPARE_FUNC compare_members) {
size_t cur_ofs;
size_t neg_size;
size_t l, r, j;
char* lp;
char* rp;
char* ip;
char* jp;
char* kp;
if (num_members < 2) {
return;
}
r = num_members;
l = (r / 2) + 1;
lp = (char*)table_base + member_size * (l - 1);
rp = (char*)table_base + member_size * (r - 1);
neg_size = (long)(member_size - member_size * 2);
cur_ofs = l * member_size;
for (;;) {
if (l > 1) {
l--;
cur_ofs -= member_size;
lp -= member_size;
} else {
swap(lp, rp, member_size);
if (--r == 1) {
return;
}
rp -= member_size;
}
j = l;
jp = (char*)table_base + (cur_ofs + neg_size);
while (j * 2 <= r) {
j *= 2;
ip = jp;
jp = (char*)table_base + member_size * (j - 1);
if (j < r) {
kp = jp + member_size;
if (compare_members(jp, kp) < 0) {
j++;
jp = kp;
}
}
if (compare_members(ip, jp) < 0) {
swap(ip, jp, member_size);
} else {
break;
}
}
}
}

View File

@@ -0,0 +1,30 @@
#include <signal.h>
int exit(int);
__signal_func_ptr signal_funcs[8];
int raise(int sig) {
__signal_func_ptr signal_func;
if (sig < SIGNAL_ABORT || sig > SIGNAL_UNK7) {
return -1;
}
signal_func = signal_funcs[sig - 1];
if (signal_func != SIGNAL_ACTION_IGNORE) {
signal_funcs[sig - 1] = SIGNAL_ACTION_DEFAULT;
}
if (signal_func == SIGNAL_ACTION_IGNORE || (signal_func == SIGNAL_ACTION_DEFAULT && sig == SIGNAL_ABORT)) {
return 0;
}
if (signal_func == SIGNAL_ACTION_DEFAULT) {
exit(0);
}
(*signal_func)(sig);
return 0;
}

View File

@@ -7,6 +7,10 @@
#define K1 0x80808080
#define K2 0xfefefeff
static const double zero = 0.0;
static char* initial = (char*)&zero;
static char* current = (char*)&zero;
char* strcpy(char* dst, const char* src) {
register unsigned char* destb;
register unsigned char* fromb;
@@ -107,6 +111,27 @@ char* strcat(char* dst, const char* src) {
return dst;
}
char* strncat(char* dst, const char* src, size_t n) {
const unsigned char* p = (unsigned char*)src - 1;
unsigned char* q = (unsigned char*)dst - 1;
while (*++q)
;
q--;
n++;
while (--n) {
if (!(*++q = *++p)) {
q--;
break;
}
}
*++q = 0;
return dst;
}
int strcmp(const char* s1, const char* s2) {
register unsigned char* left = (unsigned char*)s1;
register unsigned char* right = (unsigned char*)s2;
@@ -233,6 +258,109 @@ char* strrchr(const char* str, int ch) {
return (c ? 0 : (char*)p);
}
char* strpbrk(const char* s1, const char* s2) {
unsigned char table[32] = {0};
unsigned char* p;
unsigned long c;
p = (unsigned char*)s2 - 1;
while (c = *++p) {
table[(c >> 3) & 0x1f] |= (unsigned char)(1 << (c & 7));
}
p = (unsigned char*)s1 - 1;
while (c = *++p) {
if (table[(c >> 3) & 0x1f] & (unsigned char)(1 << (c & 7))) {
return (char*)p;
}
}
return 0;
}
size_t strspn(const char* s1, const char* s2) {
unsigned char table[32] = {0};
unsigned char* p;
unsigned long c;
p = (unsigned char*)s2 - 1;
while (c = *++p) {
table[(c >> 3) & 0x1f] |= (unsigned char)(1 << (c & 7));
}
p = (unsigned char*)s1 - 1;
while (c = *++p) {
if (!(table[(c >> 3) & 0x1f] & (unsigned char)(1 << (c & 7)))) {
break;
}
}
return p - (unsigned char*)s1;
}
size_t strcspn(const char* s1, const char* s2) {
unsigned char table[32] = {0};
unsigned char* p;
unsigned long c;
p = (unsigned char*)s2 - 1;
while (c = *++p) {
table[(c >> 3) & 0x1f] |= (unsigned char)(1 << (c & 7));
}
p = (unsigned char*)s1 - 1;
while (c = *++p) {
if (table[(c >> 3) & 0x1f] & (unsigned char)(1 << (c & 7))) {
break;
}
}
return p - (unsigned char*)s1;
}
char* strtok(char* str, const char* delimiters) {
unsigned char table[32] = {0};
unsigned char* p;
unsigned long c;
if (str) {
current = str;
}
p = (unsigned char*)delimiters - 1;
while (c = *++p) {
table[(c >> 3) & 0x1f] |= (unsigned char)(1 << (c & 7));
}
p = (unsigned char*)current - 1;
while (c = *++p) {
if (!(table[(c >> 3) & 0x1f] & (unsigned char)(1 << (c & 7)))) {
break;
}
}
if (!c) {
current = initial;
return 0;
}
str = (char*)p;
while (c = *++p) {
if (table[(c >> 3) & 0x1f] & (unsigned char)(1 << (c & 7))) {
break;
}
}
if (!c) {
current = initial;
} else {
current = (char*)(p + 1);
*p = 0;
}
return str;
}
char* strstr(const char* str, const char* pat) {
unsigned char* s1 = (unsigned char*)str - 1;
unsigned char* p1 = (unsigned char*)pat - 1;

View File

@@ -0,0 +1,44 @@
#include "internal/file_struct.h"
enum file_kinds {
file_closed
};
enum file_orientation {
file_unoriented,
file_char_oriented,
file_wide_oriented
};
int fwide(FILE* file, int file_mode) {
int orientation;
int res;
if (file == NULL || file->mode.file_kind == file_closed) {
return 0;
}
orientation = file->mode.file_orientation;
switch (orientation) {
case file_unoriented:
if (file_mode > 0) {
file->mode.file_orientation = file_wide_oriented;
} else if (file_mode < 0) {
file->mode.file_orientation = file_char_oriented;
}
res = file_mode;
break;
case file_wide_oriented:
res = 1;
break;
case file_char_oriented:
res = -1;
break;
}
return res;
}

View File

@@ -0,0 +1,104 @@
const unsigned int __wctype_mapC[128] = {
0x00040004, 0x00040004, 0x00040004, 0x00040004,
0x00040106, 0x01040104, 0x01040104, 0x00040004,
0x00040004, 0x00040004, 0x00040004, 0x00040004,
0x00040004, 0x00040004, 0x00040004, 0x00040004,
0x014200D0, 0x00D000D0, 0x00D000D0, 0x00D000D0,
0x00D000D0, 0x00D000D0, 0x00D000D0, 0x00D000D0,
0x04580458, 0x04580458, 0x04580458, 0x04580458,
0x04580458, 0x00D000D0, 0x00D000D0, 0x00D000D0,
0x00D00651, 0x06510651, 0x06510651, 0x06510251,
0x02510251, 0x02510251, 0x02510251, 0x02510251,
0x02510251, 0x02510251, 0x02510251, 0x02510251,
0x02510251, 0x025100D0, 0x00D000D0, 0x00D000D0,
0x00D00471, 0x04710471, 0x04710471, 0x04710071,
0x00710071, 0x00710071, 0x00710071, 0x00710071,
0x00710071, 0x00710071, 0x00710071, 0x00710071,
0x00710071, 0x007100D0, 0x00D000D0, 0x00D00004,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
0x00000000, 0x00000000, 0x00000000, 0x00000000,
};
const unsigned int __wlower_mapC[128] = {
0x00000001, 0x00020003, 0x00040005, 0x00060007,
0x00080009, 0x000A000B, 0x000C000D, 0x000E000F,
0x00100011, 0x00120013, 0x00140015, 0x00160017,
0x00180019, 0x001A001B, 0x001C001D, 0x001E001F,
0x00200021, 0x00220023, 0x00240025, 0x00260027,
0x00280029, 0x002A002B, 0x002C002D, 0x002E002F,
0x00300031, 0x00320033, 0x00340035, 0x00360037,
0x00380039, 0x003A003B, 0x003C003D, 0x003E003F,
0x00400061, 0x00620063, 0x00640065, 0x00660067,
0x00680069, 0x006A006B, 0x006C006D, 0x006E006F,
0x00700071, 0x00720073, 0x00740075, 0x00760077,
0x00780079, 0x007A005B, 0x005C005D, 0x005E005F,
0x00600061, 0x00620063, 0x00640065, 0x00660067,
0x00680069, 0x006A006B, 0x006C006D, 0x006E006F,
0x00700071, 0x00720073, 0x00740075, 0x00760077,
0x00780079, 0x007A007B, 0x007C007D, 0x007E007F,
0x00800081, 0x00820083, 0x00840085, 0x00860087,
0x00880089, 0x008A008B, 0x008C008D, 0x008E008F,
0x00900091, 0x00920093, 0x00940095, 0x00960097,
0x00980099, 0x009A009B, 0x009C009D, 0x009E009F,
0x00A000A1, 0x00A200A3, 0x00A400A5, 0x00A600A7,
0x00A800A9, 0x00AA00AB, 0x00AC00AD, 0x00AE00AF,
0x00B000B1, 0x00B200B3, 0x00B400B5, 0x00B600B7,
0x00B800B9, 0x00BA00BB, 0x00BC00BD, 0x00BE00BF,
0x00C000C1, 0x00C200C3, 0x00C400C5, 0x00C600C7,
0x00C800C9, 0x00CA00CB, 0x00CC00CD, 0x00CE00CF,
0x00D000D1, 0x00D200D3, 0x00D400D5, 0x00D600D7,
0x00D800D9, 0x00DA00DB, 0x00DC00DD, 0x00DE00DF,
0x00E000E1, 0x00E200E3, 0x00E400E5, 0x00E600E7,
0x00E800E9, 0x00EA00EB, 0x00EC00ED, 0x00EE00EF,
0x00F000F1, 0x00F200F3, 0x00F400F5, 0x00F600F7,
0x00F800F9, 0x00FA00FB, 0x00FC00FD, 0x00FE00FF,
};
const unsigned int __wupper_mapC[128] = {
0x00000001, 0x00020003, 0x00040005, 0x00060007,
0x00080009, 0x000A000B, 0x000C000D, 0x000E000F,
0x00100011, 0x00120013, 0x00140015, 0x00160017,
0x00180019, 0x001A001B, 0x001C001D, 0x001E001F,
0x00200021, 0x00220023, 0x00240025, 0x00260027,
0x00280029, 0x002A002B, 0x002C002D, 0x002E002F,
0x00300031, 0x00320033, 0x00340035, 0x00360037,
0x00380039, 0x003A003B, 0x003C003D, 0x003E003F,
0x00400041, 0x00420043, 0x00440045, 0x00460047,
0x00480049, 0x004A004B, 0x004C004D, 0x004E004F,
0x00500051, 0x00520053, 0x00540055, 0x00560057,
0x00580059, 0x005A005B, 0x005C005D, 0x005E005F,
0x00600041, 0x00420043, 0x00440045, 0x00460047,
0x00480049, 0x004A004B, 0x004C004D, 0x004E004F,
0x00500051, 0x00520053, 0x00540055, 0x00560057,
0x00580059, 0x005A007B, 0x007C007D, 0x007E007F,
0x00800081, 0x00820083, 0x00840085, 0x00860087,
0x00880089, 0x008A008B, 0x008C008D, 0x008E008F,
0x00900091, 0x00920093, 0x00940095, 0x00960097,
0x00980099, 0x009A009B, 0x009C009D, 0x009E009F,
0x00A000A1, 0x00A200A3, 0x00A400A5, 0x00A600A7,
0x00A800A9, 0x00AA00AB, 0x00AC00AD, 0x00AE00AF,
0x00B000B1, 0x00B200B3, 0x00B400B5, 0x00B600B7,
0x00B800B9, 0x00BA00BB, 0x00BC00BD, 0x00BE00BF,
0x00C000C1, 0x00C200C3, 0x00C400C5, 0x00C600C7,
0x00C800C9, 0x00CA00CB, 0x00CC00CD, 0x00CE00CF,
0x00D000D1, 0x00D200D3, 0x00D400D5, 0x00D600D7,
0x00D800D9, 0x00DA00DB, 0x00DC00DD, 0x00DE00DF,
0x00E000E1, 0x00E200E3, 0x00E400E5, 0x00E600E7,
0x00E800E9, 0x00EA00EB, 0x00EC00ED, 0x00EE00EF,
0x00F000F1, 0x00F200F3, 0x00F400F5, 0x00F600F7,
0x00F800F9, 0x00FA00FB, 0x00FC00FD, 0x00FE00FF,
};

View File

@@ -0,0 +1,160 @@
#include <wchar.h>
size_t wcslen(const wchar_t* str) {
const wchar_t* p = str - 1;
size_t len = -1;
do {
len++;
} while (*++p != 0);
return len;
}
wchar_t* wcscpy(wchar_t* dest, const wchar_t* src) {
const wchar_t* s = src - 1;
wchar_t* d = dest - 1;
wchar_t c;
do {
c = *++s;
*++d = c;
} while (c != 0);
return dest;
}
wchar_t* wcsncpy(wchar_t* dest, const wchar_t* src, size_t num) {
const wchar_t* s = src - 1;
wchar_t* d = dest - 1;
wchar_t c;
size_t n = num + 1;
while (--n != 0) {
c = *++s;
*++d = c;
if (c == 0) {
while (--n != 0) {
*++d = 0;
}
break;
}
}
return dest;
}
wchar_t* wcscat(wchar_t* dest, const wchar_t* src) {
const wchar_t* s = src - 1;
wchar_t* d = dest - 1;
while (*++d != 0)
;
d--;
do {
*++d = *++s;
} while (*s != 0);
return dest;
}
wchar_t* wcsncat(wchar_t* dest, const wchar_t* src, size_t num) {
const wchar_t* s = src - 1;
wchar_t* d = dest - 1;
wchar_t c;
size_t n;
while (*++d != 0)
;
d--;
n = num + 1;
while (--n != 0) {
c = *++s;
*++d = c;
if (c == 0) {
d--;
break;
}
}
*++d = 0;
return dest;
}
int wcsncmp(const wchar_t* s1, const wchar_t* s2, size_t num) {
wchar_t c2;
wchar_t c1;
const wchar_t* p1;
const wchar_t* p2;
size_t n;
p1 = s1 - 1;
p2 = s2 - 1;
n = num + 1;
while (--n != 0) {
c1 = *++p1;
c2 = *++p2;
if (c1 != c2) {
return (int)(c1 - c2);
}
if (c1 == 0) {
break;
}
}
return 0;
}
wchar_t* wcschr(wchar_t* ws, wchar_t wc) {
wchar_t* p = ws - 1;
wchar_t ch;
while ((ch = *++p) != 0) {
if (ch == wc) {
return p;
}
}
if (wc == 0) {
return p;
}
return 0;
}
wchar_t* wcsstr(const wchar_t* s1, const wchar_t* s2) {
const wchar_t* p1;
wchar_t c;
wchar_t c1;
wchar_t c2;
c = *s2;
p1 = s1 - 1;
if (c == 0) {
return (wchar_t*)s1;
}
while ((c1 = *++p1) != 0) {
if (c1 == c) {
wchar_t ic1;
const wchar_t* ps1;
const wchar_t* p2;
ps1 = p1 - 1;
p2 = s2 - 1;
do {
ic1 = *++ps1;
c2 = *++p2;
if (ic1 != c2) {
break;
}
} while (ic1 != 0);
if (c2 == 0) {
return (wchar_t*)p1;
}
}
}
return 0;
}

View File

@@ -11,7 +11,7 @@ namespace nw4r {
namespace snd {
class SoundHandle : private ut::NonCopyable {
public:
SoundHandle() : mSound(NULL) {}
SoundHandle() NO_INLINE : mSound(NULL) {}
~SoundHandle() { DetachSound(); }
void detail_AttachSound(detail::BasicSound* sound);

View File

@@ -59,7 +59,7 @@ namespace nw4r {
b = blue;
a = alpha;
}
} Color;
} ATTRIBUTE_ALIGN(4) Color;
} // namespace ut
} // namespace nw4r

View File

@@ -1,3 +1,22 @@
#include <nw4r/db/assert.h>
extern "C" const u8 lbl_81695550 = 255;
extern "C" const u8 lbl_81695551 = 255;
extern "C" const u8 lbl_81695552 = 255;
extern "C" const u8 lbl_81695553 = 0;
extern "C" char lbl_816719DC[] = "Error#004\nAn error has occurred.\nThe system files are corrupted.";
#undef NW4R_ASSERT
#define NW4R_ASSERT(x) \
{ \
if (!(x)) { \
GXColor front = {*((volatile const u8*)&::lbl_81695550), *((volatile const u8*)&::lbl_81695551), \
*((volatile const u8*)&::lbl_81695552), *((volatile const u8*)&::lbl_81695553)}; \
GXColor back = {0, 0, 0, 0}; \
OSFatal((GXColor)front, (GXColor)back, ::lbl_816719DC); \
} \
}
#include <nw4r/lyt/window.h>
#include <nw4r/lyt/common.h>

View File

@@ -34,20 +34,29 @@ namespace nw4r {
const u32* flags0A;
const u32* flags0C;
int i, j;
int i;
int entryI;
const HeaderedGlyphGroups* offsetPGlgr;
const u8* offsetFlags;
u32 loadedSheetCount, loadedSmth0ASize, loadedSmth0CSize;
u32 flagWord;
const u8* offsetFlags;
const char* groupName;
const u32* offsetData;
int j;
u32 sheetOffsetsSize;
u32 loadedSheetsSize;
u32 neededCharacterSize;
u32 baseSize;
u32 count0CWork;
u32& neededCharacterSizeRef = neededCharacterSize;
u32 loadedSizeRef;
u32 groupOffset;
if (!ArchiveFontBase::IsValidResource(fontData, 0x4000)) {
return 0;
}
@@ -55,29 +64,30 @@ namespace nw4r {
font = (ArchiveFontBinaryLayout*)fontData;
pGlgr = &font->glgr;
countName = font->glgr.inner.nameCount;
countSheet = font->glgr.inner.sheetCount;
count0A = font->glgr.inner.smthCount_0x0a;
count0C = font->glgr.inner.smthCount_0x0c;
countName = pGlgr->inner.nameCount;
countSheet = pGlgr->inner.sheetCount;
count0A = pGlgr->inner.smthCount_0x0a;
count0C = pGlgr->inner.smthCount_0x0c;
count0CWork = count0C;
stepSheets = ((s32)countSheet + 0x1f) / 32 * 4;
step0A = ((s32)count0A + 0x1f) / 32 * 4;
step0C = ((s32)count0C + 0x1f) / 32 * 4;
step0C = ((s32)count0CWork + 0x1f) / 32 * 4;
dataSheetsOff = ROUNDUP(offsetof(ArchiveFontBinaryLayout, glgr.inner.nameOffsets) + countName * sizeof(u16), 4);
data0AOff = ROUNDUP(dataSheetsOff + countSheet * sizeof(u32), 4);
data0COff = ROUNDUP(data0AOff + count0A * sizeof(u32), 4);
dataSheets = lyt::detail::ConvertOffsToPtr<u32>(fontData, dataSheetsOff);
data0A = lyt::detail::ConvertOffsToPtr<u32>(fontData, data0AOff);
data0C = lyt::detail::ConvertOffsToPtr<u32>(fontData, data0COff);
dataSheets = (const u32*)((u32)dataSheetsOff + (u32)fontData);
data0A = (const u32*)((u32)data0AOff + (u32)fontData);
data0C = (const u32*)((u32)data0COff + (u32)fontData);
flagsSheetsOff = ROUNDUP(data0COff + count0C * sizeof(u32), 4);
flagsSheetsOff = ROUNDUP(data0COff + count0CWork * sizeof(u32), 4);
flags0AOff = ROUNDUP(flagsSheetsOff + stepSheets * countName, 4);
flags0COff = ROUNDUP(flags0AOff + step0A * countName, 4);
flagsSheets = lyt::detail::ConvertOffsToPtr<u32>(fontData, flagsSheetsOff);
flags0A = lyt::detail::ConvertOffsToPtr<u32>(fontData, flags0AOff);
flags0C = lyt::detail::ConvertOffsToPtr<u32>(fontData, flags0COff);
flagsSheets = (const u32*)((u32)flagsSheetsOff + (u32)fontData);
flags0A = (const u32*)((u32)flags0AOff + (u32)fontData);
flags0C = (const u32*)((u32)flags0COff + (u32)fontData);
loadedSheetCount = 0;
loadedSmth0ASize = 0;
@@ -90,7 +100,7 @@ namespace nw4r {
flagWord = 0;
for (j = 0, offsetPGlgr = pGlgr; j < pGlgr->inner.nameCount;
offsetPGlgr = (const HeaderedGlyphGroups*)((const u8*)offsetPGlgr + 2), j++) {
groupName = (const char*)fontData + offsetPGlgr->inner.nameOffsets[0];
groupName = (const char*)((u32)offsetPGlgr->inner.nameOffsets[0] + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * stepSheets, 4));
}
@@ -101,12 +111,13 @@ namespace nw4r {
// getLoadedSheetCount(pGlgr, flagsSheets, stepSheets, fontData, includedGroups, &loadedSheetCount);
// Get the SIZE of unk_0x0a that should be loaded
for (i = 0, entryI = 0; entryI < pGlgr->inner.smthCount_0x0a; entryI += 32, i++) {
for (i = 0; i * 32 < pGlgr->inner.smthCount_0x0a; i++) {
offsetFlags = (const u8*)flags0A + i * sizeof(u32);
flagWord = 0;
for (j = 0; j < pGlgr->inner.nameCount; j++) {
groupName = (const char*)fontData + pGlgr->inner.nameOffsets[j];
groupOffset = pGlgr->inner.nameOffsets[j];
groupName = (const char*)(groupOffset + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * step0A, 4));
}
@@ -121,12 +132,13 @@ namespace nw4r {
}
// Get the SIZE of unk_0x0C that should be loaded
for (i = 0, entryI = 0; entryI < pGlgr->inner.smthCount_0x0c; entryI += 32, i++) {
for (i = 0; i * 32 < pGlgr->inner.smthCount_0x0c; i++) {
offsetFlags = (const u8*)flags0C + i * sizeof(u32);
flagWord = 0;
for (j = 0; j < pGlgr->inner.nameCount; j++) {
groupName = (const char*)fontData + pGlgr->inner.nameOffsets[j];
groupOffset = pGlgr->inner.nameOffsets[j];
groupName = (const char*)(groupOffset + (u32)fontData);
if (*includedGroups == '\0' || detail::ArchiveFontBase::IncludeName(includedGroups, groupName)) {
flagWord |= *(const u32*)((const u8*)offsetFlags + ROUNDDOWN(j * step0C, 4));
}
@@ -145,13 +157,14 @@ namespace nw4r {
sheetOffsetsSize = ROUNDUP(pGlgr->inner.sheetCount * 2, 4);
loadedSheetsSize = ROUNDUP(loadedSheetCount * pGlgr->inner.uncompSheetSize, 4);
neededCharacterSize = sizeof(CXUncompContextHuffman);
if (loadedSmth0ASize + loadedSmth0CSize >= sizeof(CXUncompContextHuffman)) {
neededCharacterSize = loadedSmth0ASize + loadedSmth0CSize;
loadedSizeRef = loadedSmth0ASize + loadedSmth0CSize;
neededCharacterSizeRef = sizeof(CXUncompContextHuffman);
if (loadedSizeRef >= sizeof(CXUncompContextHuffman)) {
neededCharacterSize = loadedSizeRef;
}
baseSize = OSRoundUp32B(sizeof(FontInformation) + sizeof(FontTextureGlyph) + sheetOffsetsSize);
return baseSize + neededCharacterSize + loadedSheetsSize;
return (baseSize + loadedSheetsSize) + neededCharacterSize;
}
detail::ArchiveFontBase::ConstructState ArchiveFont::StreamingConstruct(ConstructContext* ctx, const void* fontData, u32 fontDataSize) {
@@ -164,8 +177,9 @@ namespace nw4r {
}
state = CONSTRUCT_STATE_WORKING;
reader = &ctx->mReader;
reader->Attach(fontData, fontDataSize);
CachedStreamReader& readerRef = ctx->mReader;
reader = &readerRef;
readerRef.Attach(fontData, fontDataSize);
while (state == CONSTRUCT_STATE_WORKING) {
switch (ctx->mNextCmd) {

View File

@@ -479,7 +479,28 @@ namespace nw4r {
ctx->pFontInfo->pGlyph = (FontTextureGlyph*)ctx->pWorkCurr;
reader->memcpyToBuf(ctx->pWorkCurr, sizeof(FontTextureGlyph));
{
u32 cachedLen;
u8* pBuf;
u32 dataLen;
u8* cachedStart;
u8* cachedEnd;
pBuf = ctx->pWorkCurr;
cachedStart = reader->pCachedStart;
cachedEnd = reader->pCachedEnd;
cachedLen = cachedEnd - cachedStart;
if (cachedLen >= sizeof(FontTextureGlyph)) {
memcpy(pBuf, cachedStart, sizeof(FontTextureGlyph));
reader->pCachedStart += sizeof(FontTextureGlyph);
} else {
dataLen = sizeof(FontTextureGlyph) - cachedLen;
memcpy(pBuf, cachedStart, cachedLen);
memcpy(pBuf + cachedLen, reader->pDataCurr, dataLen);
reader->pCachedStart = reader->pCachedEnd;
reader->pDataCurr += dataLen;
}
}
ctx->pWorkCurr += sizeof(FontTextureGlyph);
origSheetFormat.formatRaw = ctx->pFontInfo->pGlyph->sheetFormat;

View File

@@ -57,6 +57,46 @@ void RFLiInitCtrlBuf(MEMiHeapHead* sysHeap) {
}
}
int RFLiGetControllerData(RFLiCharInfo* dst, s32 chan, u8 index, BOOL hiddenAvailable) {
RFLiCtrlManager* manager;
RFLiCtrlBuffer* buffer;
u16 flag;
RFLi_ASSERTLINE_RANGE(chan, 0, WPAD_MAX_CONTROLLERS, 1412);
RFLi_ASSERTLINE_RANGE(index, 0, RFL_MAX_CTRL_BUFFER, 1413);
if (chan < 0 || chan >= WPAD_MAX_CONTROLLERS) {
return FALSE;
}
if (index >= RFL_MAX_CTRL_BUFFER) {
return FALSE;
}
manager = RFLiGetCtrlBufManager();
if (manager == NULL) {
return FALSE;
}
if (!manager->mIsLoaded[chan]) {
return FALSE;
}
flag = (1 << index);
buffer = manager->mBuffer[chan];
if (!RFLiIsValidID((RFLCreateID*)&buffer->mData[index].createID)) {
return FALSE;
}
if (!hiddenAvailable && (buffer->mSecretFlag & flag) != 0) {
return FALSE;
}
RFLiConvertRaw2Info(&buffer->mData[index], dst);
return TRUE;
}
BOOL RFLiCheckCtrlBufferCore(const RFLiCtrlBuffer* buffer, u8 index, RFLiCtrlCheckType type) {
u16 flag = (1 << index);
@@ -771,46 +811,6 @@ int RFLiSetControllerData(const RFLiCharInfo* src, s32 chan, u8 index) {
return setDataCore_(src, chan, index, FALSE);
}
int RFLiGetControllerData(RFLiCharInfo* dst, s32 chan, u8 index, BOOL hiddenAvailable) {
RFLiCtrlManager* manager;
RFLiCtrlBuffer* buffer;
u16 flag;
RFLi_ASSERTLINE_RANGE(chan, 0, WPAD_MAX_CONTROLLERS, 1412);
RFLi_ASSERTLINE_RANGE(index, 0, RFL_MAX_CTRL_BUFFER, 1413);
if (chan < 0 || chan >= WPAD_MAX_CONTROLLERS) {
return FALSE;
}
if (index >= RFL_MAX_CTRL_BUFFER) {
return FALSE;
}
manager = RFLiGetCtrlBufManager();
if (manager == NULL) {
return FALSE;
}
if (!manager->mIsLoaded[chan]) {
return FALSE;
}
flag = (1 << index);
buffer = manager->mBuffer[chan];
if (!RFLiIsValidID((RFLCreateID*)&buffer->mData[index].createID)) {
return FALSE;
}
if (!hiddenAvailable && (buffer->mSecretFlag & flag) != 0) {
return FALSE;
}
RFLiConvertRaw2Info(&buffer->mData[index], dst);
return TRUE;
}
RFLErrcode RFLUnloadController(s32 chan) {
RFLi_ASSERTLINE_RANGE(chan, 0, WPAD_MAX_CONTROLLERS, 1461);

View File

@@ -204,7 +204,7 @@ void RFLi_MakeRandomFace_Core(RFLiCharInfo* pCharInfo, RFLi_SEX argSex, RFLi_AGE
pCharInfo->personal.localonly = FALSE;
}
u8 RFLi_GetFacelineType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
static u8 RFLi_GetFacelineType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
// clang-format off
static const u8 facelineTypeTable[RFLSex_All * RFLAge_All * RFLRace_All][10] = {
/* Male, Child, Black */ {0, 0, 0, 1, 1, 1, 2, 3, 4, 5},
@@ -272,7 +272,7 @@ u8 RFLi_GetHairType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
return hair_parts[index][RFLi_GetRandU32(hair_parts_num[index])];
}
u8 RFLi_GetEyeType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
static u8 RFLi_GetEyeType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
// clang-format off
u8 eye_parts[RFLSex_All * RFLAge_All * RFLRace_All][48] = {
/* Male, Child, Black */ { 2, 3, 5, 7, 8, 9, 11, 12, 13, 15, 16, 18, 27, 29, 32, 34, 36, 38, 39, 41, 43, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
@@ -307,7 +307,7 @@ u8 RFLi_GetEyeType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
return eye_parts[index][RFLi_GetRandU32(eye_parts_num[index])];
}
u8 RFLi_GetEyebrowType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
static u8 RFLi_GetEyebrowType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
// clang-format off
static const u8 eyebrow_parts[RFLSex_All * RFLAge_All * RFLRace_All][24] = {
/* Male, Child, Black */ { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 17, 18, 20, 0, 0, 0, 0, 0, 0},
@@ -342,7 +342,7 @@ u8 RFLi_GetEyebrowType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
return eyebrow_parts[index][RFLi_GetRandU32(eyebrow_parts_num[index])];
}
u8 RFLi_GetNoseType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
static u8 RFLi_GetNoseType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
// clang-format off
u8 nose_parts[RFLSex_All * RFLAge_All * RFLRace_All][12] = {
/* Male, Child, Black */ { 0, 1, 2, 3, 4, 5, 7, 8, 10, 0, 0, 0},
@@ -377,7 +377,7 @@ u8 RFLi_GetNoseType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
return nose_parts[index][RFLi_GetRandU32(nose_parts_num[index])];
}
u8 RFLi_GetMouthType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
static u8 RFLi_GetMouthType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
// clang-format off
u8 mouth_parts[RFLSex_All * RFLAge_All * RFLRace_All][24] = {
/* Male, Child, Black */ { 0, 2, 3, 6, 7, 8, 9, 10, 12, 14, 15, 17, 18, 19, 21, 22, 23, 0, 0, 0, 0, 0, 0, 0},
@@ -412,7 +412,7 @@ u8 RFLi_GetMouthType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
return mouth_parts[index][RFLi_GetRandU32(mouth_parts_num[index])];
}
u8 RFLi_GetFaceTexType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
static u8 RFLi_GetFaceTexType(RFLi_SEX sex, RFLi_AGE age, RFLi_RACE race) {
// clang-format off
static const u8 faceTexTypeTable[RFLSex_All * RFLAge_All * RFLRace_All][20] = {
/* Male, Child, Black */ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 3},
@@ -507,7 +507,7 @@ u8 RFLi_GetGlassType(RFLi_AGE age) {
}
}
u8 RFLi_GetFaceColor(RFLi_SEX sex, RFLi_RACE race) {
static u8 RFLi_GetFaceColor(RFLi_SEX sex, RFLi_RACE race) {
// clang-format off
static const u8 faceColorTable[RFLSex_All * RFLRace_All][10] = {
/* Male, Black */ { 2, 2, 4, 4, 4, 4, 5, 5, 5, 5 },
@@ -526,7 +526,7 @@ u8 RFLi_GetFaceColor(RFLi_SEX sex, RFLi_RACE race) {
return faceColorTable[(sex * RFLRace_All) + race][RFLi_GetRandU32(GET_ARRAY_LENGTH(faceColorTable[0]))];
}
u8 RFLi_GetHairColor(RFLi_AGE age, RFLi_RACE race) {
static u8 RFLi_GetHairColor(RFLi_AGE age, RFLi_RACE race) {
// clang-format off
static const u8 hairColorTable[RFLAge_All * RFLRace_All][20] = {
/* Black, Child */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
@@ -547,7 +547,7 @@ u8 RFLi_GetHairColor(RFLi_AGE age, RFLi_RACE race) {
return hairColorTable[(race * 4 - race) + age][RFLi_GetRandU32(GET_ARRAY_LENGTH(hairColorTable[0]))];
}
u8 RFLi_GetEyeColor(RFLi_RACE race) {
static u8 RFLi_GetEyeColor(RFLi_RACE race) {
// clang-format off
static const u8 eyeColorTable[RFLRace_All][10] = {
/* Black */ {0, 0, 0, 0, 0, 0, 0, 0, 0, 1},
@@ -561,6 +561,6 @@ u8 RFLi_GetEyeColor(RFLi_RACE race) {
return eyeColorTable[race][RFLi_GetRandU32(GET_ARRAY_LENGTH(eyeColorTable[0]))];
}
u32 RFLi_GetRandU32(u32 max) {
static u32 RFLi_GetRandU32(u32 max) {
return OSGetTick() % max;
}

View File

@@ -202,7 +202,7 @@ void RFLExit() {
}
}
RFLErrcode RFLiBootLoad() {
static inline RFLErrcode RFLiBootLoad() {
RFLiBootLoadAsync();
return RFLWaitAsync();
}
@@ -223,7 +223,7 @@ static void bootloadDB2Res_() {
}
}
RFLErrcode RFLiBootLoadAsync() {
static inline RFLErrcode RFLiBootLoadAsync() {
return RFLiBootLoadDatabaseAsync(bootloadDB2Res_);
}
@@ -249,7 +249,7 @@ void RFLiFree(void* block) {
MEMFreeToExpHeap(RFLiGetManager()->mTmpHeap, block);
}
u32 RFLiGetUsedWorkSize() {
static inline u32 RFLiGetUsedWorkSize() {
if (RFLAvailable()) {
MEMiHeapHead* heap = RFLiGetManager()->mTmpHeap;
return MEMGetAllocatableSizeForExpHeap(heap) - MEMGetTotalFreeSizeForExpHeap(heap);
@@ -397,7 +397,7 @@ BOOL RFLiNeedRepairError() {
return ((*list & (1 << RFLiFileBrokenType_DBBroken)) != 0) ? TRUE : FALSE;
}
BOOL RFLiCriticalError() {
static inline BOOL RFLiCriticalError() {
u8* list = &sRFLBrokenType;
BOOL ret = FALSE; // Unused

View File

@@ -1,5 +1,49 @@
#include <tmc_jpeg_internal.h>
#ifdef __MWERKS__
asm s32 TMCJPEGDEC_init_buff_thumbnail(register TMCCJPEGDecWork* work, register u8* dst, register u8* src) {
nofralloc
lwz r0, 4(r5)
cmpwi r0, 0
bne _init_buff_thumbnail_have_src1
li r3, -1
blr
_init_buff_thumbnail_have_src1:
lwz r0, 8(r5)
cmpwi r0, 0
bne _init_buff_thumbnail_have_src2
li r3, -1
blr
_init_buff_thumbnail_have_src2:
lwz r7, 0(r5)
li r0, 0
stw r7, 0x18(r4)
lwz r6, 4(r5)
stw r6, 0x1c(r4)
lwz r6, 8(r5)
stw r6, 0x20(r4)
lwz r6, 0xc(r5)
stw r6, 0x24(r4)
lwz r5, 0x10(r5)
stw r5, 0x28(r4)
stw r7, 8(r4)
lwz r6, 0x674(r3)
lwz r5, 0x66c(r3)
add r5, r6, r5
stw r5, 0xc(r4)
lwz r6, 0x670(r3)
li r3, 0
add r5, r5, r6
stw r0, 0x20(r4)
subi r0, r5, 0x22
stw r5, 0x10(r4)
stw r0, 0x14(r4)
blr
}
#else
s32 TMCJPEGDEC_init_buff_thumbnail(TMCCJPEGDecWork* work, u8* dst, u8* src) {
u32* src32;
u32* dst32;
@@ -29,6 +73,7 @@ s32 TMCJPEGDEC_init_buff_thumbnail(TMCCJPEGDecWork* work, u8* dst, u8* src) {
dst32[8] = 0;
return 0;
}
#endif
s32 TMCJPEGDEC_init_buff(TMCCJPEGDecWork* work) {
work->bitBuf = 0;

View File

@@ -1,5 +1,256 @@
#include <tmc_jpeg_internal.h>
extern void* memcpy(void* dest, const void* src, unsigned long size);
extern void* memset(void* dest, int value, unsigned long size);
#ifdef __MWERKS__
asm s32 TMCJPEGDEC_make_huffdec(register const u8* dht, register const u8* tb, register TMCHuffParam* hp) {
nofralloc
stwu r1, -0x840(r1)
mflr r0
li r6, 1
li r7, 1
stw r0, 0x844(r1)
stmw r20, 0x810(r1)
mr r26, r3
mr r27, r4
addi r4, r1, 0x408
addi r3, r3, 1
lwz r31, 0(r5)
lwz r30, 4(r5)
lwz r29, 8(r5)
lbz r28, 0xc(r5)
li r5, 0
_make_huffdec_count_loop:
lbz r0, 0(r3)
cmpw r7, r0
ble _make_huffdec_count_store
addi r6, r6, 1
li r7, 1
cmpwi r6, 0x10
addi r3, r3, 1
ble _make_huffdec_count_loop
slwi r0, r5, 2
addi r7, r1, 0x408
li r3, 0
stwx r3, r7, r0
b _make_huffdec_count_done
_make_huffdec_count_store:
addi r5, r5, 1
stw r6, 0(r4)
cmpw r5, r28
addi r4, r4, 4
ble _make_huffdec_count_next
li r3, -0x40
b _make_huffdec_return
_make_huffdec_count_next:
addi r7, r7, 1
b _make_huffdec_count_loop
_make_huffdec_count_done:
lwz r0, 0x408(r1)
addi r6, r1, 8
li r9, 0
li r8, 0
clrlwi r10, r0, 24
li r4, 1
b _make_huffdec_values_loop
_make_huffdec_values_inner:
clrlwi r5, r10, 24
slwi r3, r8, 2
b _make_huffdec_values_store_check
_make_huffdec_values_store:
clrlwi r0, r9, 16
addi r7, r7, 4
stwx r0, r6, r3
addi r8, r8, 1
addi r3, r3, 4
addi r9, r9, 1
_make_huffdec_values_store_check:
lwz r0, 0(r7)
clrlwi r0, r0, 24
cmplw r5, r0
beq _make_huffdec_values_store
clrlwi r3, r9, 16
slw r0, r4, r5
cmpw r3, r0
blt _make_huffdec_values_next
li r3, -0x40
b _make_huffdec_return
_make_huffdec_values_next:
clrlslwi r9, r9, 17, 1
addi r10, r10, 1
_make_huffdec_values_loop:
lwz r0, 0(r7)
cmpwi r0, 0
bne _make_huffdec_values_inner
mr r3, r30
li r4, 0
li r5, 0x44
bl memset
addi r4, r1, 0x408
addi r5, r1, 8
li r6, 0
mtctr r28
cmpwi r28, 0
ble _make_huffdec_valptr_done
_make_huffdec_valptr_loop:
lwz r0, 0(r4)
cmplwi r0, 0x10
bgt _make_huffdec_valptr_next
slwi r3, r0, 2
lwz r0, 0(r5)
add r3, r30, r3
sth r6, 2(r3)
sth r0, 0(r3)
_make_huffdec_valptr_next:
addi r4, r4, 4
addi r5, r5, 4
addi r6, r6, 1
bdnz _make_huffdec_valptr_loop
_make_huffdec_valptr_done:
addi r4, r1, 8
addi r12, r26, 1
li r6, 0
li r7, 1
lis r3, 0x8000
_make_huffdec_table_loop:
subfic r0, r7, 8
li r8, 1
slw r5, r8, r0
b _make_huffdec_table_count
_make_huffdec_table_store:
lwz r10, 0(r4)
cmpwi cr1, r5, 0
mr r9, r5
slw r10, r10, r0
ble cr1, _make_huffdec_table_next
cmpwi r5, 8
ble _make_huffdec_table_short
li r21, 0
blt cr1, _make_huffdec_table_short_check
addi r11, r3, 1
cmpw r5, r11
blt _make_huffdec_table_short_check
li r21, 1
_make_huffdec_table_short_check:
cmpwi r21, 0
beq _make_huffdec_table_short
subi r11, r5, 1
slwi r26, r10, 2
srwi r11, r11, 3
mtctr r11
cmpwi r5, 8
ble _make_huffdec_table_short
_make_huffdec_table_unrolled:
sthx r7, r31, r26
add r25, r31, r26
addi r11, r10, 1
addi r22, r10, 2
lbzx r24, r27, r6
slwi r21, r11, 2
addi r11, r10, 3
addi r30, r10, 6
sth r24, 2(r25)
slwi r23, r11, 2
addi r11, r10, 4
add r20, r31, r21
sthx r7, r31, r21
slwi r24, r11, 2
addi r11, r10, 5
slwi r22, r22, 2
lbzx r21, r27, r6
slwi r25, r11, 2
addi r11, r10, 7
slwi r30, r30, 2
sth r21, 2(r20)
add r20, r31, r23
add r21, r31, r24
slwi r11, r11, 2
sthux r7, r22, r31
add r23, r31, r25
add r25, r31, r11
add r24, r31, r30
lbzx r11, r27, r6
addi r10, r10, 8
addi r26, r26, 0x20
subi r9, r9, 8
sth r11, 2(r22)
sth r7, 0(r20)
lbzx r11, r27, r6
sth r11, 2(r20)
sth r7, 0(r21)
lbzx r11, r27, r6
sth r11, 2(r21)
sth r7, 0(r23)
lbzx r11, r27, r6
sth r11, 2(r23)
sthx r7, r31, r30
lbzx r11, r27, r6
sth r11, 2(r24)
sth r7, 0(r25)
lbzx r11, r27, r6
sth r11, 2(r25)
bdnz _make_huffdec_table_unrolled
_make_huffdec_table_short:
slwi r10, r10, 2
add r11, r31, r10
mtctr r9
cmpwi r9, 0
ble _make_huffdec_table_next
_make_huffdec_table_short_loop:
sth r7, 0(r11)
subi r9, r9, 1
lbzx r10, r27, r6
sth r10, 2(r11)
addi r11, r11, 4
bdnz _make_huffdec_table_short_loop
_make_huffdec_table_next:
addi r8, r8, 1
addi r4, r4, 4
addi r6, r6, 1
_make_huffdec_table_count:
lbz r9, 0(r12)
cmpw r8, r9
ble _make_huffdec_table_store
addi r7, r7, 1
addi r12, r12, 1
cmpwi r7, 8
ble _make_huffdec_table_loop
mr r3, r29
mr r4, r27
mr r5, r28
bl memcpy
li r3, 0
_make_huffdec_return:
lmw r20, 0x810(r1)
lwz r0, 0x844(r1)
mtlr r0
addi r1, r1, 0x840
blr
}
#else
s32 TMCJPEGDEC_make_huffdec(const u8* dht, const u8* tb, TMCHuffParam* hp) {
u32 huffCount[256];
u32 huffVal[256];
@@ -115,8 +366,10 @@ s32 TMCJPEGDEC_make_huffdec(const u8* dht, const u8* tb, TMCHuffParam* hp) {
return 0;
}
#endif
void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCUnknownInfo* work) {
void TMCJPEGDEC_set_HuffmanTable(TMCHuffParam* tbl, s32 tblType, s32 tblID, TMCUnknownInfo* info) {
TMCCJPEGDecWork* work = (TMCCJPEGDecWork*)info;
void* hufftable;
void* maxcode;
void* valptr;

View File

@@ -169,8 +169,9 @@ s32 TMCCJPEGDecGetOffsetEXIF(u32* pOffset, u32* pSize, TMCCJPEGDecInitParam* pPa
s32 TMCCJPEGDecGetInfoEXIF(TMCCJPEGDecExifInfo* pInfo, TMCCJPEGDecInitParam* pParam) {
TMCCJPEGDecWork* work;
u16 segSize;
u32 segSizeP2;
u32 segSize;
u16 segSizeP2;
u16 exifSize;
s32 result;
work = pParam->pBuf1;
@@ -195,7 +196,8 @@ s32 TMCCJPEGDecGetInfoEXIF(TMCCJPEGDecExifInfo* pInfo, TMCCJPEGDecInitParam* pPa
}
segSizeP2 = segSize + 2;
result = TMCJPEGDEC_exif_parse((const u8*)pParam->pBuf2 + 10, segSize - 8, &pInfo->exifData);
exifSize = segSize - 8;
result = TMCJPEGDEC_exif_parse((const u8*)pParam->pBuf2 + 10, exifSize, &pInfo->exifData);
if (result < 0) {
return result;
}
@@ -621,9 +623,8 @@ static s32 TMCJPEGDEC_ThumbnailCheck(TMCCJPEGDecInitParam* param, TMCCJPEGDecExi
return -0xA0;
}
total += length;
tmp = (s32)info->exifData.thumbnailData - (s32)param->pBuf2;
total += tmp;
total = length + total + tmp;
if ((u32)total > param->buf2Size) {
return -0xF1;

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,220 @@
#include <tmc_jpeg_internal.h>
extern void* memset(void* dest, int value, unsigned long size);
static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork* work);
#ifdef __MWERKS__
asm s32 TMCJPEGDEC_decode_iquant_rc(register s32* block, register u8* conv_row_ptr, register u32* dc_predict_row_ptr, register TMCCJPEGDecWork* work) {
nofralloc
stwu r1, -0x40(r1)
mflr r0
stw r0, 0x44(r1)
stmw r21, 0x14(r1)
mr r22, r3
mr r23, r4
mr r25, r5
mr r24, r6
lwz r0, 4(r6)
lwz r21, 0x498(r6)
cmpwi r0, 8
bgt _decode_iquant_rc_have_dc_bits
mr r3, r24
bl TMCJPEGDEC_load_buff
cmpwi r3, 0
bge _decode_iquant_rc_have_dc_bits
b _decode_iquant_rc_return
_decode_iquant_rc_have_dc_bits:
lwz r4, 4(r24)
lwz r3, 0(r24)
addi r0, r4, -8
srw r0, r3, r0
rlwinm r0, r0, 2, 0x16, 0x1d
lhzx r5, r21, r0
cmpwi r5, 0
beq _decode_iquant_rc_decode_dc
add r3, r21, r0
subf r0, r5, r4
lhz r21, 2(r3)
stw r0, 4(r24)
b _decode_iquant_rc_have_dc_value
_decode_iquant_rc_decode_dc:
lwz r3, 0x49c(r24)
mr r5, r24
lwz r4, 0x4a0(r24)
bl TMCJPEGDEC_vl_decode_rc
cmpwi r3, 0
mr r21, r3
bge _decode_iquant_rc_have_dc_value
b _decode_iquant_rc_return
_decode_iquant_rc_have_dc_value:
cmpwi r21, 0
beq _decode_iquant_rc_store_dc
lwz r0, 4(r24)
cmpw r0, r21
bgt _decode_iquant_rc_read_dc_bits
mr r3, r24
bl TMCJPEGDEC_load_buff
cmpwi r3, 0
bge _decode_iquant_rc_read_dc_bits
b _decode_iquant_rc_return
_decode_iquant_rc_read_dc_bits:
lwz r0, 4(r24)
li r4, 1
lwz r3, 0(r24)
slw r6, r4, r21
subf r4, r21, r0
addi r5, r6, -1
srwi r0, r6, 1
srw r3, r3, r4
stw r4, 4(r24)
and r3, r5, r3
cmplw r0, r3
ble _decode_iquant_rc_store_dc_bits
subf r3, r5, r3
_decode_iquant_rc_store_dc_bits:
lwz r0, 0(r25)
add r0, r0, r3
stw r0, 0(r25)
_decode_iquant_rc_store_dc:
lwz r5, 0(r25)
addi r3, r22, 4
lwz r0, 0(r23)
li r4, 0
mullw r0, r5, r0
stw r0, 0(r22)
lwz r30, 0x4a8(r24)
lwz r26, 0x4ac(r24)
lwz r25, 0x4b0(r24)
lwz r27, 0x1834(r24)
lwz r5, 0x1838(r24)
bl memset
lis r21, TMCJPEGDEC_Zigzag_data@ha
li r28, 1
addi r21, r21, TMCJPEGDEC_Zigzag_data@l
li r31, 1
_decode_iquant_rc_ac_loop:
lwz r0, 4(r24)
cmpwi r0, 8
bgt _decode_iquant_rc_have_ac_bits
mr r3, r24
bl TMCJPEGDEC_load_buff
cmpwi r3, 0
bge _decode_iquant_rc_have_ac_bits
b _decode_iquant_rc_return
_decode_iquant_rc_have_ac_bits:
lwz r4, 4(r24)
lwz r3, 0(r24)
addi r0, r4, -8
srw r0, r3, r0
rlwinm r0, r0, 2, 0x16, 0x1d
add r3, r30, r0
lhzx r0, r30, r0
cmpwi r0, 0
beq _decode_iquant_rc_decode_ac
lhz r3, 2(r3)
subf r0, r0, r4
stw r0, 4(r24)
b _decode_iquant_rc_have_ac_value
_decode_iquant_rc_decode_ac:
mr r3, r26
mr r4, r25
mr r5, r24
bl TMCJPEGDEC_vl_decode_rc
cmpwi r3, 0
bge _decode_iquant_rc_have_ac_value
b _decode_iquant_rc_return
_decode_iquant_rc_have_ac_value:
clrlwi. r29, r3, 0x1c
beq _decode_iquant_rc_no_ac_bits
lwz r0, 4(r24)
srawi r3, r3, 4
add r28, r28, r3
cmpw r0, r29
bgt _decode_iquant_rc_read_ac_bits
mr r3, r24
bl TMCJPEGDEC_load_buff
cmpwi r3, 0
bge _decode_iquant_rc_read_ac_bits
b _decode_iquant_rc_return
_decode_iquant_rc_read_ac_bits:
cmpw r28, r27
ble _decode_iquant_rc_store_ac
lwz r0, 4(r24)
cmpwi r28, 0x40
subf r0, r29, r0
stw r0, 4(r24)
blt _decode_iquant_rc_increment
li r3, -0x64
b _decode_iquant_rc_return
_decode_iquant_rc_increment:
addi r28, r28, 1
b _decode_iquant_rc_loop_check
_decode_iquant_rc_store_ac:
lwz r0, 4(r24)
slw r6, r31, r29
lwz r3, 0(r24)
addi r5, r6, -1
subf r4, r29, r0
srwi r0, r6, 1
srw r3, r3, r4
stw r4, 4(r24)
and r4, r5, r3
cmplw r0, r4
ble _decode_iquant_rc_have_extra
subf r4, r5, r4
_decode_iquant_rc_have_extra:
cmpwi r28, 0x40
blt _decode_iquant_rc_store_coeff
li r3, -0x64
b _decode_iquant_rc_return
_decode_iquant_rc_store_coeff:
lbzx r0, r21, r28
addi r28, r28, 1
slwi r3, r0, 2
lwzx r0, r23, r3
mullw r0, r4, r0
stwx r0, r22, r3
b _decode_iquant_rc_loop_check
_decode_iquant_rc_no_ac_bits:
cmpwi r3, 0
bne _decode_iquant_rc_zrl
li r3, 0
b _decode_iquant_rc_return
_decode_iquant_rc_zrl:
addi r28, r28, 0x10
_decode_iquant_rc_loop_check:
cmpwi r28, 0x40
blt _decode_iquant_rc_ac_loop
li r3, 0
_decode_iquant_rc_return:
lmw r21, 0x14(r1)
lwz r0, 0x44(r1)
mtlr r0
addi r1, r1, 0x40
blr
}
#else
s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_row_ptr, TMCCJPEGDecWork* work) {
const u8* zztbl;
u16* ac_fast;
@@ -142,6 +355,7 @@ s32 TMCJPEGDEC_decode_iquant_rc(s32* block, u8* conv_row_ptr, u32* dc_predict_ro
return 0;
}
#endif
static s32 TMCJPEGDEC_vl_decode_rc(u32* huff_tbl, u8* huff_sym, TMCCJPEGDecWork* work) {
s32 bit_pos;

View File

@@ -181,7 +181,7 @@ struct __zi8_work_data_s {
ziU32 unk_0x14;
ziU8 unk_0x18;
ziU8 unk_0x1C[0x108];
ziU16** unk_0x124;
ziU16* unk_0x124[1];
ziU8* unk_0x128;
ziU8 unk_0x12C;
};

View File

@@ -45,6 +45,7 @@ enum {
ziU32 Zi8GetTableData(ziU8 lang, ziU8 tableIdx, ziU8 memberId ZI_NEED_WORK) {
ziU8 langIdx;
ziU32 offset = 0;
ziU32 address;
ziU8* tableData;
Zi8LogError(0x64, ZI_WORK);
@@ -62,8 +63,9 @@ ziU32 Zi8GetTableData(ziU8 lang, ziU8 tableIdx, ziU8 memberId ZI_NEED_WORK) {
}
switch (memberId) {
case ziTableAddress: {
return ((ziU32)tableData + (tableData[(tableIdx * ZI8_TABLE_SIZE) + 7] << 0x10) + (tableData[(tableIdx * ZI8_TABLE_SIZE) + 8] << 8) +
(tableData[(tableIdx * ZI8_TABLE_SIZE) + 9]));
address = (tableData[(tableIdx * ZI8_TABLE_SIZE) + 7] << 0x10) +
(tableData[(tableIdx * ZI8_TABLE_SIZE) + 8] << 8) + (tableData[(tableIdx * ZI8_TABLE_SIZE) + 9]);
return (ziU32)(tableData + address);
}
case ziTableSize: {
tableData = tableData + ((tableIdx * ZI8_TABLE_SIZE) + 4);

View File

@@ -9,7 +9,7 @@ ziU32 Zi8GetZHuwdPtr(ziU32* arg0, ziU16* arg1 ZI_NEED_WORK) {
return 0;
} else {
*arg1 = ZI_WORK->unk_0x124[ZI_WORK->unk_0x12C - 1][1] / 3;
*arg0 = ZI_WORK->unk_0x124[ZI_WORK->unk_0x12C - 1][0];
*arg0 = (ziU32)ZI_WORK->unk_0x124[ZI_WORK->unk_0x12C - 1];
*arg0 += 8;
Zi8LogError(0x64, ZI_WORK);
return 1;

View File

@@ -247,7 +247,12 @@ typedef struct WPADCB {
u8 unk_0x98F[0x9A0 - 0x990];
} WPADCB;
extern WPADCB _wpd[WPAD_MAX_CONTROLLERS];
typedef struct WPADStorage {
WPADCB controllers[WPAD_MAX_CONTROLLERS];
u8 unk_0x26C0[0x48];
} WPADStorage;
extern WPADStorage _wpd;
extern WPADCB* _wpdcb[WPAD_MAX_CONTROLLERS];
void WPADiInitSub();

View File

@@ -55,7 +55,7 @@ typedef struct AXFX_REVERBHI_EXP {
f32 sendGain; // 0x144
} AXFX_REVERBHI_EXP;
u32 AXFXReverbHiExpGetMemSize(const AXFX_REVERBHI_EXP* fx);
u32 AXFXReverbHiExpGetMemSize(AXFX_REVERBHI_EXP* fx);
BOOL AXFXReverbHiExpInit(AXFX_REVERBHI_EXP* fx);
void AXFXReverbHiExpShutdown(AXFX_REVERBHI_EXP* fx);
BOOL AXFXReverbHiExpSettings(AXFX_REVERBHI_EXP* fx);

View File

@@ -10,7 +10,16 @@ extern "C" {
#endif
typedef struct _GXColor {
#ifdef IPL_SYSTEM_COLOR_ALIGNMENT
union {
struct {
u8 r, g, b, a;
};
u32 value;
};
#else
u8 r, g, b, a; // 0x00
#endif
} GXColor;
typedef struct _GXColorS10 {

View File

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

View File

@@ -10,6 +10,10 @@ void* __CARDGetFatBlock(CARDControl* card) {
return card->currentFat;
}
static u16* __CARDGetFatBlockU16(CARDControl* card) {
return card->currentFat;
}
static void WriteCallback(s32 chan, s32 result) {
CARDControl* card;
CARDCallback callback;
@@ -85,7 +89,7 @@ s32 __CARDAllocBlock(s32 chan, u32 cBlock, CARDCallback callback) {
return CARD_RESULT_NOCARD;
}
fat = __CARDGetFatBlock(card);
fat = __CARDGetFatBlockU16(card);
if (fat[3] < cBlock) {
return CARD_RESULT_INSSPACE;
}
@@ -131,7 +135,7 @@ s32 __CARDFreeBlock(s32 chan, u16 nBlock, CARDCallback callback) {
return CARD_RESULT_NOCARD;
}
fat = __CARDGetFatBlock(card);
fat = __CARDGetFatBlockU16(card);
while (nBlock != 0xFFFF) {
if (!CARDIsValidBlockNo(card, nBlock)) {
return CARD_RESULT_BROKEN;
@@ -155,6 +159,6 @@ s32 __CARDUpdateFatBlock(s32 chan, u16* fat, CARDCallback callback) {
__CARDCheckSum(fat + 2, 0x1FFC, fat, fat + 1);
DCStoreRange(fat, 0x2000);
card->eraseCallback = callback;
addr = (((char*)fat - (char*)card->workArea) / 8192) * card->sectorSize;
addr = ((u32)fat - (u32)card->workArea) / CARD_SYSTEM_BLOCK_SIZE * card->sectorSize;
return __CARDEraseSector(chan, addr, EraseCallback);
}

View File

@@ -1,35 +1,55 @@
#include <revolution/verdefs.h>
#include <revolution/os.h>
#include <private/nand.h>
#include <revolution/nand.h>
#include <private/es.h>
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
SDKDefineVersion(CNTCACHE, "Apr 20 2010", "14:15:28");
char lbl_81693350[0xd0] = {
0x3c, 0x3c, 0x20, 0x52, 0x56, 0x4c, 0x5f, 0x53, 0x44, 0x4b, 0x20, 0x2d, 0x20, 0x43, 0x4e, 0x54,
0x43, 0x41, 0x43, 0x48, 0x45, 0x20, 0x09, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x20, 0x62,
0x75, 0x69, 0x6c, 0x64, 0x3a, 0x20, 0x41, 0x70, 0x72, 0x20, 0x32, 0x30, 0x20, 0x32, 0x30, 0x31,
0x30, 0x20, 0x31, 0x34, 0x3a, 0x31, 0x35, 0x3a, 0x32, 0x38, 0x20, 0x28, 0x30, 0x78, 0x34, 0x31,
0x39, 0x39, 0x5f, 0x36, 0x30, 0x38, 0x33, 0x31, 0x29, 0x20, 0x3e, 0x3e, 0x00, 0x00, 0x00, 0x00,
0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x32, 0x2f, 0x63, 0x6e, 0x74, 0x63, 0x61, 0x63, 0x68,
0x65, 0x2e, 0x74, 0x78, 0x74, 0x00, 0x00, 0x00, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x69,
0x74, 0x6c, 0x65, 0x20, 0x00, 0x00, 0x00, 0x00, 0x25, 0x30, 0x31, 0x36, 0x6c, 0x6c, 0x78, 0x20,
0x00, 0x00, 0x00, 0x00, 0x2f, 0x74, 0x6d, 0x70, 0x2f, 0x63, 0x6e, 0x74, 0x63, 0x61, 0x63, 0x68,
0x65, 0x2e, 0x74, 0x78, 0x74, 0x00, 0x00, 0x00, 0x2f, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x32,
0x00, 0x00, 0x00, 0x00, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
0x74, 0x20, 0x00, 0x00, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x00,
0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x00, 0x00, 0x00
};
char lbl_81693420[0x16] = {
0x2f, 0x74, 0x69, 0x74, 0x6c, 0x65, 0x2f, 0x25, 0x30, 0x38, 0x78, 0x2f, 0x25, 0x30, 0x38, 0x78,
0x2f, 0x64, 0x61, 0x74, 0x61, 0x00,
};
const char* __CNTCACHEVersion = lbl_81693350;
char lbl_816985DC[3] = {0x20, 0x0a, 0x00};
extern void _savegpr_23();
extern void _restgpr_23();
extern void _savegpr_26();
extern void _restgpr_26();
OSMutex _CNTCACHEMutex;
int _CNTCACHEUnused816997A8;
long long _CNTCACHEUnused816997A8;
int _CNTCACHEUnused816997A4;
BOOL _CNTCACHEInitialized;
void CNTCACHEClear();
BOOL _CNTCACHEIsTitleRemovable(ESTitleId titleId);
void _CNTCACHEDeleteTitle();
void _CNTCACHEDeleteContent();
void CNTCACHEInit(int unk0, int unk1) {
if (_CNTCACHEInitialized == FALSE) {
BOOL old;
OSRegisterVersion(GetVersion(CNTCACHE));
OSRegisterVersion(__CNTCACHEVersion);
OSInitMutex(&_CNTCACHEMutex);
ES_InitLib();
@@ -41,87 +61,492 @@ void CNTCACHEInit(int unk0, int unk1) {
CNTCACHEClear();
_CNTCACHEUnused816997A4 = unk0;
_CNTCACHEUnused816997A8 = unk1;
*((int*)&_CNTCACHEUnused816997A8) = unk1;
}
asm void CNTCACHEClear() {
clrlwi r11, r1, 0x1b
mr r12, r1
subfic r11, r11, -0x500
stwux r1, r1, r11
mflr r0
mr r11, r12
stw r0, 4(r12)
bl _savegpr_23
lis r30, lbl_81693350@ha
lis r3, _CNTCACHEMutex@ha
addi r30, r30, lbl_81693350@l
li r29, 0
addi r3, r3, _CNTCACHEMutex@l
bl OSLockMutex
addi r3, r30, 0x50
addi r4, r1, 0x24
li r27, 1
li r5, 3
bl NANDPrivateOpen
cmpwi r3, -0xc
mr r28, r3
bne L_d4
li r28, 0
b L_28c
L_d4:
cmpwi r3, 0
beq L_e0
b L_268
L_e0:
addi r3, r1, 0x24
addi r4, r1, 0x20
bl NANDGetLength
cmpwi r3, 0
mr r28, r3
beq L_fc
b L_268
L_fc:
li r26, 0
li r31, 0
b L_25c
L_108:
lwz r25, 0x20(r1)
cmplwi r25, 0x400
ble L_118
li r25, 0x400
L_118:
addi r24, r1, 0xc0
addi r0, r25, 0x1f
addi r3, r1, 0x24
mr r4, r24
rlwinm r5, r0, 0, 0, 0x1a
bl NANDRead
cmpw r3, r25
beq L_140
li r28, -0x14b3
b L_268
L_140:
mr r4, r24
li r28, 0
mtctr r25
cmplwi r25, 0
ble L_16c
L_154:
lbz r0, 0(r4)
cmpwi r0, 0xa
bne L_164
b L_170
L_164:
addi r4, r4, 1
bdnz L_154
L_16c:
li r4, 0
L_170:
cmpwi r4, 0
bne L_224
li r28, 0
b L_268
b L_224
L_184:
stb r31, 0(r4)
subf r23, r24, r4
mr r3, r24
la r4, lbl_816985DC
bl strtok
cmpwi r3, 0
mr r29, r3
beq L_1d4
addi r4, r30, 0xb4
bl strcmp
cmpwi r3, 0
bne L_1bc
bl _CNTCACHEDeleteTitle
b L_1d4
L_1bc:
mr r3, r29
addi r4, r30, 0xc0
bl strcmp
cmpwi r3, 0
bne L_1d4
bl _CNTCACHEDeleteContent
L_1d4:
lwz r0, 0x20(r1)
addi r23, r23, 1
add r24, r24, r23
subf r0, r23, r0
subf r25, r23, r25
mr r4, r24
stw r0, 0x20(r1)
add r26, r26, r23
mtctr r25
cmplwi r25, 0
ble L_218
L_200:
lbz r0, 0(r4)
cmpwi r0, 0xa
bne L_210
b L_21c
L_210:
addi r4, r4, 1
bdnz L_200
L_218:
li r4, 0
L_21c:
cmpwi r4, 0
beq L_22c
L_224:
cmpwi r25, 0
bgt L_184
L_22c:
lwz r0, 0x20(r1)
cmpwi r0, 0
beq L_25c
mr r4, r26
addi r3, r1, 0x24
li r5, 0
bl NANDSeek
cmplw r3, r26
beq L_258
li r28, -0x14b3
b L_268
L_258:
li r28, 0
L_25c:
lwz r0, 0x20(r1)
cmpwi r0, 0
bne L_108
L_268:
addi r3, r1, 0x24
bl NANDClose
addi r3, r30, 0x50
li r29, 0
bl NANDPrivateDelete
cmpwi r3, 0
addi r3, r30, 0x84
bl NANDPrivateDelete
cmpwi r3, 0
L_28c:
cmpwi r29, 0
beq L_29c
addi r3, r1, 0x24
bl NANDClose
L_29c:
cmpwi r27, 0
beq L_2b0
lis r3, _CNTCACHEMutex@ha
addi r3, r3, _CNTCACHEMutex@l
bl OSUnlockMutex
L_2b0:
mr r3, r28
lwz r10, 0(r1)
mr r11, r10
bl _restgpr_23
lwz r0, 4(r10)
mtlr r0
mr r1, r10
blr
}
void _CNTCACHEDeleteTitle() {
char* tok = strtok(NULL, " \n");
while (tok != NULL) {
ESTitleId titleId;
errno = 0;
titleId = strtoull(tok, NULL, 16);
if (errno == 0 && NANDTitleIdHi(titleId) != 0x00000001) {
BOOL result = _CNTCACHEIsTitleRemovable(titleId);
if (result == TRUE) {
ES_DeleteTitle(titleId);
} else if (result == FALSE) {
ES_DeleteTitleContent(titleId);
}
}
tok = strtok(NULL, " \n");
}
asm void _CNTCACHEDeleteTitle() {
stwu r1, -0x20(r1)
mflr r0
li r3, 0
la r4, lbl_816985DC
stw r0, 0x24(r1)
stw r31, 0x1c(r1)
stw r30, 0x18(r1)
stw r29, 0x14(r1)
stw r28, 0x10(r1)
bl strtok
li r30, 0
li r31, -1
b L_370
L_304:
stw r30, errno(r0)
li r4, 0
li r5, 0x10
bl strtoull
lwz r0, errno(r0)
mr r28, r4
mr r29, r3
cmpwi r0, 0
bne L_364
and r0, r3, r31
cmplwi r0, 1
beq L_364
bl _CNTCACHEIsTitleRemovable
cmpwi r3, 1
bne L_350
mr r4, r28
mr r3, r29
bl ES_DeleteTitle
b L_364
L_350:
cmpwi r3, 0
bne L_364
mr r4, r28
mr r3, r29
bl ES_DeleteTitleContent
L_364:
li r3, 0
la r4, lbl_816985DC
bl strtok
L_370:
cmpwi r3, 0
bne L_304
lwz r0, 0x24(r1)
lwz r31, 0x1c(r1)
lwz r30, 0x18(r1)
lwz r29, 0x14(r1)
lwz r28, 0x10(r1)
mtlr r0
addi r1, r1, 0x20
blr
}
static int GetSavePath(ESTitleId titleId) {
char nandPath[64] ALIGN32;
s32 ret;
u32 usedBlocks = 1;
u32 usedINodes = 1;
snprintf(nandPath, (int)sizeof(nandPath), "/title/%08x/%08x/data", NANDTitleIdHi(titleId), NANDTitleIdLo(titleId));
ret = NANDSecretGetUsage(nandPath, &usedBlocks, &usedINodes);
if (ret == NAND_RESULT_NOEXISTS) {
ret = 2;
} else if (ret >= NAND_RESULT_OK) {
if (usedINodes == 1 && usedBlocks == 0) {
ret = 1;
} else {
ret = 0;
}
}
return ret;
asm int _CNTCACHEIsTitleRemovable(ESTitleId titleId) {
clrlwi r11, r1, 0x1b
mr r12, r1
subfic r11, r11, -0x2100
stwux r1, r1, r11
mflr r0
lis r5, lbl_81693420@ha
stw r0, 4(r12)
li r0, 1
addi r5, r5, lbl_81693420@l
stw r31, -4(r12)
stw r30, -8(r12)
mr r30, r3
addi r3, r1, 0x40
stw r29, -0xc(r12)
mr r29, r4
li r4, -1
stw r0, 0x20(r1)
and r6, r30, r4
and r7, r29, r4
li r4, 0x40
stw r0, 0x24(r1)
crclr 4*cr1+eq
bl snprintf
addi r3, r1, 0x40
addi r4, r1, 0x20
addi r5, r1, 0x24
bl NANDSecretGetUsage
cmpwi r3, -0xc
mr r4, r3
bne L_418
li r4, 2
b L_444
L_418:
cmpwi r3, 0
blt L_444
lwz r0, 0x24(r1)
cmplwi r0, 1
bne L_440
lwz r0, 0x20(r1)
cmpwi r0, 0
bne L_440
li r4, 1
b L_444
L_440:
li r4, 0
L_444:
cmpwi r4, 1
bne L_4bc
mr r4, r29
mr r3, r30
addi r31, r1, 0x80
addi r6, r1, 0x28
li r5, 0
bl ES_GetTmdView
cmpwi r3, 0
beq L_470
b L_4c0
L_470:
lwz r0, 0x28(r1)
cmplwi r0, 0x2060
ble L_484
li r3, -0x400
b L_4c0
L_484:
mr r4, r29
mr r3, r30
mr r5, r31
addi r6, r1, 0x28
bl ES_GetTmdView
cmpwi r3, 0
beq L_4a4
b L_4c0
L_4a4:
lhz r0, 0xd8(r1)
rlwinm. r0, r0, 0x18, 0x18, 0x1f
bne L_4b8
li r4, 1
b L_4bc
L_4b8:
li r4, 0
L_4bc:
mr r3, r4
L_4c0:
lwz r10, 0(r1)
lwz r0, 4(r10)
lwz r31, -4(r10)
lwz r30, -8(r10)
lwz r29, -0xc(r10)
mtlr r0
mr r1, r10
blr
}
static int GetTmdView(ESTitleId titleId, ESTmdView* tmdView) {
s32 ret;
u32* tmdSize = NULL;
ret = ES_GetTmdView(titleId, NULL, tmdSize);
if (ret != ES_ERR_OK) {
return ret;
}
if (*tmdSize > OSRoundUp32B(sizeof(ESTmdView))) {
ret = -1024;
goto out;
}
ret = ES_GetTmdView(titleId, tmdView, tmdSize);
out:
return ret;
}
int _CNTCACHEIsTitleRemovable(ESTitleId titleId) {
ESTmdView tmd ALIGN32;
s32 ret = -1;
ret = GetSavePath(titleId);
if (ret == 1) {
ret = GetTmdView(titleId, &tmd);
if (ret != ES_ERR_OK) {
return ret;
}
if (tmd.head.titleVersion >> 8 == 0) {
ret = 1;
} else {
ret = 0;
}
goto out;
}
out:
return ret;
asm void _CNTCACHEDeleteContent() {
clrlwi r11, r1, 0x1b
mr r12, r1
subfic r11, r11, -0x2100
stwux r1, r1, r11
mflr r0
mr r11, r12
stw r0, 4(r12)
bl _savegpr_26
li r3, 0
la r4, lbl_816985DC
bl strtok
li r31, 0
li r4, 0
stw r31, errno(r0)
li r5, 0x10
bl strtoull
lwz r0, errno(r0)
mr r29, r4
mr r30, r3
cmpwi r0, 0
bne L_708
li r0, -1
and r5, r3, r0
addis r0, r5, -1
cmplwi r0, 5
bne L_708
addi r28, r1, 0x80
addi r6, r1, 0x28
li r5, 0
bl ES_GetTmdView
cmpwi r3, -0x6a
beq L_708
cmpwi r3, 0
bne L_708
mr r4, r29
mr r3, r30
mr r5, r28
addi r6, r1, 0x28
bl ES_GetTmdView
cmpwi r3, 0
bne L_708
lwz r3, 0x94(r1)
rlwinm. r0, r3, 0, 0x1c, 0x1c
beq L_6f0
rlwinm. r0, r3, 0, 0x1b, 0x1b
beq L_6f0
li r3, 0
la r4, lbl_816985DC
bl strtok
li r26, 1
lis r27, lbl_81693420@ha
b L_6e8
L_5b0:
stw r31, errno(r0)
li r4, 0
li r5, 0xa
bl strtoul
lwz r0, errno(r0)
cmpwi r0, 0
bne L_6dc
cmplwi r3, 0x1fe
bgt L_6dc
lhz r0, 0xda(r1)
li r4, 0
mtctr r0
cmplwi r0, 0
ble L_6dc
L_5e8:
add r5, r28, r4
lhz r0, 0x60(r5)
cmplw r3, r0
bne L_6d4
lhz r0, 0x62(r5)
rlwinm. r0, r0, 0, 0x10, 0x10
bne L_6dc
lwz r5, 0x5c(r5)
mr r4, r29
mr r3, r30
bl ES_DeleteContent
cmpwi r3, 0
bne L_6dc
mr r4, r29
mr r3, r30
addi r6, r1, 0x2c
li r5, 0
bl ES_ListTitleContentsOnCard
cmpwi r3, 0
bne L_6dc
lwz r0, 0x2c(r1)
cmpwi r0, 0
bne L_6dc
li r0, -1
stw r26, 0x20(r1)
addi r3, r1, 0x40
addi r5, r27, lbl_81693420@l
stw r26, 0x24(r1)
and r6, r30, r0
and r7, r29, r0
li r4, 0x40
crclr 4*cr1+eq
bl snprintf
addi r3, r1, 0x40
addi r4, r1, 0x20
addi r5, r1, 0x24
bl NANDSecretGetUsage
cmpwi r3, -0xc
mr r0, r3
bne L_690
li r0, 2
b L_6bc
L_690:
cmpwi r3, 0
blt L_6bc
lwz r0, 0x24(r1)
cmplwi r0, 1
bne L_6b8
lwz r0, 0x20(r1)
cmpwi r0, 0
bne L_6b8
li r0, 1
b L_6bc
L_6b8:
li r0, 0
L_6bc:
cmpwi r0, 1
bne L_6dc
mr r4, r29
mr r3, r30
bl ES_DeleteTitle
b L_6dc
L_6d4:
addi r4, r4, 0x10
bdnz L_5e8
L_6dc:
li r3, 0
la r4, lbl_816985DC
bl strtok
L_6e8:
cmpwi r3, 0
bne L_5b0
L_6f0:
lwz r5, 0x28(r1)
addi r3, r1, 0x80
li r4, 0
addi r0, r5, 0x1f
rlwinm r5, r0, 0, 0, 0x1a
bl memset
L_708:
lwz r10, 0(r1)
mr r11, r10
bl _restgpr_26
lwz r0, 4(r10)
mtlr r0
mr r1, r10
blr
}

View File

@@ -0,0 +1,8 @@
#include <revolution/fa.h>
extern s32 pfstub_fclose(FAFILE* stream);
FAError FAFclose(FAFILE* stream) {
s32 error = pfstub_fclose(stream);
return (-error | error) >> 31;
}

View File

@@ -0,0 +1,8 @@
#include <revolution/fa.h>
extern s32 pfstub_finfo(FAFILE* stream, FAFileInfo* info);
FAError FAFinfo(FAFILE* stream, FAFileInfo* info) {
s32 error = pfstub_finfo(stream, info);
return (-error | error) >> 31;
}

View File

@@ -0,0 +1,7 @@
#include <revolution/fa.h>
extern size_t pfstub_fread(void* buffer, size_t size, size_t count, FAFILE* stream);
size_t FAFread(void* buffer, size_t size, size_t count, FAFILE* stream) {
return pfstub_fread(buffer, size, count, stream);
}

View File

@@ -0,0 +1,7 @@
#include <revolution/fa.h>
extern size_t pfstub_fwrite(void* buffer, size_t size, size_t count, FAFILE* stream);
size_t FAFwrite(void* buffer, size_t size, size_t count, FAFILE* stream) {
return pfstub_fwrite(buffer, size, count, stream);
}

View File

@@ -0,0 +1,2 @@
int FADiskInitializedPadding;
int FADiskInitialized;

View File

@@ -0,0 +1,10 @@
typedef int s32;
extern s32 PFDIR_closedir(void* dir);
extern s32 PFAPI_convertReturnValue(s32 err);
s32 pf2_closedir(void* dir) {
s32 err = PFDIR_closedir(dir);
err = PFAPI_convertReturnValue(err);
return err;
}

View File

@@ -0,0 +1,10 @@
#include <revolution/fa.h>
extern s32 PFVOL_errnum(void);
extern s32 PFAPI_convertError(s32 error);
FAError pf2_errnum() {
s32 error = PFVOL_errnum();
error = PFAPI_convertError(error);
return error;
}

View File

@@ -0,0 +1,7 @@
#include <revolution/types.h>
extern s32 PFVOL_InitModule(u32 config, void* param);
s32 PFFATFS_initializeFATFS(u32 config, void* param) {
return PFVOL_InitModule(config, param);
}

View File

@@ -0,0 +1,10 @@
#include <revolution/fa.h>
extern s32 PFFILE_fclose(FAFILE* stream);
extern s32 PFAPI_convertReturnValue(s32 error);
FAError pf2_fclose(FAFILE* stream) {
s32 error = PFFILE_fclose(stream);
error = PFAPI_convertReturnValue(error);
return error;
}

View File

@@ -0,0 +1,10 @@
#include <revolution/fa.h>
extern s32 PFFILE_feof(FAFILE* stream);
extern s32 PFAPI_convertReturnValue4feof(s32 error);
FAError pf2_feof(FAFILE* stream) {
s32 error = PFFILE_feof(stream);
error = PFAPI_convertReturnValue4feof(error);
return error;
}

View File

@@ -0,0 +1,10 @@
#include <revolution/fa.h>
extern s32 PFFILE_ferror(FAFILE* stream);
extern s32 PFAPI_convertError(s32 error);
FAError pf2_ferror(FAFILE* stream) {
s32 error = PFFILE_ferror(stream);
error = PFAPI_convertError(error);
return error;
}

View File

@@ -0,0 +1,12 @@
#include <revolution/fa.h>
extern s32 PFFILE_flock(FAFILE* stream, s32 mode);
extern s32 PFAPI_convertReturnValue(s32 error);
FAError pf2_flock(FAFILE* stream, s32 mode) {
s32 error;
mode |= 8;
error = PFFILE_flock(stream, mode);
error = PFAPI_convertReturnValue(error);
return error;
}

View File

@@ -0,0 +1,9 @@
#include <revolution/fa.h>
extern s32 PFFILE_fread(void* buffer, size_t size, size_t count, FAFILE* stream, size_t* countRead);
size_t pf2_fread(void* buffer, size_t size, size_t count, FAFILE* stream) {
size_t countRead;
PFFILE_fread(buffer, size, count, stream, &countRead);
return countRead;
}

View File

@@ -0,0 +1,10 @@
#include <revolution/fa.h>
extern s32 PFFILE_fsync(FAFILE* stream);
extern s32 PFAPI_convertReturnValue(s32 error);
FAError pf2_fsync(FAFILE* stream) {
s32 error = PFFILE_fsync(stream);
error = PFAPI_convertReturnValue(error);
return error;
}

View File

@@ -0,0 +1,9 @@
#include <revolution/fa.h>
extern s32 PFFILE_fwrite(void* buffer, size_t size, size_t count, FAFILE* stream, size_t* countWritten);
size_t pf2_fwrite(void* buffer, size_t size, size_t count, FAFILE* stream) {
size_t countWritten;
PFFILE_fwrite(buffer, size, count, stream, &countWritten);
return countWritten;
}

View File

@@ -66,6 +66,7 @@ void __OSEVStart();
void __OSEVEnd();
#define __OSEVSize ((u32)__OSEVEnd - (u32)__OSEVStart)
void __OSEVSetNumber();
void __OSDBJumpTarget();
void __DBVECTOR();
@@ -576,9 +577,18 @@ void OSInit() {
arenaAddr = RAMReadPtr(OSPhysicalToCached(OS_ADDR_AVAILABLE_MEM1_START));
if (arenaAddr == NULL) {
if (OSIsMEM1Region(__ArenaLo)) {
register void* arenaLo;
#ifdef __MWERKS__
asm {
lis arenaLo, -0x7E95
addi arenaLo, arenaLo, -0x6800
}
#else
arenaLo = __ArenaLo;
#endif
if (OSIsMEM1Region(arenaLo)) {
void* tmp = BootInfo->arenaLo;
arenaAddr = tmp == NULL ? __ArenaLo : tmp;
arenaAddr = tmp == NULL ? arenaLo : tmp;
if (BootInfo->arenaLo == NULL && BI2DebugFlag && *BI2DebugFlag < 2) {
arenaAddr = (void*)OSRoundUp32B(_stack_addr);
@@ -602,8 +612,17 @@ void OSInit() {
arenaAddr = RAMReadPtr(OSPhysicalToCached(OS_ADDR_AVAILABLE_MEM2_START));
if (arenaAddr != NULL) {
if (OSIsMEM2Region(__ArenaLo)) {
arenaAddr = __ArenaLo;
register void* arenaLo;
#ifdef __MWERKS__
asm {
lis arenaLo, -0x7E95
addi arenaLo, arenaLo, -0x6800
}
#else
arenaLo = __ArenaLo;
#endif
if (OSIsMEM2Region(arenaLo)) {
arenaAddr = arenaLo;
if (BI2DebugFlag && *BI2DebugFlag < 2) {
arenaAddr = (void*)OSRoundUp32B(_stack_addr);
@@ -777,7 +796,7 @@ static asm void __OSDBJump() {
#ifdef __MWERKS__
nofralloc
entry __OSDBJUMPSTART
bla OS_ADDR_DB_INTEGRATOR_HOOK
bla __OSDBJumpTarget
entry __OSDBJUMPEND
#endif // __MWERKS__
// clang-format on
@@ -813,6 +832,7 @@ entry __OSEVStart
mflr r3
stw r3, OSContext.lr(r4)
mfctr r3
entry __OSDBJumpTarget
stw r3, OSContext.ctr(r4)
mfxer r3
stw r3, OSContext.xer(r4)

View File

@@ -7,12 +7,17 @@
#include <string.h>
#pragma sym on
#define SD_SLOT_0_PATH "/dev/sdio/slot0"
#define SD_SLOT_1_PATH "/dev/sdio/slot1"
#define SD_SLOT_W_PATH "/dev/sdio/slotw"
#define SD_SLOT_PATH_LENGTH 32
char lbl_81691748[] = " +++ SD RESET Failed: %d +++\n\0"
"/dev/sdio/slot0\0/dev/sdio/slot1\0/dev/sdio/slotw";
typedef void (*SDCallbackFunc)(s32, void*);
#define SD_CMD_SIZE 0x24
@@ -29,7 +34,7 @@ u32* __sdReg = NULL;
IOSIoVector* __sdVect = NULL;
IOSHeapId __sdHeapId = -1;
static IOSHeapId __sdHeapId[2] = {-1};
char __sdPaths[SD_MAX_SLOTS][OSRoundUp32B(SD_SLOT_PATH_LENGTH)] ALIGN32;
OSMutex __reqMutex;
@@ -58,6 +63,9 @@ static ISD_Error sduCommand(s32 fd, u32 cmd, u32 cmdType, u32 respType, u32 arg,
static ISD_Error sduDatabuswidth(SDDev* dev, u32 buswidth);
static ISD_Error sduGetSCR(SDDev* dev, u32* data) NO_INLINE;
static ISD_Error sduGetOCR(SDDev* dev, u32* data);
extern ISD_Error ISD_ReadMultiBlockAsync(SDDev* dev, u32 offset, u8* cmdResp, u32 cmdRespSize, u32 param_5, u32 param_6);
extern ISD_Error ISD_WriteMultiBlockAsync(SDDev* dev, u32 offset, u8* cmdResp, u32 cmdRespSize, u32 param_5, u32 param_6);
ISD_Error ISD_GetCardSize(SDDev* dev, u32* param_2, u32* param_3, u32* param_4);
IOSError __sdCb(s32 result, void* arg) {
__sdCbArg* data = (__sdCbArg*)arg;
@@ -65,7 +73,7 @@ IOSError __sdCb(s32 result, void* arg) {
switch (data->unk_0x0C) {
case 4: {
if (result != 0) {
OSReport(" +++ SD RESET Failed: %d +++\n", result);
OSReport(lbl_81691748, result);
data->dev->SDDevRca = 0;
} else {
if (data->dev != NULL) {
@@ -91,9 +99,9 @@ IOSError __sdCb(s32 result, void* arg) {
}
if (data->SDSectorSize != NULL) {
iosFree(__sdHeapId, data->SDSectorSize);
iosFree(__sdHeapId[0], data->SDSectorSize);
}
iosFree(__sdHeapId, data);
iosFree(__sdHeapId[0], data);
return result;
}
@@ -101,7 +109,7 @@ IOSError __sdCb(s32 result, void* arg) {
ISD_Error ISD_GetHCRegister(SDDev* dev, u32 param_2, u32* param_3, u32 param_4) {
IOSError ret;
if (__sdHeapId < 0) {
if (__sdHeapId[0] < 0) {
return SD_ERROR_FATAL;
}
@@ -124,7 +132,7 @@ ISD_Error ISD_GetHCRegister(SDDev* dev, u32 param_2, u32* param_3, u32 param_4)
ISD_Error ISD_GetDeviceStatus(SDDev* dev, u32* param_2) {
IOSError ret = SD_ERROR_FATAL;
if (__sdHeapId >= 0 && param_2 != NULL) {
if (__sdHeapId[0] >= 0 && param_2 != NULL) {
OSLockMutex(&__reqMutex);
if (__sdReq != 0) {
@@ -160,7 +168,7 @@ static IOSError sduCommandv(s32 fd, u32 cmd, u32 cmdType, u32 respType, u32 arg,
writeCount = 2;
}
sdCmd = iosAlloc(__sdHeapId, OSRoundUp32B(SD_CMD_SIZE));
sdCmd = iosAlloc(__sdHeapId[0], OSRoundUp32B(SD_CMD_SIZE));
if (sdCmd == NULL) {
ret = IPC_RESULT_ALLOC_FAILED;
} else {
@@ -181,7 +189,7 @@ static IOSError sduCommandv(s32 fd, u32 cmd, u32 cmdType, u32 respType, u32 arg,
__sdVect[2].length = 0x10;
if (cb != NULL) {
__sdCbArg* data = iosAlloc(__sdHeapId, sizeof(__sdCbArg));
__sdCbArg* data = iosAlloc(__sdHeapId[0], sizeof(__sdCbArg));
if (data == NULL) {
ret = IPC_RESULT_ALLOC_FAILED;
} else {
@@ -202,7 +210,7 @@ static IOSError sduCommandv(s32 fd, u32 cmd, u32 cmdType, u32 respType, u32 arg,
}
if ((cb == NULL || ret != IPC_RESULT_OK) && sdCmd != NULL) {
iosFree(__sdHeapId, sdCmd);
iosFree(__sdHeapId[0], sdCmd);
}
return ret;
@@ -213,7 +221,7 @@ static ISD_Error sduCommand(s32 fd, u32 cmd, u32 cmdType, u32 respType, u32 arg,
ISD_Error ret;
u32* sdCmd;
sdCmd = iosAlloc(__sdHeapId, ROUNDUP(SD_CMD_SIZE, 64));
sdCmd = iosAlloc(__sdHeapId[0], ROUNDUP(SD_CMD_SIZE, 64));
if (sdCmd == NULL) {
ret = IPC_RESULT_ALLOC_FAILED;
} else {
@@ -228,7 +236,7 @@ static ISD_Error sduCommand(s32 fd, u32 cmd, u32 cmdType, u32 respType, u32 arg,
if (resp != NULL) {
if (cb != NULL) {
__sdCbArg* data = iosAlloc(__sdHeapId, sizeof(__sdCbArg));
__sdCbArg* data = iosAlloc(__sdHeapId[0], sizeof(__sdCbArg));
if (data == NULL) {
ret = IPC_RESULT_ALLOC_FAILED;
} else {
@@ -263,7 +271,7 @@ static ISD_Error sduCommand(s32 fd, u32 cmd, u32 cmdType, u32 respType, u32 arg,
}
if ((resp == NULL || cb == NULL || ret != 0) && sdCmd != NULL) {
iosFree(__sdHeapId, sdCmd);
iosFree(__sdHeapId[0], sdCmd);
}
return ret;
@@ -272,7 +280,7 @@ static ISD_Error sduCommand(s32 fd, u32 cmd, u32 cmdType, u32 respType, u32 arg,
ISD_Error ISD_ResetDevice(SDDev* dev) {
IOSError ret;
if (__sdHeapId < 0) {
if (__sdHeapId[0] < 0) {
return SD_ERROR_FATAL;
}
@@ -318,7 +326,7 @@ ISD_Error ISD_ProbeCard(u32 slot) {
ISD_Error ret;
u32 status;
if (__sdHeapId < 0) {
if (__sdHeapId[0] < 0) {
ret = SD_ERROR_FATAL;
} else {
ret = ISD_MountCard(slot, &pDev);
@@ -341,10 +349,194 @@ ISD_Error ISD_ProbeCard(u32 slot) {
return ret;
}
ISD_Error ISD_ReadBlock(SDDev* dev, u32 offset, u8* cmdResp, u32 cmdRespSize) {
return ISD_ReadMultiBlockAsync(dev, offset, cmdResp, cmdRespSize, 0, 0);
}
ISD_Error ISD_WriteBlock(SDDev* dev, u32 offset, u8* cmdResp, u32 cmdRespSize) {
return ISD_WriteMultiBlockAsync(dev, offset, cmdResp, cmdRespSize, 0, 0);
}
ISD_Error ISD_ReadMultiBlock(SDDev* dev, u32 offset, u8* cmdResp, u32 cmdRespSize) {
return ISD_ReadMultiBlockAsync(dev, offset, cmdResp, cmdRespSize, 0, 0);
}
ISD_Error ISD_WriteMultiBlock(SDDev* dev, u32 offset, u8* cmdResp, u32 cmdRespSize) {
return ISD_WriteMultiBlockAsync(dev, offset, cmdResp, cmdRespSize, 0, 0);
}
ISD_Error ISD_ReadMultiBlockAsync(SDDev* dev, u32 offset, u8* cmdResp, u32 cmdRespSize, u32 param_5, u32 param_6) {
ISD_Error ret;
u32 status;
if (__sdHeapId[0] < 0) {
return SD_ERROR_FATAL;
}
if (dev->SDState == 0) {
return SD_ERROR_FATAL;
}
if (dev->SDDevSize == 0) {
if (ISD_GetCardSize(dev, NULL, NULL, NULL) < IPC_RESULT_OK) {
goto out;
}
}
if (offset + cmdRespSize > dev->SDDevSize) {
return -4;
}
OSLockMutex(&__reqMutex);
if (__sdReq != 0) {
OSUnlockMutex(&__reqMutex);
return SD_ERROR_FATAL;
}
__sdReq = 1;
OSUnlockMutex(&__reqMutex);
if (dev->SDState == 2) {
u32 zero = 0;
u32 resp[4];
u32 resp2[4];
ret = sduCommand(dev->SDDevFd, 7, 3, 2, dev->SDDevRca, 0, 0, 0, zero, resp2, (void*)zero, (void*)zero);
if (ret == IPC_RESULT_OK) {
dev->SDState = 1;
ret = sduCommand(dev->SDDevFd, 0x10, 3, 1, 0x200, 0, 0, 0, zero, resp, (void*)zero, (void*)zero);
if (ret == IPC_RESULT_OK) {
ret = sduDatabuswidth(dev, 4);
if (ret == IPC_RESULT_OK) {
{
IOSFd fd = dev->SDDevFd;
u32* cmdBuffer = __sdCmdBuffer;
cmdBuffer[0] = 1;
ret = IOS_Ioctl(fd, 6, __sdCmdBuffer, 4, NULL, 0);
}
if (ret != IPC_RESULT_OK) {
ret = SD_ERROR_FATAL;
}
}
}
}
if (ret != IPC_RESULT_OK) {
__sdReq = 0;
goto out;
}
}
ret = IOS_Ioctl(dev->SDDevFd, 11, NULL, 0, &status, 4);
if (ret >= IPC_RESULT_OK) {
if ((status & 0x100000) == 0) {
offset <<= 9;
}
DCInvalidateRange(cmdResp, cmdRespSize << 9);
ret = sduCommandv(dev->SDDevFd, 0x12, 3, 1, offset, (u32)cmdResp, cmdRespSize, 0x200, 1, __sdResp2, (void*)param_5, (void*)param_6);
if (ret != IPC_RESULT_OK) {
__sdReq = 0;
}
if (param_5 == 0) {
__sdReq = 0;
}
}
out:
return ret;
}
ISD_Error ISD_WriteMultiBlockAsync(SDDev* dev, u32 offset, u8* cmdResp, u32 cmdRespSize, u32 param_5, u32 param_6) {
ISD_Error ret;
u32 status;
if (__sdHeapId[0] < 0) {
return SD_ERROR_FATAL;
}
if (dev->SDState == 0) {
return SD_ERROR_FATAL;
}
if (dev->SDDevSize == 0) {
if (ISD_GetCardSize(dev, NULL, NULL, NULL) < IPC_RESULT_OK) {
goto out;
}
}
if (offset + cmdRespSize > dev->SDDevSize) {
return -4;
}
OSLockMutex(&__reqMutex);
if (__sdReq != 0) {
OSUnlockMutex(&__reqMutex);
return SD_ERROR_FATAL;
}
__sdReq = 1;
OSUnlockMutex(&__reqMutex);
if (dev->SDState == 2) {
u32 zero = 0;
u32 resp[4];
u32 resp2[4];
ret = sduCommand(dev->SDDevFd, 7, 3, 2, dev->SDDevRca, 0, 0, 0, zero, resp2, (void*)zero, (void*)zero);
if (ret == IPC_RESULT_OK) {
dev->SDState = 1;
ret = sduCommand(dev->SDDevFd, 0x10, 3, 1, 0x200, 0, 0, 0, zero, resp, (void*)zero, (void*)zero);
if (ret == IPC_RESULT_OK) {
ret = sduDatabuswidth(dev, 4);
if (ret == IPC_RESULT_OK) {
{
IOSFd fd = dev->SDDevFd;
u32* cmdBuffer = __sdCmdBuffer;
cmdBuffer[0] = 1;
ret = IOS_Ioctl(fd, 6, __sdCmdBuffer, 4, NULL, 0);
}
if (ret != IPC_RESULT_OK) {
ret = SD_ERROR_FATAL;
}
}
}
}
if (ret != IPC_RESULT_OK) {
__sdReq = 0;
goto out;
}
}
ret = IOS_Ioctl(dev->SDDevFd, 11, NULL, 0, &status, 4);
if (ret >= IPC_RESULT_OK) {
if ((status & 0x100000) == 0) {
offset <<= 9;
}
DCFlushRange(cmdResp, cmdRespSize << 9);
ret = sduCommand(dev->SDDevFd, 0x19, 3, 1, offset, (u32)cmdResp, cmdRespSize, 0x200, 1, __sdResp2, (void*)param_5, (void*)param_6);
if (ret != IPC_RESULT_OK) {
__sdReq = 0;
}
if (param_5 == 0) {
__sdReq = 0;
}
}
out:
return ret;
}
ISD_Error ISD_MountCard(u32 slot, SDDev** dev) {
IOSError ret = IPC_RESULT_OK;
if (__sdHeapId < 0) {
if (__sdHeapId[0] < 0) {
ret = SD_ERROR_FATAL;
goto out;
}
@@ -376,46 +568,60 @@ ISD_Error ISD_UnmountCard(SDDev* dev) {
dev->SDDevFd = -1;
}
ISD_Error sduDatabuswidth(SDDev* dev, u32 buswidth) {
u32 resp[4];
u32 cmdArg = buswidth == 4 ? 2 : 0;
u32 hcReg;
ISD_Error ret;
ISD_Error ISD_InitCard() {
static u8* lo;
char* paths = lbl_81691748;
ISD_Error ret = SD_ERROR_SUCCESS;
BOOL enabled;
ret = sduCommand(dev->SDDevFd, 0x37, 3, 1, dev->SDDevRca, 0, 0, 0, 0, resp, NULL, NULL);
if (ret != SD_ERROR_SUCCESS) {
return ret;
enabled = OSDisableInterrupts();
if (__sdHeapId[0] >= 0) {
OSRestoreInterrupts(enabled);
goto out;
}
OSRestoreInterrupts(enabled);
__sdReq = 0;
OSInitMutex(&__reqMutex);
lo = IPCGetBufferLo();
IPCGetBufferHi();
__sdHeapId[0] = iosCreateHeap(lo, 0x800);
if (__sdHeapId[0] < 0) {
ret = IPC_RESULT_ALLOC_FAILED;
goto out;
}
ret = sduCommand(dev->SDDevFd, 6, 3, 1, cmdArg, 0, 0, 0, 0, resp, NULL, NULL);
if (ret != SD_ERROR_SUCCESS) {
return ret;
if ((__sdCmdBuffer = iosAlloc(__sdHeapId[0], 0x20)) == 0) {
ret = IPC_RESULT_ALLOC_FAILED;
goto out;
}
ret = ISD_GetHCRegister(dev, 0x28, &hcReg, 1);
if (ret != SD_ERROR_SUCCESS) {
return ret;
if ((__sdResp = iosAlloc(__sdHeapId[0], 0x20)) == 0) {
ret = IPC_RESULT_ALLOC_FAILED;
goto out;
}
if (cmdArg != 0) {
hcReg |= 2;
} else {
hcReg &= ~0x02;
if ((__sdResp2 = iosAlloc(__sdHeapId[0], 0x20)) == 0) {
ret = IPC_RESULT_ALLOC_FAILED;
goto out;
}
if (__sdHeapId < 0) {
return SD_ERROR_FATAL;
if ((__sdReg = iosAlloc(__sdHeapId[0], 0x20)) == 0) {
ret = IPC_RESULT_ALLOC_FAILED;
goto out;
}
__sdReg[0] = 0x28;
__sdReg[3] = 1;
__sdReg[4] = hcReg;
ret = IOS_Ioctl(dev->SDDevFd, 1, __sdReg, 0x18, NULL, 0);
if (ret != IPC_RESULT_OK) {
ret = SD_ERROR_FATAL;
if ((__sdVect = iosAlloc(__sdHeapId[0], 0x60)) == 0) {
ret = IPC_RESULT_ALLOC_FAILED;
goto out;
}
IPCSetBufferLo((void*)((u32)lo + 0x800));
strcpy(__sdPaths[0], paths + 0x20);
strcpy(__sdPaths[1], paths + 0x30);
strcpy(__sdPaths[2], paths + 0x40);
out:
return ret;
}
@@ -423,7 +629,7 @@ ISD_Error ISD_ReadCardRegister(SDDev* dev, u32 cmd, u32* cmdResp, u32 cmdRespSiz
ISD_Error ret;
u32 cmdArg = dev->SDDevRca;
if (__sdHeapId < 0) {
if (__sdHeapId[0] < 0) {
ret = SD_ERROR_FATAL;
goto out;
}
@@ -502,6 +708,49 @@ out:
return ret;
}
ISD_Error sduDatabuswidth(SDDev* dev, u32 buswidth) {
u32 resp[4];
u32 cmdArg = buswidth == 4 ? 2 : 0;
u32 hcReg;
ISD_Error ret;
ret = sduCommand(dev->SDDevFd, 0x37, 3, 1, dev->SDDevRca, 0, 0, 0, 0, resp, NULL, NULL);
if (ret != SD_ERROR_SUCCESS) {
return ret;
}
ret = sduCommand(dev->SDDevFd, 6, 3, 1, cmdArg, 0, 0, 0, 0, resp, NULL, NULL);
if (ret != SD_ERROR_SUCCESS) {
return ret;
}
ret = ISD_GetHCRegister(dev, 0x28, &hcReg, 1);
if (ret != SD_ERROR_SUCCESS) {
return ret;
}
if (cmdArg != 0) {
hcReg |= 2;
} else {
hcReg &= ~0x02;
}
if (__sdHeapId[0] < 0) {
return SD_ERROR_FATAL;
}
__sdReg[0] = 0x28;
__sdReg[3] = 1;
__sdReg[4] = hcReg;
ret = IOS_Ioctl(dev->SDDevFd, 1, __sdReg, 0x18, NULL, 0);
if (ret != IPC_RESULT_OK) {
ret = SD_ERROR_FATAL;
}
return ret;
}
static ISD_Error sduGetSCR(SDDev* dev, u32* data) {
ISD_Error ret = SD_ERROR_FATAL;
u32 resp[4];
@@ -532,6 +781,109 @@ static ISD_Error sduGetOCR(SDDev* dev, u32* data) {
return ret;
}
#ifdef __MWERKS__
asm ISD_Error ISD_GetCardSize(register SDDev* dev, register u32* param_2, register u32* param_3, register u32* param_4) {
nofralloc
stwu r1, -0x30(r1)
mflr r0
stw r0, 0x34(r1)
stw r31, 0x2c(r1)
mr r31, r6
stw r30, 0x28(r1)
mr r30, r5
li r5, 0x10
stw r29, 0x24(r1)
mr r29, r4
li r4, 0
stw r28, 0x20(r1)
mr r28, r3
addi r3, r1, 8
bl memset
mr r3, r28
addi r5, r1, 8
li r4, 9
li r6, 0x10
bl ISD_ReadCardRegister
cmpwi r3, 0
beq ISD_GetCardSize_success
b ISD_GetCardSize_return
ISD_GetCardSize_success:
lwz r0, 0x14(r1)
rlwinm. r0, r0, 0xa, 0x1e, 0x1f
beq ISD_GetCardSize_standard
lwz r0, 0xc(r1)
li r5, 0x80
rlwinm r3, r0, 0x18, 0xa, 0x1f
addi r0, r3, 1
slwi r3, r0, 0xa
rlwinm r0, r0, 3, 7, 0x1c
b ISD_GetCardSize_store
ISD_GetCardSize_standard:
lwz r3, 0x10(r1)
li r0, 9
lwz r7, 0xc(r1)
rlwinm r4, r3, 0x18, 0x1c, 0x1f
cmplwi r4, 9
srwi r6, r7, 0x16
rlwimi r6, r3, 0xa, 0x14, 0x15
rlwinm r3, r7, 0x19, 0x1d, 0x1f
blt ISD_GetCardSize_clamp_high
mr r0, r4
ISD_GetCardSize_clamp_high:
cmplwi r0, 0xb
li r4, 0xb
bgt ISD_GetCardSize_clamp_done
mr r4, r0
ISD_GetCardSize_clamp_done:
addi r0, r3, 2
li r5, 1
addi r3, r6, 1
addi r4, r4, -9
slw r0, r5, r0
lwz r6, 8(r1)
mullw r0, r3, r0
slw r3, r5, r4
srwi r5, r6, 0x1f
rlwimi r5, r7, 1, 0x19, 0x1e
mullw r3, r3, r0
addi r5, r5, 1
slwi r0, r3, 9
divwu r0, r0, r5
srw r0, r0, r4
ISD_GetCardSize_store:
cmpwi r29, 0
stw r5, 0x18(r28)
stw r0, 0x1c(r28)
stw r3, 0x20(r28)
beq ISD_GetCardSize_no_param2
stw r3, 0(r29)
ISD_GetCardSize_no_param2:
cmpwi r30, 0
beq ISD_GetCardSize_no_param3
stw r3, 0(r30)
ISD_GetCardSize_no_param3:
cmpwi r31, 0
beq ISD_GetCardSize_success_return
li r0, 0x200
stw r0, 0(r31)
ISD_GetCardSize_success_return:
li r3, 0
ISD_GetCardSize_return:
lwz r0, 0x34(r1)
lwz r31, 0x2c(r1)
lwz r30, 0x28(r1)
lwz r29, 0x24(r1)
lwz r28, 0x20(r1)
mtlr r0
addi r1, r1, 0x30
blr
}
#else
ISD_Error ISD_GetCardSize(SDDev* dev, u32* param_2, u32* param_3, u32* param_4) {
ISD_Error ret;
u32 out0;
@@ -575,3 +927,38 @@ ISD_Error ISD_GetCardSize(SDDev* dev, u32* param_2, u32* param_3, u32* param_4)
return SD_ERROR_SUCCESS;
}
#endif
ISD_Error ISD_RegisterDeviceIntrHandler(SDDev* dev, SDDevIntrCallback intCB, void* arg) {
u32 state;
if (__sdHeapId[0] < 0) {
return SD_ERROR_FATAL;
}
if (intCB == NULL) {
return SD_ERROR_FATAL;
}
if (arg != NULL) {
state = *(u32*)arg;
} else {
return IPC_RESULT_INVALID;
}
if (state != 2 && state != 1) {
return IPC_RESULT_INVALID;
}
return sduCommand(dev->SDDevFd, 0x40, 0, 0, state, 0, 0, 0, 0, __sdResp2, intCB, arg);
}
ISD_Error ISD_UnregisterDeviceIntrHandler(SDDev* dev) {
u32 resp[4] ALIGN32;
if (__sdHeapId[0] < 0) {
return SD_ERROR_FATAL;
}
return sduCommand(dev->SDDevFd, 0x41, 0, 0, 0, 0, 0, 0, 0, resp, NULL, NULL);
}

View File

@@ -28,9 +28,10 @@
#define DPD_CONFIG2_SIZE 2
#define SPK_CONFIG_SIZE 7
SDKDefineVersion(WPAD, "Apr 20 2010", "11:20:55");
char lbl_81687720[] = "<< RVL_SDK - WPAD \trelease build: Apr 20 2010 11:20:55 (0x4199_60831) >>";
const char* __WPADVersion = lbl_81687720;
WPADCB _wpd[WPAD_MAX_CONTROLLERS];
WPADStorage _wpd;
WPADCB* _wpdcb[WPAD_MAX_CONTROLLERS];
u8 __WPADiManageHandlerStack[0x1000] ALIGN32;
@@ -615,6 +616,540 @@ static void __reconnect(BOOL exec) {
WUDSetHidRecvCallback(NULL);
WUDShutdown(exec);
}
#ifdef __MWERKS__
char lbl_81687810[0x58] = "Reconnect Start!!\n\0\0\0\0\0\0"
"Check the update of WiFi using channel\n\0"
"WiFi uses channel = %d\n";
extern void _savegpr_19();
extern void _restgpr_19();
static asm void WPADiManageHandler(OSAlarm* pAlarm, OSContext* pContext) {
nofralloc
stwu r1, -0x160(r1)
mflr r0
stw r0, 0x164(r1)
addi r11, r1, 0x160
bl _savegpr_19
lis r28, lbl_81687720@ha
addi r28, r28, lbl_81687720@l
bl WUDGetStatus
cmpwi r3, 0x3
beq WPADiManageHandler_8AC8
cmpwi r3, 0x2
bne WPADiManageHandler_91D8
lwz r0, _initialized(r0)
cmpwi r0, 0x0
bne WPADiManageHandler_91D8
li r0, 0x1
lis r3, WPADiConnCallback@ha
stw r0, _initialized(r0)
addi r3, r3, WPADiConnCallback@l
bl WUDSetHidConnCallback
lis r3, WPADiRecvCallback@ha
addi r3, r3, WPADiRecvCallback@l
bl WUDSetHidRecvCallback
li r0, 0x32
stw r0, _recCnt(r0)
b WPADiManageHandler_91D8
WPADiManageHandler_8AC8:
lwz r4, _recCnt(r0)
lwz r19, _recFlag(r0)
cntlzw r3, r4
subi r0, r4, 0x1
extrwi r3, r3, 1, 26
cmpwi r19, 0x0
neg r3, r3
andc r0, r0, r3
stw r0, _recCnt(r0)
blt WPADiManageHandler_8B28
cmpwi r0, 0x0
bne WPADiManageHandler_91D8
addi r3, r28, 0xf0
crclr 4*cr1+eq
bl DEBUGPrint
bl BTA_DmSendHciReset
lis r3, _managerAlarm@ha
addi r3, r3, _managerAlarm@l
bl OSCancelAlarm
li r3, 0x0
bl WUDSetHidRecvCallback
mr r3, r19
bl WUDShutdown
b WPADiManageHandler_91D8
WPADiManageHandler_8B28:
lis r24, _wpdcb@ha
li r22, 0x0
addi r24, r24, _wpdcb@l
la r25, _extCnt
la r23, _rumbleCnt
li r29, 0x0
li r30, 0x10
li r31, 0x1
WPADiManageHandler_8B48:
lbz r0, 0x0(r25)
li r21, 0x0
cmplwi r0, 0x5
bne WPADiManageHandler_8D20
lwz r26, 0x0(r24)
lwz r0, 0x8d8(r26)
cmpwi r0, 0x0
beq WPADiManageHandler_8D10
bl OSDisableInterrupts
mr r27, r3
bl OSDisableInterrupts
lbz r4, 0x5ec(r26)
lbz r0, 0x5ed(r26)
subf r0, r4, r0
extsb. r19, r0
bge WPADiManageHandler_8B94
lwz r0, 0x5f4(r26)
add r0, r19, r0
extsb r19, r0
WPADiManageHandler_8B94:
bl OSRestoreInterrupts
cmpwi r19, 0x0
bne WPADiManageHandler_8BB0
mr r3, r27
bl OSRestoreInterrupts
li r0, 0x0
b WPADiManageHandler_8BDC
WPADiManageHandler_8BB0:
lbz r0, 0x5ec(r26)
addi r3, r1, 0xc8
lwz r4, 0x5f0(r26)
li r5, 0x30
extsb r0, r0
mulli r0, r0, 0x30
add r4, r4, r0
bl memcpy
mr r3, r27
bl OSRestoreInterrupts
li r0, 0x1
WPADiManageHandler_8BDC:
cmpwi r0, 0x0
beq WPADiManageHandler_8D10
lwz r0, 0xc8(r1)
cmplwi r0, 0x12
beq WPADiManageHandler_8BFC
lwz r0, 0x840(r26)
cmpwi r0, 0x0
beq WPADiManageHandler_8D10
WPADiManageHandler_8BFC:
lwz r21, 0xc8(r1)
mr r3, r22
lwz r20, 0xcc(r1)
addi r4, r1, 0xf8
lwz r19, 0xd0(r1)
lwz r12, 0xd4(r1)
lwz r11, 0xd8(r1)
lwz r10, 0xdc(r1)
lwz r9, 0xe0(r1)
lwz r8, 0xe4(r1)
lwz r7, 0xe8(r1)
lwz r6, 0xec(r1)
lwz r5, 0xf0(r1)
lwz r0, 0xf4(r1)
stw r21, 0xf8(r1)
stw r20, 0xfc(r1)
stw r19, 0x100(r1)
stw r12, 0x104(r1)
stw r11, 0x108(r1)
stw r10, 0x10c(r1)
stw r9, 0x110(r1)
stw r8, 0x114(r1)
stw r7, 0x118(r1)
stw r6, 0x11c(r1)
stw r5, 0x120(r1)
stw r0, 0x124(r1)
bl WPADiSendData
cmpwi r3, 0x0
bne WPADiManageHandler_8D10
bl OSDisableInterrupts
mr r27, r3
bl OSDisableInterrupts
lbz r4, 0x5ec(r26)
lbz r0, 0x5ed(r26)
subf r0, r4, r0
extsb. r19, r0
bge WPADiManageHandler_8C9C
lwz r0, 0x5f4(r26)
add r0, r19, r0
extsb r19, r0
WPADiManageHandler_8C9C:
bl OSRestoreInterrupts
cmpwi r19, 0x0
bne WPADiManageHandler_8CB4
mr r3, r27
bl OSRestoreInterrupts
b WPADiManageHandler_8D08
WPADiManageHandler_8CB4:
lbz r0, 0x5ec(r26)
li r4, 0x0
lwz r3, 0x5f0(r26)
li r5, 0x30
extsb r0, r0
mulli r0, r0, 0x30
add r3, r3, r0
bl memset
lbz r0, 0x5ec(r26)
mr r3, r27
lwz r4, 0x5f4(r26)
extsb r6, r0
subi r4, r4, 0x1
subf r5, r4, r6
addi r0, r6, 0x1
subf r4, r6, r4
nor r4, r5, r4
srawi r4, r4, 31
andc r0, r0, r4
stb r0, 0x5ec(r26)
bl OSRestoreInterrupts
WPADiManageHandler_8D08:
li r21, 0x1
b WPADiManageHandler_8D14
WPADiManageHandler_8D10:
li r21, 0x0
WPADiManageHandler_8D14:
cmpwi r21, 0x0
beq WPADiManageHandler_8D20
stb r29, 0x0(r25)
WPADiManageHandler_8D20:
cmpwi r21, 0x0
bne WPADiManageHandler_8ED0
lwz r27, 0x0(r24)
lwz r0, 0x8d8(r27)
cmpwi r0, 0x0
beq WPADiManageHandler_8EC8
bl OSDisableInterrupts
mr r26, r3
bl OSDisableInterrupts
lbz r4, 0x160(r27)
lbz r0, 0x161(r27)
subf r0, r4, r0
extsb. r19, r0
bge WPADiManageHandler_8D64
lwz r0, 0x168(r27)
add r0, r19, r0
extsb r19, r0
WPADiManageHandler_8D64:
bl OSRestoreInterrupts
cmpwi r19, 0x0
bne WPADiManageHandler_8D80
mr r3, r26
bl OSRestoreInterrupts
li r0, 0x0
b WPADiManageHandler_8DAC
WPADiManageHandler_8D80:
lbz r0, 0x160(r27)
addi r3, r1, 0x68
lwz r4, 0x164(r27)
li r5, 0x30
extsb r0, r0
mulli r0, r0, 0x30
add r4, r4, r0
bl memcpy
mr r3, r26
bl OSRestoreInterrupts
li r0, 0x1
WPADiManageHandler_8DAC:
cmpwi r0, 0x0
beq WPADiManageHandler_8EC8
lwz r19, 0x68(r1)
mr r3, r22
lwz r20, 0x6c(r1)
addi r4, r1, 0x98
lwz r26, 0x70(r1)
lwz r12, 0x74(r1)
lwz r11, 0x78(r1)
lwz r10, 0x7c(r1)
lwz r9, 0x80(r1)
lwz r8, 0x84(r1)
lwz r7, 0x88(r1)
lwz r6, 0x8c(r1)
lwz r5, 0x90(r1)
lwz r0, 0x94(r1)
stw r19, 0x98(r1)
stw r20, 0x9c(r1)
stw r26, 0xa0(r1)
stw r12, 0xa4(r1)
stw r11, 0xa8(r1)
stw r10, 0xac(r1)
stw r9, 0xb0(r1)
stw r8, 0xb4(r1)
stw r7, 0xb8(r1)
stw r6, 0xbc(r1)
stw r5, 0xc0(r1)
stw r0, 0xc4(r1)
bl WPADiSendData
cmpwi r3, 0x0
bne WPADiManageHandler_8EC8
bl OSDisableInterrupts
mr r26, r3
bl OSDisableInterrupts
lbz r4, 0x160(r27)
lbz r0, 0x161(r27)
subf r0, r4, r0
extsb. r19, r0
bge WPADiManageHandler_8E54
lwz r0, 0x168(r27)
add r0, r19, r0
extsb r19, r0
WPADiManageHandler_8E54:
bl OSRestoreInterrupts
cmpwi r19, 0x0
bne WPADiManageHandler_8E6C
mr r3, r26
bl OSRestoreInterrupts
b WPADiManageHandler_8EC0
WPADiManageHandler_8E6C:
lbz r0, 0x160(r27)
li r4, 0x0
lwz r3, 0x164(r27)
li r5, 0x30
extsb r0, r0
mulli r0, r0, 0x30
add r3, r3, r0
bl memset
lbz r0, 0x160(r27)
mr r3, r26
lwz r4, 0x168(r27)
extsb r6, r0
subi r4, r4, 0x1
subf r5, r4, r6
addi r0, r6, 0x1
subf r4, r6, r4
nor r4, r5, r4
srawi r4, r4, 31
andc r0, r0, r4
stb r0, 0x160(r27)
bl OSRestoreInterrupts
WPADiManageHandler_8EC0:
li r0, 0x1
b WPADiManageHandler_8ECC
WPADiManageHandler_8EC8:
li r0, 0x0
WPADiManageHandler_8ECC:
or r21, r21, r0
WPADiManageHandler_8ED0:
lwz r20, 0x0(r24)
lwz r0, 0x8bc(r20)
cmpwi r0, -0x1
beq WPADiManageHandler_8FD0
cmpwi r21, 0x1
beq WPADiManageHandler_8F18
bl OSDisableInterrupts
lbz r4, 0x160(r20)
lbz r0, 0x161(r20)
subf r0, r4, r0
extsb. r19, r0
bge WPADiManageHandler_8F0C
lwz r0, 0x168(r20)
add r0, r19, r0
extsb r19, r0
WPADiManageHandler_8F0C:
bl OSRestoreInterrupts
cmpwi r19, 0x0
ble WPADiManageHandler_8F24
WPADiManageHandler_8F18:
lwz r3, 0x0(r24)
stw r29, 0x8d0(r3)
b WPADiManageHandler_8FAC
WPADiManageHandler_8F24:
lbz r0, 0x0(r23)
cmplwi r0, 0x5
bne WPADiManageHandler_8FAC
sth r31, 0x22(r1)
mr r3, r22
lwz r5, 0x0(r24)
addi r4, r1, 0x38
stb r29, 0xc(r1)
lwz r12, 0x10(r1)
stw r29, 0x8d0(r5)
lwz r21, 0xc(r1)
lwz r11, 0x14(r1)
lwz r10, 0x18(r1)
lwz r9, 0x1c(r1)
lwz r8, 0x20(r1)
lwz r7, 0x24(r1)
lwz r6, 0x28(r1)
lwz r5, 0x2c(r1)
lwz r0, 0x30(r1)
stw r30, 0x8(r1)
stw r29, 0x34(r1)
stw r30, 0x38(r1)
stw r21, 0x3c(r1)
stw r12, 0x40(r1)
stw r11, 0x44(r1)
stw r10, 0x48(r1)
stw r9, 0x4c(r1)
stw r8, 0x50(r1)
stw r7, 0x54(r1)
stw r6, 0x58(r1)
stw r5, 0x5c(r1)
stw r0, 0x60(r1)
stw r29, 0x64(r1)
bl __SendData
WPADiManageHandler_8FAC:
lwz r3, 0x0(r24)
lwz r0, 0x8d0(r3)
cmpwi r0, 0x0
beq WPADiManageHandler_8FC8
lbz r3, 0x0(r23)
addi r0, r3, 0x1
b WPADiManageHandler_8FCC
WPADiManageHandler_8FC8:
li r0, 0x0
WPADiManageHandler_8FCC:
stb r0, 0x0(r23)
WPADiManageHandler_8FD0:
lbz r0, _checkCnt(r0)
cmplwi r0, 0x5
bne WPADiManageHandler_8FE4
mr r3, r22
bl WPADiCheckContInputs
WPADiManageHandler_8FE4:
lhz r0, _senseCnt(r0)
cmplwi r0, 0xa
bne WPADiManageHandler_8FF8
mr r3, r22
bl WPADiRadioSensitivity
WPADiManageHandler_8FF8:
lbz r3, 0x0(r25)
cmplwi r3, 0x5
addi r0, r3, 0x1
bne WPADiManageHandler_900C
mr r0, r3
WPADiManageHandler_900C:
addi r22, r22, 0x1
stb r0, 0x0(r25)
cmpwi r22, 0x4
addi r25, r25, 0x1
addi r24, r24, 0x4
addi r23, r23, 0x1
blt WPADiManageHandler_8B48
lhz r0, _afhCnt(r0)
cmplwi r0, 0xea60
bne WPADiManageHandler_9090
lis r21, 0x8000
li r4, 0x1
addi r3, r21, 0x31a2
bl DCInvalidateRange
addi r3, r28, 0x108
crclr 4*cr1+eq
bl DEBUGPrint
lbz r3, _afhChannel(r0)
lbz r0, 0x31a2(r21)
extsb r3, r3
cmpw r3, r0
beq WPADiManageHandler_9090
bl OSDisableInterrupts
lbz r0, 0x31a2(r21)
stb r0, _afhChannel(r0)
bl OSRestoreInterrupts
lbz r4, 0x31a2(r21)
addi r3, r28, 0x130
crclr 4*cr1+eq
bl DEBUGPrint
lbz r0, _afhChannel(r0)
extsb r3, r0
bl WUDSetDisableChannel
WPADiManageHandler_9090:
lhz r6, _senseCnt(r0)
lis r3, 0x1
subi r0, r3, 0x15a0
lbz r9, _checkCnt(r0)
subi r4, r6, 0xa
subfic r3, r6, 0xa
nor r3, r4, r3
lhz r10, _afhCnt(r0)
srawi r8, r3, 31
addi r7, r6, 0x1
clrlwi r0, r0, 16
subi r4, r9, 0x5
subfic r3, r9, 0x5
andc r7, r7, r8
nor r5, r4, r3
subf r4, r0, r10
subf r3, r10, r0
lbz r0, _scFlush(r0)
srawi r6, r5, 31
addi r5, r9, 0x1
nor r4, r4, r3
addi r3, r10, 0x1
srawi r4, r4, 31
andc r5, r5, r6
andc r3, r3, r4
cmpwi r0, 0x0
sth r7, _senseCnt(r0)
stb r5, _checkCnt(r0)
sth r3, _afhCnt(r0)
beq WPADiManageHandler_9138
bl SCCheckStatus
cmpwi r3, 0x0
bne WPADiManageHandler_9138
lis r3, _scArray@ha
addi r3, r3, _scArray@l
bl SCSetBtDeviceInfoArray
cmpwi r3, 0x1
bne WPADiManageHandler_9138
li r3, 0x0
bl SCFlushAsync
li r0, 0x0
stb r0, _scFlush(r0)
WPADiManageHandler_9138:
lbz r0, _scSetting(r0)
cmpwi r0, 0x0
beq WPADiManageHandler_91D4
bl SCCheckStatus
cmpwi r3, 0x0
bne WPADiManageHandler_91D4
bl SCGetBtDpdSensibility
clrlwi r0, r3, 24
cmplwi r0, 0x1
bge WPADiManageHandler_9164
li r0, 0x1
WPADiManageHandler_9164:
cmplwi r0, 0x5
ble WPADiManageHandler_9170
li r0, 0x5
WPADiManageHandler_9170:
stb r0, _dpdSensitivity(r0)
bl SCGetWpadSensorBarPosition
clrlwi r3, r3, 24
subi r0, r3, 0x1
cntlzw r0, r0
extrwi r0, r0, 8, 19
stb r0, _sensorBarPos(r0)
bl SCGetWpadMotorMode
clrlwi r3, r3, 24
subi r0, r3, 0x1
cntlzw r0, r0
srwi r0, r0, 5
stw r0, _rumble(r0)
bl SCGetWpadSpeakerVolume
clrlwi. r0, r3, 24
mr r4, r3
bne WPADiManageHandler_91B8
li r4, 0x0
WPADiManageHandler_91B8:
clrlwi r0, r3, 24
cmplwi r0, 0x7f
blt WPADiManageHandler_91C8
li r4, 0x7f
WPADiManageHandler_91C8:
li r0, 0x0
stb r4, _speakerVolume(r0)
stb r0, _scSetting(r0)
WPADiManageHandler_91D4:
bl BTA_HhGetAclQueueInfo
WPADiManageHandler_91D8:
addi r11, r1, 0x160
bl _restgpr_19
lwz r0, 0x164(r1)
mtlr r0
addi r1, r1, 0x160
blr
}
#else
static void WPADiManageHandler(OSAlarm* pAlarm, OSContext* pContext) {
s32 status = WPADGetStatus();
s32 chan;
@@ -682,6 +1217,8 @@ static void WPADiManageHandler(OSAlarm* pAlarm, OSContext* pContext) {
BTA_HhGetAclQueueInfo();
}
#endif
static void WPADiManageHandler0(OSAlarm* pAlarm, OSContext* pContext) {
OSSwitchFiberEx((u32)pAlarm, (u32)pContext, 0, 0, WPADiManageHandler, __WPADiManageHandlerStack + sizeof(__WPADiManageHandlerStack));
}
@@ -801,12 +1338,12 @@ void WPADiInitSub() {
DEBUGPrint("WPADInit()\n");
for (chan = 0; chan < WPAD_MAX_CONTROLLERS; chan++) {
_wpdcb[chan] = &_wpd[chan];
_wpdcb[chan] = &_wpd.controllers[chan];
_chan_active_state[chan] = FALSE;
_wpdcb[chan]->connectCB = NULL;
__ClearControlBlock(chan);
OSInitThreadQueue(&_wpd[chan].threadQueue);
OSInitThreadQueue(&_wpd.controllers[chan].threadQueue);
_extCnt[chan] = 0;
_rumbleCnt[chan] = 0;

View File

@@ -27,7 +27,7 @@ enum {
/* RECORD POOL */
CDBErr CDBRecordPoolInit(void* work);
void CDBRecordPoolInit(void* work);
/* RECORD */
@@ -46,7 +46,7 @@ void CDBRecordKeyGetKeyStr(CDBRecordKey* recordKey, char* keyString);
void CDBRecordKeySetSerialNumber(CDBRecordKey* recordKey, int serialNum);
void CDBRecordKeyCopy(CDBRecordKey* recordKey, CDBRecordKey* newRecordKey);
void CDBRecordKeyCopy(CDBRecordKey* recordKey, const CDBRecordKey* newRecordKey);
BOOL CDBRecordKeyCompare(CDBRecordKey* recordKey1, CDBRecordKey* recordKey2);
int CDBRecordKeyCompareByDate(CDBRecordKey* recordKey1, CDBRecordKey* recordKey2);

View File

@@ -16,7 +16,7 @@ int STD_strnlen(const char* str, u32 len);
int Util_xtoi(char ch);
void* Mail_memcpy(void* dest, void* src, u32 len);
void* Mail_memcpy(void* dest, const void* src, u32 len);
void* Mail_memset(void* dest, int fill, u32 count);
int Mail_strlen(const char* str);

View File

@@ -8,7 +8,8 @@
extern CDBErr GenCDBIdNumber(u32* cdbIDNum);
static char CDB_ATTR_MAGIC[] = "CDBFILE";
static const u8 CDB_ATTR_VERSION = 2;
static const u32 CDB_ATTR_VERSION = 0x02000000;
static const u32 CDB_ATTR_VERSION_PADDING = 0;
static u32 s_seed = 0;
@@ -76,7 +77,7 @@ CDBErr CDBAttrCreateOnNAND(CDBAttr* attr, const char* desc, u32 lastModifiedDate
CDBAttrInit(attr);
memcpy(&attr->buf.magic, CDB_ATTR_MAGIC, sizeof(CDB_ATTR_MAGIC) - 1);
memcpy(&attr->buf.version, &CDB_ATTR_VERSION, sizeof(CDB_ATTR_VERSION));
memcpy(&attr->buf.version, &CDB_ATTR_VERSION, sizeof(u8));
descStrLen = strlen(desc) + 1;

View File

@@ -324,25 +324,37 @@ CDBErr CDBConvKeyToFullPath(CDBRecordKey* recordKey, char* fullPath) {
}
void CDBConvKeyStrToFullPath_(char* keyString, char* fullPath, CDBLocation location, u64* wiiId) {
char fileNameStr[8];
char yearStr[8];
char monthStr[8];
char dayStr[8];
char hourStr[8];
char minStr[8];
char codeStr[8];
char typeStr[8];
char serialNumStr[8];
char fileNameStr[8];
char typeStr[5];
CDBDate epoch;
int year;
int month;
int day;
int hour;
int min;
char serialNumStr[4];
char fileSerial[4];
CDBDate fileEpoch;
char fileEpochStr[40];
CDBConvKeyStrToEpochValue(keyString, &epoch);
{
union {
char storage[20];
struct {
char prefix[8];
char value[12];
} epoch;
} epochBuffer;
strncpy(epochBuffer.epoch.value, CDBKeyStrEpoch(keyString), CDB_KEYSTR_EPOCH_SIZE);
epochBuffer.epoch.value[CDB_KEYSTR_EPOCH_SIZE] = 0;
sscanf(epochBuffer.epoch.value, "%ul", &epoch);
}
CDBConvEpochValueToDate(epoch, &year, &month, &day, &hour, &min, NULL);
CDBConvYearValueToYearStr(yearStr, year);
@@ -354,7 +366,12 @@ void CDBConvKeyStrToFullPath_(char* keyString, char* fullPath, CDBLocation locat
CDBConvKeyStrToCode(keyString, codeStr);
CDBConvKeyStrToSerialNumber(keyString, serialNumStr);
CDBConvKeyStrToType(keyString, typeStr);
CDBConvKeyStrToFileName(keyString, fileNameStr);
strncpy(fileEpochStr, CDBKeyStrEpoch(keyString), CDB_KEYSTR_EPOCH_SIZE);
fileEpochStr[CDB_KEYSTR_EPOCH_SIZE] = 0;
sscanf(fileEpochStr, "%ul", &fileEpoch);
strncpy(fileSerial, CDBKeyStrSerialNumber(keyString), CDB_KEYSTR_SERIAL_NUMBER_SIZE);
fileSerial[CDB_KEYSTR_SERIAL_NUMBER_SIZE] = 0;
sprintf(fileNameStr, "%08X.%s", fileEpoch, fileSerial);
if (location == CDB_FS_LOCATION_NAND || location == CDB_FS_LOCATION_SD) {
CDBConvFileNameStrToFullPath(fullPath, yearStr, monthStr, dayStr, hourStr, minStr, codeStr, typeStr, fileNameStr, location, wiiId);

View File

@@ -11,11 +11,11 @@ void CDBCryptBufSysInit(CDBCryptBuf* cryptBuf) {
// Some weird crap is going on with these functions.
CDBErr CDBCryptBufAllocate(CDBCryptBuf* cryptBuf) {
CDBErr err;
CDBErr err = CDB_ERROR_OK;
if (s_cryptBuf->allocated == FALSE) {
cryptBuf->buffer32[0] = (u32)s_cryptBuf;
s_cryptBuf->allocated = TRUE;
cryptBuf->buffer32[0] = (u32)&s_cryptBuf[err];
s_cryptBuf[err].allocated = TRUE;
return CDB_ERROR_OK;
} else {
CDBReportError("failed to allocate crypt buffer\n");
@@ -24,10 +24,10 @@ CDBErr CDBCryptBufAllocate(CDBCryptBuf* cryptBuf) {
}
CDBErr CDBCryptBufFree(CDBCryptBuf* cryptBuf) {
CDBErr err;
CDBErr err = CDB_ERROR_OK;
if ((CDBCryptBuf*)*cryptBuf->buffer32 == s_cryptBuf) {
s_cryptBuf->allocated = FALSE;
s_cryptBuf[err].allocated = FALSE;
*cryptBuf->buffer32 = 0;
return CDB_ERROR_OK;
} else {

File diff suppressed because it is too large Load Diff

View File

@@ -6,8 +6,13 @@
#include <stdlib.h>
#include <string.h>
#pragma push
#pragma section sconst_type ".sdata"
extern const char lbl_816979E8[8] = "/\0\0\0\0\0\0\0";
#pragma pop
void CDBFSConcatenatePath(char* path, const char* concatPath) {
strcat(path, "/");
strcat(path, lbl_816979E8);
strcat(path, concatPath);
}
@@ -106,6 +111,167 @@ BOOL CDBFSIsTypeDirName(char* dirName) {
return FALSE;
}
#ifdef __MWERKS__
asm BOOL CDBFSIsCDBFileOnSD(register char* fileName) {
nofralloc
stwu r1, -0x10(r1)
mflr r0
li r4, 0xd
stw r0, 0x14(r1)
stw r31, 0xc(r1)
mr r31, r3
bl CDBSafeStrLen
cmpwi r3, 0xc
bne CDBFSIsCDBFileOnSD_invalid
lis r4, _current_locale@ha
li r0, 0x4
addi r4, r4, _current_locale@l
mr r3, r31
lwz r6, 0x38(r4)
li r7, 0
mtctr r0
CDBFSIsCDBFileOnSD_loop:
lbz r5, 0(r3)
li r0, 0
extsb. r5, r5
blt CDBFSIsCDBFileOnSD_digit1_invalid
cmpwi r5, 0x100
blt CDBFSIsCDBFileOnSD_digit1_check
CDBFSIsCDBFileOnSD_digit1_invalid:
li r0, 1
CDBFSIsCDBFileOnSD_digit1_check:
cmpwi r0, 0
beq CDBFSIsCDBFileOnSD_digit1_map
li r0, 0
b CDBFSIsCDBFileOnSD_digit1_done
CDBFSIsCDBFileOnSD_digit1_map:
lwz r4, 8(r6)
slwi r0, r5, 1
lhzx r0, r4, r0
rlwinm r0, r0, 0, 21, 21
CDBFSIsCDBFileOnSD_digit1_done:
cmpwi r0, 0
bne CDBFSIsCDBFileOnSD_first_next
li r3, 0
b CDBFSIsCDBFileOnSD_return
CDBFSIsCDBFileOnSD_first_next:
lbz r5, 1(r3)
li r0, 0
extsb. r5, r5
blt CDBFSIsCDBFileOnSD_digit2_invalid
cmpwi r5, 0x100
blt CDBFSIsCDBFileOnSD_digit2_check
CDBFSIsCDBFileOnSD_digit2_invalid:
li r0, 1
CDBFSIsCDBFileOnSD_digit2_check:
cmpwi r0, 0
beq CDBFSIsCDBFileOnSD_digit2_map
li r0, 0
b CDBFSIsCDBFileOnSD_digit2_done
CDBFSIsCDBFileOnSD_digit2_map:
lwz r4, 8(r6)
slwi r0, r5, 1
lhzx r0, r4, r0
rlwinm r0, r0, 0, 21, 21
CDBFSIsCDBFileOnSD_digit2_done:
cmpwi r0, 0
bne CDBFSIsCDBFileOnSD_pair_next
li r3, 0
b CDBFSIsCDBFileOnSD_return
CDBFSIsCDBFileOnSD_pair_next:
addi r7, r7, 1
addi r3, r3, 2
bdnz CDBFSIsCDBFileOnSD_loop
lbz r0, 8(r31)
cmpwi r0, 0x2e
beq CDBFSIsCDBFileOnSD_extension
li r3, 0
b CDBFSIsCDBFileOnSD_return
CDBFSIsCDBFileOnSD_extension:
lbz r4, 9(r31)
li r0, 0
extsb. r4, r4
blt CDBFSIsCDBFileOnSD_digit3_invalid
cmpwi r4, 0x100
blt CDBFSIsCDBFileOnSD_digit3_check
CDBFSIsCDBFileOnSD_digit3_invalid:
li r0, 1
CDBFSIsCDBFileOnSD_digit3_check:
cmpwi r0, 0
beq CDBFSIsCDBFileOnSD_digit3_map
li r0, 0
b CDBFSIsCDBFileOnSD_digit3_done
CDBFSIsCDBFileOnSD_digit3_map:
lwz r3, 8(r6)
slwi r0, r4, 1
lhzx r0, r3, r0
rlwinm r0, r0, 0, 21, 21
CDBFSIsCDBFileOnSD_digit3_done:
cmpwi r0, 0
bne CDBFSIsCDBFileOnSD_digit4
li r3, 0
b CDBFSIsCDBFileOnSD_return
CDBFSIsCDBFileOnSD_digit4:
lbz r4, 0xa(r31)
li r0, 0
extsb. r4, r4
blt CDBFSIsCDBFileOnSD_digit4_invalid
cmpwi r4, 0x100
blt CDBFSIsCDBFileOnSD_digit4_check
CDBFSIsCDBFileOnSD_digit4_invalid:
li r0, 1
CDBFSIsCDBFileOnSD_digit4_check:
cmpwi r0, 0
beq CDBFSIsCDBFileOnSD_digit4_map
li r0, 0
b CDBFSIsCDBFileOnSD_digit4_done
CDBFSIsCDBFileOnSD_digit4_map:
lwz r3, 8(r6)
slwi r0, r4, 1
lhzx r0, r3, r0
rlwinm r0, r0, 0, 21, 21
CDBFSIsCDBFileOnSD_digit4_done:
cmpwi r0, 0
bne CDBFSIsCDBFileOnSD_digit5
li r3, 0
b CDBFSIsCDBFileOnSD_return
CDBFSIsCDBFileOnSD_digit5:
lbz r4, 0xb(r31)
li r0, 0
extsb. r4, r4
blt CDBFSIsCDBFileOnSD_digit5_invalid
cmpwi r4, 0x100
blt CDBFSIsCDBFileOnSD_digit5_check
CDBFSIsCDBFileOnSD_digit5_invalid:
li r0, 1
CDBFSIsCDBFileOnSD_digit5_check:
cmpwi r0, 0
beq CDBFSIsCDBFileOnSD_digit5_map
li r0, 0
b CDBFSIsCDBFileOnSD_digit5_done
CDBFSIsCDBFileOnSD_digit5_map:
lwz r3, 8(r6)
slwi r0, r4, 1
lhzx r0, r3, r0
rlwinm r0, r0, 0, 21, 21
CDBFSIsCDBFileOnSD_digit5_done:
cmpwi r0, 0
bne CDBFSIsCDBFileOnSD_valid
li r3, 0
b CDBFSIsCDBFileOnSD_return
CDBFSIsCDBFileOnSD_valid:
li r3, 1
b CDBFSIsCDBFileOnSD_return
CDBFSIsCDBFileOnSD_invalid:
li r3, 0
CDBFSIsCDBFileOnSD_return:
lwz r0, 0x14(r1)
lwz r31, 0xc(r1)
mtlr r0
addi r1, r1, 0x10
blr
}
#else
BOOL CDBFSIsCDBFileOnSD(char* fileName) {
if (CDBSafeStrLen(fileName, 12 + 1) == 12) {
char* ptr = fileName;
@@ -133,6 +299,7 @@ BOOL CDBFSIsCDBFileOnSD(char* fileName) {
return FALSE;
}
#endif
BOOL CDBFSIsMCGCDirNameOnSD(char* dirName) {
if (CDBSafeStrLen(dirName, 7 + 1) == 7) {

View File

@@ -3,6 +3,13 @@
#include <stdio.h>
typedef struct _CDBRecordKeyArray {
CDBRecordKey* records;
int capacity;
int size;
int reverse;
} CDBRecordKeyArray;
BOOL CDBRecordKeyIsValid(CDBRecordKey* recordKey) {
u32 keyLength;
if (recordKey == NULL) {
@@ -22,23 +29,25 @@ BOOL CDBRecordKeyIsValid(CDBRecordKey* recordKey) {
}
void CDBRecordKeyInit(CDBRecordKey* recordKey, CDBDate epoch, int gameCode, u16 makerCode, int serialNumber, char* fileType, int unk) {
char typeStr[8];
char gcStr[8];
char mcStr[8];
struct {
char mcStr[4];
char typeStr[8];
char gcStr[8];
} strings;
u32 typeLength;
CDBConvMCValueToMCStr(makerCode, mcStr);
CDBConvGCValueToGCStr(gameCode, gcStr);
CDBConvMCValueToMCStr(makerCode, strings.mcStr);
CDBConvGCValueToGCStr(gameCode, strings.gcStr);
recordKey->wiiId = CDBGetWiiId();
recordKey->location = unk;
typeLength = strlen(typeStr);
strcpy(typeStr, fileType);
CDBToLower(typeStr, typeLength);
typeLength = strlen(fileType);
strcpy(strings.typeStr, fileType);
CDBToLower(((char*)strings.typeStr), typeLength);
sprintf(recordKey->keyString, "%010u_%s_%s_%03d.%s", epoch, gcStr, mcStr, serialNumber, typeStr);
sprintf(recordKey->keyString, "%010u_%s_%s_%03d.%s", epoch, strings.gcStr, strings.mcStr, serialNumber, strings.typeStr);
}
void CDBRecordKeySetSerialNumber(CDBRecordKey* recordKey, int serialNum) {
@@ -65,9 +74,8 @@ void CDBRecordKeyInitFromFileName2(CDBRecordKey* recordKey, char* keyString, cha
recordKey->location = CDB_FS_LOCATION_SD;
}
void CDBRecordKeyCopy(CDBRecordKey* recordKey, CDBRecordKey* newRecordKey) {
void CDBRecordKeyCopy(CDBRecordKey* recordKey, const CDBRecordKey* newRecordKey) {
strcpy(recordKey->keyString, newRecordKey->keyString);
recordKey->wiiId = newRecordKey->wiiId;
recordKey->location = newRecordKey->location;
}
@@ -97,3 +105,200 @@ int CDBRecordKeyCompareByDate(CDBRecordKey* recordKey1, CDBRecordKey* recordKey2
void CDBRecordKeyGetKeyStr(CDBRecordKey* recordKey, char* keyString) {
strcpy(keyString, recordKey->keyString);
}
void CDBRecordKeyArrayInit(CDBRecordKeyArray* recordArray, CDBRecordKey* records, int capacity) {
recordArray->size = 0;
recordArray->reverse = 1;
recordArray->capacity = capacity;
recordArray->records = records;
}
void CDBRecordKeyArraySetReverse(CDBRecordKeyArray* recordArray) {
recordArray->reverse = -1;
}
int CDBRecordKeyArraySize(CDBRecordKeyArray* recordArray) {
return recordArray->size;
}
CDBRecordKey* CDBRecordKeyArrayAt(CDBRecordKeyArray* recordArray, int index) {
return (CDBRecordKey*)((char*)recordArray->records + index * sizeof(CDBRecordKey));
}
BOOL CDBRecordKeyArrayEmpty(CDBRecordKeyArray* recordArray) {
return recordArray->size == 0;
}
BOOL CDBRecordKeyArrayFull(CDBRecordKeyArray* recordArray) {
return recordArray->capacity <= recordArray->size;
}
CDBRecordKey* CDBRecordKeyArrayEnd(CDBRecordKeyArray* recordArray) {
return recordArray->records + recordArray->size;
}
#pragma dont_inline on
int CDBRecordKeyArrayDicInsertR(CDBRecordKeyArray* recordArray, CDBRecordKey* recordKey, int first, int last) {
int index;
int result;
if (first == last || first == last - 1) {
result = CDBRecordKeyCompare(recordKey, recordArray->records + first);
if (result < 0) {
return first;
}
result = CDBRecordKeyCompare(recordKey, recordArray->records + last);
if (result >= 0) {
last++;
}
return last;
}
index = first + (last - first) / 2;
result = CDBRecordKeyCompare(recordKey, recordArray->records + index);
if (result < 0) {
return CDBRecordKeyArrayDicInsertR(recordArray, recordKey, first, index);
}
if (result > 0) {
return CDBRecordKeyArrayDicInsertR(recordArray, recordKey, index, last);
}
return index;
}
CDBRecordKey* CDBRecordKeyArrayDicInsert(CDBRecordKeyArray* recordArray, CDBRecordKey* recordKey) {
int size = recordArray->size;
int index;
int moveCount;
CDBRecordKey* record;
if (size == 0) {
if (size < recordArray->capacity) {
record = recordArray->records + size;
CDBRecordKeyCopy(record, recordKey);
recordArray->size++;
}
return recordKey;
}
if (recordArray->capacity <= size) {
if (recordArray->reverse == 1) {
if (size != 0) {
record = recordArray->records + (size - 1);
} else {
record = recordArray->records;
}
if (CDBRecordKeyCompare(record, recordKey) < 0) {
return record;
}
recordArray->size--;
index = CDBRecordKeyArrayDicInsertR(recordArray, recordKey, 0, recordArray->size - 1);
moveCount = (recordArray->size - index) * sizeof(CDBRecordKey);
if (recordArray->capacity <= recordArray->size) {
moveCount -= sizeof(CDBRecordKey);
}
if (moveCount > 0) {
memmove((CDBRecordKey*)((char*)recordArray->records + (index + 1) * sizeof(CDBRecordKey)),
(CDBRecordKey*)((char*)recordArray->records + index * sizeof(CDBRecordKey)),
moveCount);
}
CDBRecordKeyCopy((CDBRecordKey*)((char*)recordArray->records + index * sizeof(CDBRecordKey)), recordKey);
if (recordArray->size < recordArray->capacity) {
recordArray->size++;
}
return (CDBRecordKey*)((char*)recordArray->records + index * sizeof(CDBRecordKey));
}
record = recordArray->records;
if (CDBRecordKeyCompare(recordKey, record) < 0) {
return record;
}
recordArray->size--;
if (recordArray->size >= 0 && recordArray->capacity - 1 >= 0) {
memmove(recordArray->records, recordArray->records + 1, recordArray->size * sizeof(CDBRecordKey));
}
index = CDBRecordKeyArrayDicInsertR(recordArray, recordKey, 0, recordArray->size - 1);
moveCount = (recordArray->size - index) * sizeof(CDBRecordKey);
if (recordArray->capacity <= recordArray->size) {
moveCount -= sizeof(CDBRecordKey);
}
if (moveCount > 0) {
memmove((CDBRecordKey*)((char*)recordArray->records + (index + 1) * sizeof(CDBRecordKey)),
(CDBRecordKey*)((char*)recordArray->records + index * sizeof(CDBRecordKey)),
moveCount);
}
CDBRecordKeyCopy((CDBRecordKey*)((char*)recordArray->records + index * sizeof(CDBRecordKey)), recordKey);
if (recordArray->size < recordArray->capacity) {
recordArray->size++;
}
return (CDBRecordKey*)((char*)recordArray->records + index * sizeof(CDBRecordKey));
}
index = CDBRecordKeyArrayDicInsertR(recordArray, recordKey, 0, size - 1);
moveCount = (recordArray->size - index) * sizeof(CDBRecordKey);
if (recordArray->capacity <= recordArray->size) {
moveCount -= sizeof(CDBRecordKey);
}
if (moveCount > 0) {
memmove((CDBRecordKey*)((char*)recordArray->records + (index + 1) * sizeof(CDBRecordKey)),
(CDBRecordKey*)((char*)recordArray->records + index * sizeof(CDBRecordKey)),
moveCount);
}
CDBRecordKeyCopy((CDBRecordKey*)((char*)recordArray->records + index * sizeof(CDBRecordKey)), recordKey);
if (recordArray->size < recordArray->capacity) {
recordArray->size++;
}
return (CDBRecordKey*)((char*)recordArray->records + index * sizeof(CDBRecordKey));
}
int CDBRecordKeyArrayDicFindR(CDBRecordKeyArray* recordArray, CDBRecordKey* recordKey, int first, int last) {
int index;
int result;
if (first == last || first == last - 1) {
result = CDBRecordKeyCompare(recordKey, recordArray->records + first);
if (result == 0) {
return first;
}
result = CDBRecordKeyCompare(recordKey, recordArray->records + last);
if (result != 0) {
return -1;
}
return last;
}
index = first + (last - first) / 2;
result = CDBRecordKeyCompare(recordKey, recordArray->records + index);
if (result < 0) {
return CDBRecordKeyArrayDicFindR(recordArray, recordKey, first, index);
}
if (result > 0) {
return CDBRecordKeyArrayDicFindR(recordArray, recordKey, index, last);
}
return index;
}
#pragma dont_inline reset
CDBRecordKey* CDBRecordKeyArrayDicFind(CDBRecordKeyArray* recordArray, CDBRecordKey* recordKey) {
int size = recordArray->size;
int index;
if (size == 0) {
return recordArray->records + size;
}
index = CDBRecordKeyArrayDicFindR(recordArray, recordKey, 0, size - 1);
if (index != -1) {
return recordArray->records + index;
}
return recordArray->records + recordArray->size;
}

View File

@@ -21,6 +21,7 @@ static VFErr s_lastVFError;
static s32 s_lastNANDError;
static u8 s_cdbWiiId[OSRoundUp32B(CDB_WIIID_DAT_SIZE)] ALIGN32;
static u8* s_recordPool;
void MutexInitialized() {
s_mutexInitialized = TRUE;
@@ -34,6 +35,18 @@ void CDBUnlock() {
OSUnlockMutex(&s_mutex);
}
CDBErr CDBRecordFree(CDBRecord* record) {
CDBRecordFile* recordFile = record->file;
OSLockMutex(&s_mutex);
OSLockMutex((OSMutex*)recordFile);
*(u32*)&recordFile->unk_0x00[0x18] = 0;
OSUnlockMutex((OSMutex*)recordFile);
recordFile->unk_0x1C = 0;
record->file = NULL;
OSUnlockMutex(&s_mutex);
}
CDBErr _CDBOnVFErrorOccured(VFErr VFErr, const char* unused0, u32 unused1) {
s_lastVFError = VFErr;
return CDB_ERROR_VF_ERROR;
@@ -60,6 +73,18 @@ void CDBSetFatalVFErrorFlag() {
s_fatalVFFlag = TRUE;
}
void CDBRecordPoolInit(void* work) {
int i;
s_recordPool = (u8*)work + 0x18030;
for (i = 0; i < 5; i++) {
*(u32*)(s_recordPool + i * 0x470 + 0x18) = 0;
if (!s_mutexInitialized) {
OSInitMutex((OSMutex*)(s_recordPool + i * 0x470));
}
}
}
void CDBTryToCreate_wiiiddat(u8* data) {
NANDFileInfo fileInfo;
u32 nandCheck;

View File

@@ -0,0 +1,585 @@
#include <private/ipc.h>
#include <private/ios.h>
#include <private/nwc24/NWC24Schedule.h>
#include <revolution/ncd.h>
#include <revolution/os.h>
#include <string.h>
#define NCD_IPC_HEAP_SIZE 0x1B60
#define NCD_MAX_PROFILE 3
static u32 ncdInitialized;
static NCDConfig* ncdCommonBuffer;
struct NCDMutex {
OSMutex mutex;
u8 padding[8];
} ncdMutex;
s32 ncdCommonResult[8] ATTRIBUTE_ALIGN(32);
IOSIoVector ncdCommonVector[4] ATTRIBUTE_ALIGN(32);
const char* __NCDVersion = "<< RVL_SDK - NCD \trelease build: Dec 12 2008 03:06:03 (0x4199_60831) >>";
const char* __NCDUnofficialVersion = "<< RVL_SDK - NCD \trelease build: Dec 12 2008 03:06:03 (0x4199_60831) UNOFFICIAL >>";
static void LockRight(void);
static NCDErr ExecConfigCommand(const char* name, NCDConfig* config, u32 command);
static NCDErr NCDiGetWirelessMacAddress(u8* macAddr);
NCDErr NCDReadConfig(NCDConfig* config) {
if (config == NULL) {
return -3;
}
return ExecConfigCommand("NCDReadConfig", config, 5);
}
NCDErr NCDWriteConfig(const NCDConfig* config) {
BOOL enabled;
enabled = OSDisableInterrupts();
if (!(ncdInitialized & 2)) {
OSRegisterVersion(__NCDUnofficialVersion);
ncdInitialized |= 2;
}
OSRestoreInterrupts(enabled);
if (config == NULL) {
return -3;
}
return ExecConfigCommand("NCDWriteConfig", (NCDConfig*)config, 6);
}
NCDErr NCDSetIfConfig(NCDIfConfig* ifConfig) {
union {
BOOL enabled;
NCDConfig* config;
} state;
NCDErr lockErr;
NCDProfile* profile;
NCDErr result;
s32 i;
u32 count;
state.enabled = OSDisableInterrupts();
if (!(ncdInitialized & 2)) {
OSRegisterVersion(__NCDUnofficialVersion);
ncdInitialized |= 2;
}
OSRestoreInterrupts(state.enabled);
if (ifConfig == NULL) {
return -3;
}
if (!OSGetCurrentThread()) {
return -5;
}
LockRight();
lockErr = NWC24iLockSocket();
if (lockErr == 0) {
result = ExecConfigCommand("NCDSetIfConfig", NULL, 3);
if (result == 0) {
state.config = ncdCommonBuffer;
if (ifConfig->selectedMedia != 1 && ifConfig->selectedMedia != 2) {
state.config->selectedMedia = 0;
} else {
state.config->selectedMedia = ifConfig->selectedMedia;
profile = state.config->profiles;
i = 0;
state.config->linkTimeout = ifConfig->linkTimeout;
count = 0;
for (; i < NCD_MAX_PROFILE; i++, profile++) {
if (state.config->profiles[i].flags & 0x80) {
switch (ifConfig->selectedMedia) {
case 1:
state.config->profiles[i].flags &= ~1;
memcpy(&profile->netif, &ifConfig->netif, 0x15c);
break;
case 2:
state.config->profiles[i].flags |= 1;
memcpy(&profile->netif, &ifConfig->netif, 4);
break;
}
count++;
}
}
if (count == 0) {
state.config->profiles[0].flags |= 0x80;
switch (ifConfig->selectedMedia) {
case 1:
state.config->profiles[0].flags &= ~1;
memcpy(&state.config->profiles[0].netif.wireless, &ifConfig->netif, 0x15c);
break;
case 2:
state.config->profiles[0].flags |= 1;
memcpy(&state.config->profiles[0].netif.wired, &ifConfig->netif, 4);
break;
}
memset(&state.config->profiles[0].adjust, 0, 0xc);
state.config->profiles[0].flags |= 6;
memset(&state.config->profiles[0].ip, 0, 0x14);
state.config->profiles[0].flags &= ~0x10;
memset(&state.config->profiles[0].proxy, 0, 0x79c);
}
}
result = ExecConfigCommand("NCDSetIfConfig", NULL, 4);
}
NWC24iUnlockSocket();
} else if (lockErr == -0x16) {
result = -4;
} else if (lockErr == -0x1d) {
result = -8;
} else {
result = -2;
}
OSUnlockMutex((OSMutex*)&ncdMutex);
return result;
}
NCDErr NCDSetIpConfig(NCDIpConfig* ipConfig) {
NCDErr err;
BOOL enabled;
s32 i;
u32 count;
NCDConfig* config;
enabled = OSDisableInterrupts();
if (!(ncdInitialized & 2)) {
OSRegisterVersion(__NCDUnofficialVersion);
ncdInitialized |= 2;
}
OSRestoreInterrupts(enabled);
if (ipConfig == NULL) {
return -3;
}
if (!OSGetCurrentThread()) {
return -5;
}
LockRight();
err = NWC24iLockSocket();
if (err == 0) {
err = ExecConfigCommand("NCDSetIpConfig", NULL, 3);
if (err == 0) {
i = 0;
count = 0;
config = ncdCommonBuffer;
for (; i < NCD_MAX_PROFILE; i++) {
if (config->profiles[i].flags & 0x80) {
NCDProfile* profile = &config->profiles[i];
memcpy(&profile->adjust, &ipConfig->adjust, 0xc);
if (ipConfig->useDhcp == 1) {
config->profiles[i].flags |= 6;
memcpy(&profile->ip, &ipConfig->ip, 0x14);
} else {
config->profiles[i].flags &= ~6;
memcpy(&profile->ip, &ipConfig->ip, 0x14);
}
if (ipConfig->useProxy == 1) {
config->profiles[i].flags |= 0x10;
memcpy(&profile->proxy, &ipConfig->proxy, 0x79c);
} else {
config->profiles[i].flags &= ~0x10;
memset(&profile->proxy, 0, 0x79c);
}
count++;
}
}
if (count == 0) {
NCDProfile* profile = config->profiles;
profile->flags |= 0x80;
memcpy(&profile->adjust, &ipConfig->adjust, 0xc);
if (ipConfig->useDhcp == 1) {
profile->flags |= 6;
memcpy(&profile->ip, &ipConfig->ip, 0x14);
} else {
profile->flags &= ~6;
memcpy(&profile->ip, &ipConfig->ip, 0x14);
}
if (ipConfig->useProxy == 1) {
profile->flags |= 0x10;
memcpy(&profile->proxy, &ipConfig->proxy, 0x79c);
} else {
profile->flags &= ~0x10;
memset(&profile->proxy, 0, 0x79c);
}
profile->flags = profile->flags & ~1;
memset(&profile->netif, 0, 0x15c);
}
err = ExecConfigCommand("NCDSetIpConfig", NULL, 4);
}
NWC24iUnlockSocket();
} else if (err == -0x16) {
err = -4;
} else if (err == -0x1d) {
err = -8;
} else {
err = -2;
}
OSUnlockMutex((OSMutex*)&ncdMutex);
return err;
}
NCDErr NCDGetCurrentIpConfig(NCDIpConfig* ipConfig) {
NCDErr err = 0;
NCDConfig* config;
s32 idx;
if (ipConfig == NULL) {
return -3;
}
LockRight();
err = ExecConfigCommand("NCDGetCurrentIpConfig", 0, 3);
if (err == 0) {
config = ncdCommonBuffer;
idx = ncdCommonResult[1];
if (idx < 0 || idx >= NCD_MAX_PROFILE) {
err = -7;
} else {
memcpy(&ipConfig->adjust, &config->profiles[idx].adjust, 0xc);
if (config->profiles[idx].flags & 0x6) {
ipConfig->useDhcp = TRUE;
memcpy(&ipConfig->ip, &config->profiles[idx].ip, 0x14);
} else {
ipConfig->useDhcp = FALSE;
memcpy(&ipConfig->ip, &config->profiles[idx].ip, 0x14);
}
if (config->profiles[idx].flags & 0x10) {
ipConfig->useProxy = TRUE;
memcpy(&ipConfig->proxy, &config->profiles[idx].proxy, 0x79c);
} else {
ipConfig->useProxy = FALSE;
memset(&ipConfig->proxy, 0, 0x79c);
}
}
}
OSUnlockMutex((OSMutex*)&ncdMutex);
return err;
}
NCDErr NCDGetLinkStatus(void) {
NCDErr err;
s32 fd;
if (!OSGetCurrentThread()) {
return -5;
}
LockRight();
fd = IOS_Open("/dev/net/ncd/manage", 0);
if (fd < 0) {
if (fd == -6) {
err = -8;
} else {
err = -2;
}
} else {
ncdCommonVector[0].base = (u8*)ncdCommonResult;
ncdCommonVector[0].length = sizeof(ncdCommonResult);
if (IOS_Ioctlv(fd, 7, 0, 1, ncdCommonVector) < 0) {
err = -2;
} else {
err = ncdCommonResult[0];
if (err == 0) {
err = ncdCommonResult[1];
err = err >= 0 ? err : -1;
}
}
if (IOS_Close(fd) < 0) {
err = -1;
}
}
OSUnlockMutex((OSMutex*)&ncdMutex);
return err;
}
BOOL NCDIsInterfaceDecided(void) {
NCDErr err = NCDGetLinkStatus();
switch (err) {
case 3:
case 4:
case 5:
return TRUE;
default:
return FALSE;
}
}
NCDErr NCDGetWirelessMacAddress(u8* macAddr) {
return NCDiGetWirelessMacAddress(macAddr);
}
static NCDErr NCDiGetWirelessMacAddress(u8* macAddr) {
NCDErr err = 0;
s32 fd;
if (macAddr == NULL) {
return -3;
}
if (!OSGetCurrentThread()) {
return -5;
}
LockRight();
fd = IOS_Open("/dev/net/ncd/manage", 0);
if (fd < 0) {
if (fd == -6) {
err = -8;
} else {
err = -2;
}
} else {
ncdCommonVector[0].base = (u8*)ncdCommonResult;
ncdCommonVector[0].length = sizeof(ncdCommonResult);
ncdCommonVector[1].base = (u8*)ncdCommonBuffer;
ncdCommonVector[1].length = NCD_MAC_ADDRESS_LENGTH;
if (IOS_Ioctlv(fd, 8, 0, 2, ncdCommonVector) < 0) {
err = -2;
} else {
err = ncdCommonResult[0];
if (err == 0) {
memcpy(macAddr, ncdCommonBuffer, NCD_MAC_ADDRESS_LENGTH);
}
}
if (IOS_Close(fd) < 0) {
err = -1;
}
}
OSUnlockMutex((OSMutex*)&ncdMutex);
return err;
}
NCDErr NCDLockWirelessDriver(void) {
NCDErr err;
s32 fd;
if (!OSGetCurrentThread()) {
return -5;
}
LockRight();
fd = IOS_Open("/dev/net/ncd/manage", 0);
if (fd < 0) {
if (fd == -6) {
err = -8;
} else {
err = -2;
}
} else {
ncdCommonVector[0].base = (u8*)ncdCommonResult;
ncdCommonVector[0].length = sizeof(ncdCommonResult);
if (IOS_Ioctlv(fd, 1, 0, 1, ncdCommonVector) < 0) {
err = -2;
} else {
err = ncdCommonResult[0];
if (err == 0) {
err = ncdCommonResult[1];
err = err > 0 ? err : -1;
}
}
if (IOS_Close(fd) < 0) {
err = -1;
}
}
OSUnlockMutex((OSMutex*)&ncdMutex);
return err;
}
NCDErr NCDUnlockWirelessDriver(s32 id) {
NCDErr err;
s32 fd;
if (id <= 0) {
return -3;
}
if (!OSGetCurrentThread()) {
return -5;
}
LockRight();
fd = IOS_Open("/dev/net/ncd/manage", 0);
if (fd < 0) {
if (fd == -6) {
err = -8;
} else {
err = -2;
}
} else {
ncdCommonVector[0].base = (u8*)ncdCommonBuffer;
ncdCommonVector[0].length = 4;
ncdCommonVector[1].base = (u8*)ncdCommonResult;
ncdCommonVector[1].length = sizeof(ncdCommonResult);
ncdCommonBuffer->version = id;
if (IOS_Ioctlv(fd, 2, 1, 1, ncdCommonVector) < 0) {
err = -2;
} else {
err = ncdCommonResult[0];
}
if (IOS_Close(fd) < 0) {
err = -1;
}
}
OSUnlockMutex((OSMutex*)&ncdMutex);
return err;
}
s32 NCDRestoreConfig(void) {
NCDErr err;
if (!OSGetCurrentThread()) {
return -5;
}
LockRight();
err = NWC24iLockSocket();
if (err == 0) {
err = ExecConfigCommand("NCDRestoreConfig", NULL, 5);
if (err == 0) {
err = ExecConfigCommand("NCDRestoreConfig", NULL, 4);
}
NWC24iUnlockSocket();
} else if (err == -0x16) {
err = -4;
} else if (err == -0x1d) {
err = -8;
} else {
err = -2;
}
OSUnlockMutex((OSMutex*)&ncdMutex);
return err;
}
NCDErr NCDiGetEnabledConfigList(u32* list0, u32* list1, u32* list2) {
NCDErr err;
u32 mask0 = 0;
u32 mask1 = 0;
u32 mask2 = 0;
u8 flags;
u32 i;
LockRight();
err = ExecConfigCommand("NCDiGetEnabledConfigList", NULL, 3);
if (err == 0) {
for (i = 0; i < NCD_MAX_PROFILE; i++) {
NCDProfile* profile = &ncdCommonBuffer->profiles[i];
flags = profile->flags;
if (flags & 0x80) {
if (flags & 1) {
mask0 |= 1 << i;
} else {
if (profile->netif.wireless.configMethod != 1) {
mask1 |= 1 << i;
}
if (ncdCommonBuffer->profiles[i].netif.wireless.configMethod == 1) {
mask2 |= 1 << i;
}
}
}
}
}
OSUnlockMutex((OSMutex*)&ncdMutex);
if (list0 != NULL) {
*list0 = mask0;
}
if (list1 != NULL) {
*list1 = mask1;
}
if (list2 != NULL) {
*list2 = mask2;
}
return err;
}
static NCDErr ExecConfigCommand(const char* name, NCDConfig* config, u32 command) {
NCDErr err = 0;
s32 fd;
if (!OSGetCurrentThread()) {
return -5;
}
LockRight();
fd = IOS_Open("/dev/net/ncd/manage", 0);
if (fd < 0) {
if (fd == -6) {
err = -8;
} else {
err = -2;
}
} else {
ncdCommonVector[0].base = (u8*)ncdCommonBuffer;
ncdCommonVector[0].length = sizeof(NCDConfig);
ncdCommonVector[1].base = (u8*)ncdCommonResult;
ncdCommonVector[1].length = sizeof(ncdCommonResult);
switch (command) {
case 3:
case 5:
if (IOS_Ioctlv(fd, command, 0, 2, ncdCommonVector) < 0) {
err = -2;
} else {
err = ncdCommonResult[0];
if (err == 0 && config != NULL) {
memcpy(config, ncdCommonBuffer, sizeof(NCDConfig));
}
}
break;
case 4:
case 6:
if (config != NULL) {
memcpy(ncdCommonBuffer, config, sizeof(NCDConfig));
}
if (IOS_Ioctlv(fd, command, 1, 1, ncdCommonVector) < 0) {
err = -2;
} else {
err = ncdCommonResult[0];
}
break;
}
if (IOS_Close(fd) < 0) {
err = -1;
}
}
OSUnlockMutex((OSMutex*)&ncdMutex);
return err;
}
static void LockRight(void) {
BOOL enabled;
void* lo;
enabled = OSDisableInterrupts();
if (!(ncdInitialized & 1)) {
OSRegisterVersion(__NCDVersion);
OSInitMutex((OSMutex*)&ncdMutex);
lo = (void*)OSRoundUp32B(IPCGetBufferLo());
if ((u32)IPCGetBufferHi() - (u32)lo < NCD_IPC_HEAP_SIZE) {
OSPanic("ncdsystem.c", 0x5B1, "Could not reserve heap for NCD library from IPC arena");
}
IPCSetBufferLo((u8*)lo + NCD_IPC_HEAP_SIZE);
ncdCommonBuffer = (NCDConfig*)lo;
memset(ncdCommonBuffer, 0, NCD_IPC_HEAP_SIZE);
memset(ncdCommonResult, 0, sizeof(ncdCommonResult));
memset(ncdCommonVector, 0, sizeof(ncdCommonVector));
ncdInitialized |= 1;
}
OSRestoreInterrupts(enabled);
OSLockMutex((OSMutex*)&ncdMutex);
}

View File

@@ -85,8 +85,7 @@ NWC24Err NWC24GetCHJumpBlockSize(const NWC24CHJumpObj* chjp, u32* size, u32 inde
}
NWC24Err NWC24GetCHJumpBlockData(const NWC24CHJumpObj* chjp, char* data, u32 size, u32 index) {
const CHJumpBlock* block;
const char* blockTbl = GetCHDataPtr(chjp);
const u32* blockTbl = (const u32*)GetCHDataPtr(chjp);
char* srcData;
u32 srcSize;
@@ -95,11 +94,9 @@ NWC24Err NWC24GetCHJumpBlockData(const NWC24CHJumpObj* chjp, char* data, u32 siz
return NWC24_ERR_INVALID_VALUE;
}
block = GetCHJumpBlock(blockTbl, index);
// Get block data and size
srcData = (char*)&blockTbl[block->offset];
srcSize = block->size;
srcData = (char*)chjp + blockTbl[index * 2];
srcSize = blockTbl[index * 2 + 1];
// Make sure they do not overflow
if (srcSize > size) {

View File

@@ -18,10 +18,16 @@ enum {
#define FRIEND_LIST_MAGIC 'WcFl'
#define FRIEND_LIST_VERSION 2
static const char* FLFilePath = "/shared2/wc24/nwc24fl.bin";
const char lbl_8166E160[26] __attribute__((section(".data"), aligned(8))) = "/shared2/wc24/nwc24fl.bin";
void* const lbl_8166E160_pad __attribute__((section(".data"))) = (void*)0;
static const char* FLFilePath = lbl_8166E160;
const u32 FLFilePath_pad __attribute__((section(".sdata"), aligned(1))) = 0;
const char g_SpecialsChars[16] = { '(', ')', '<', '>', '[', ']', ':', ';', '\\', ',', '"' };
static NWC24Err GetCachedFLHeader(NWC24FLHeader** header);
static ChkHostNameError CheckHostName(const char* hostName, u32 hostNameLength);
static inline NWC24Err CheckFriendInfo(const NWC24FriendInfo* friendInfo);
static u32 GetUnkFlag(u32 index) {
NWC24Err result;
@@ -127,7 +133,7 @@ NWC24Err NWC24WriteFriendInfo(const NWC24FriendInfo* friendInfo, u32 index) {
return NWC24_ERR_ALIGNMENT;
}
result = NWC24CheckFriendInfo(friendInfo);
result = CheckFriendInfo(friendInfo);
if (result != NWC24_OK) {
return result;
}
@@ -219,63 +225,6 @@ NWC24Err NWC24WriteFriendInfo(const NWC24FriendInfo* friendInfo, u32 index) {
return result;
}
NWC24Err NWC24DeleteFriendInfo(u32 index) {
NWC24Err result;
NWC24Err resultWrite;
NWC24FLHeader* header;
NWC24FriendInfo* tmpFriendInfo;
NWC24File file;
u32 fileOffset;
if (!NWC24IsMsgLibOpened() && !NWC24IsMsgLibOpenedByTool()) {
return NWC24_ERR_LIB_NOT_OPENED;
}
result = GetCachedFLHeader(&header);
if (result != NWC24_OK) {
return result;
}
if (index >= header->infoCount) {
return NWC24_ERR_INVALID_VALUE;
}
if (header->friendIds[index] == 0) {
return NWC24_ERR_NULL;
}
tmpFriendInfo = (NWC24FriendInfo*)nwc24Work->mainWork;
Mail_memset(tmpFriendInfo, 0, sizeof(NWC24FriendInfo));
result = NWC24FOpen(&file, FLFilePath, NWC24_OPEN_RW);
if (result != NWC24_OK) {
return result;
}
fileOffset = (index * sizeof(NWC24FriendInfo)) + sizeof(NWC24FLHeader);
NWC24FSeek(&file, fileOffset, NWC24_SEEK_BEG);
resultWrite = NWC24FWrite(tmpFriendInfo, sizeof(NWC24FriendInfo), &file);
if (resultWrite == NWC24_OK) {
header->friendIds[index] = 0;
header->registeredCount--;
result = SetUnkFlag(index, 0);
if (result == NWC24_OK) {
NWC24FSeek(&file, 0, NWC24_SEEK_BEG);
resultWrite = NWC24FWrite(header, sizeof(NWC24FLHeader), &file);
}
}
result = NWC24FClose(&file);
if (resultWrite != NWC24_OK) {
result = resultWrite;
}
return result;
}
NWC24Err NWC24UpdateFriendInfo(const NWC24FriendInfo* friendInfo, u32 index) {
NWC24Err result;
NWC24Err resultFile;
@@ -296,7 +245,7 @@ NWC24Err NWC24UpdateFriendInfo(const NWC24FriendInfo* friendInfo, u32 index) {
return NWC24_ERR_ALIGNMENT;
}
result = NWC24CheckFriendInfo(friendInfo);
result = CheckFriendInfo(friendInfo);
if (result != NWC24_OK) {
return result;
}
@@ -358,6 +307,63 @@ out:
return result;
}
NWC24Err NWC24DeleteFriendInfo(u32 index) {
NWC24Err result;
NWC24Err resultWrite;
NWC24FLHeader* header;
NWC24FriendInfo* tmpFriendInfo;
NWC24File file;
u32 fileOffset;
if (!NWC24IsMsgLibOpened() && !NWC24IsMsgLibOpenedByTool()) {
return NWC24_ERR_LIB_NOT_OPENED;
}
result = GetCachedFLHeader(&header);
if (result != NWC24_OK) {
return result;
}
if (index >= header->infoCount) {
return NWC24_ERR_INVALID_VALUE;
}
if (header->friendIds[index] == 0) {
return NWC24_ERR_NULL;
}
tmpFriendInfo = (NWC24FriendInfo*)nwc24Work->mainWork;
Mail_memset(tmpFriendInfo, 0, sizeof(NWC24FriendInfo));
result = NWC24FOpen(&file, FLFilePath, NWC24_OPEN_RW);
if (result != NWC24_OK) {
return result;
}
fileOffset = (index * sizeof(NWC24FriendInfo)) + sizeof(NWC24FLHeader);
NWC24FSeek(&file, fileOffset, NWC24_SEEK_BEG);
resultWrite = NWC24FWrite(tmpFriendInfo, sizeof(NWC24FriendInfo), &file);
if (resultWrite == NWC24_OK) {
header->friendIds[index] = 0;
header->registeredCount--;
result = SetUnkFlag(index, 0);
if (result == NWC24_OK) {
NWC24FSeek(&file, 0, NWC24_SEEK_BEG);
resultWrite = NWC24FWrite(header, sizeof(NWC24FLHeader), &file);
}
}
result = NWC24FClose(&file);
if (resultWrite != NWC24_OK) {
result = resultWrite;
}
return result;
}
NWC24Err NWC24SwapFriendInfos(u32 index1, u32 index2) {
NWC24Err result;
NWC24Err resultFile;
@@ -476,8 +482,8 @@ NWC24Err NWC24SearchFriendInfoByAddr(const NWC24FriendAddr* addr, u32* index) {
NWC24Err result;
NWC24FLHeader* header;
NWC24FriendAddr* tmpFriendAddr;
NWC24FriendInfo* tmpFriendInfo;
int cmpResult;
u32 i;
@@ -498,10 +504,12 @@ NWC24Err NWC24SearchFriendInfoByAddr(const NWC24FriendAddr* addr, u32* index) {
}
tmpFriendInfo = (NWC24FriendInfo*)&nwc24Work->mainWork;
tmpFriendAddr = (NWC24FriendAddr*)&tmpFriendInfo->addr.mailAddr[sizeof(NWC24UserId)];
for (i = 0; i < header->infoCount; i++) {
if (friendValue == header->friendIds[i]) {
result = NWC24ReadFriendInfo(tmpFriendInfo, i);
result = NWC24ReadFriendInfo(
(NWC24FriendInfo*)((u8*)tmpFriendAddr - sizeof(NWC24FriendAttr) - sizeof(NWC24UserId)), i);
if (result != NWC24_OK) {
return result;
}
@@ -748,7 +756,7 @@ static NWC24Err GetCachedFLHeader(NWC24FLHeader** header) {
return NWC24_OK;
}
NWC24Err NWC24CheckFriendInfo(const NWC24FriendInfo* friendInfo) {
static inline NWC24Err CheckFriendInfo(const NWC24FriendInfo* friendInfo) {
NWC24Err result;
if (friendInfo == NULL) {
@@ -773,8 +781,6 @@ NWC24Err NWC24CheckPublicMailAddr(const char* addr) {
int len;
BOOL readingDomain;
static const char specials[] = { '(', ')', '<', '>', '[', ']', ':', ';', '\\', ',', '"' };
// Check parameters
if (addr == NULL) {
return NWC24_ERR_NULL;
@@ -810,8 +816,8 @@ NWC24Err NWC24CheckPublicMailAddr(const char* addr) {
}
// If the character is special, invalid!
for (j = 0; j < sizeof(specials); j++) {
if (ch == specials[j]) {
for (j = 0; j < 11; j++) {
if (ch == g_SpecialsChars[j]) {
return NWC24_ERR_FORMAT;
}
}

View File

@@ -22,6 +22,9 @@ static BOOL Registered = FALSE;
static u8 InternalStatBuf[32];
static NWC24Err NWC24OpenLibInternal(NWC24Work* work, s32 state);
NWC24Err InitAllFiles(NWC24Work* work, BOOL forceConfig, BOOL forceMBox, BOOL forceFriendList, BOOL forceDlTask);
NWC24Err NWC24iInitMsgBoxDir(BOOL force);
NWC24Err AnalyzeErrorCode(s32 errorCode, u32 usage, u32* score);
void NWC24iRegister() {
if (Registered) {
@@ -287,10 +290,382 @@ NWC24Err NWC24GetSchedulerError(s32* numErrors, s32* errorCode) {
return result;
}
#ifdef __MWERKS__
extern void _savegpr_27();
extern void _restgpr_27();
extern void NCDiGetEnabledConfigList();
extern NWC24Err AnalyzeScdErrors(s32* errorCode, u32 usage);
extern void NWC24iMBoxCheck();
extern void SCCheckStatus();
extern void SCGetWCFlags();
extern void SCGetEULA();
extern void SCGetNetContentRestrictions();
extern void SCGetParentalControl();
asm NWC24Err NWC24Check(register u32 usage) {
nofralloc
stwu r1, -0x80(r1)
mflr r0
stw r0, 0x84(r1)
addi r11, r1, 0x80
bl _savegpr_27
lwz r0, Opened(r0)
li r4, 0
stw r4, GlobalErrorCode(r0)
mr r27, r3
cmpwi r0, 1
beq _NWC24Check_open
li r31, -9
b _NWC24Check_return
_NWC24Check_open:
li r31, -0x27
_NWC24Check_status:
bl SCCheckStatus
cmplwi r3, 1
beq _NWC24Check_status
cmplwi r3, 2
bne _NWC24Check_status_ok
lis r3, -2
addi r0, r3, 0x55c8
stw r0, GlobalErrorCode(r0)
b _NWC24Check_return
_NWC24Check_status_ok:
bl SCGetWCFlags
clrlwi r29, r3, 0x1f
bl SCGetEULA
mr r30, r3
bl SCGetNetContentRestrictions
rlwinm r28, r3, 0, 0x1e, 0x1e
addi r3, r1, 0x1c
bl SCGetParentalControl
cmpwi r29, 0
bne _NWC24Check_eula
lis r3, -2
addi r0, r3, 0x55ad
stw r0, GlobalErrorCode(r0)
b _NWC24Check_return
_NWC24Check_eula:
cmpwi r30, 0
bne _NWC24Check_restrictions
lis r3, -2
addi r0, r3, 0x55cd
stw r0, GlobalErrorCode(r0)
b _NWC24Check_return
_NWC24Check_restrictions:
clrlwi. r30, r27, 0x1f
beq _NWC24Check_config
lbz r0, 0x1c(r1)
rlwinm. r0, r0, 0, 0x18, 0x18
beq _NWC24Check_config
cmpwi r28, 0
beq _NWC24Check_config
lis r3, -2
addi r0, r3, 0x55cd
stw r0, GlobalErrorCode(r0)
b _NWC24Check_return
_NWC24Check_config:
addi r3, r1, 0x18
addi r4, r1, 0x14
addi r5, r1, 0x10
li r31, -0x1f
bl NCDiGetEnabledConfigList
cmpwi r3, 0
bge _NWC24Check_config_ok
lis r3, -2
addi r0, r3, 0x55b3
stw r0, GlobalErrorCode(r0)
b _NWC24Check_return
_NWC24Check_config_ok:
lwz r0, 0x18(r1)
cmpwi r0, 0
bne _NWC24Check_id
lwz r0, 0x14(r1)
cmpwi r0, 0
bne _NWC24Check_id
lwz r0, 0x10(r1)
cmpwi r0, 0
bne _NWC24Check_id
lis r3, -1
addi r0, r3, 0x3b85
stw r0, GlobalErrorCode(r0)
b _NWC24Check_return
_NWC24Check_id:
cmpwi r30, 0
beq _NWC24Check_scheduler
addi r3, r1, 0xc
bl NWC24GetIdCreationStage
lwz r0, 0xc(r1)
cmpwi r0, 2
beq _NWC24Check_scheduler
lis r3, -2
addi r0, r3, 0x55a8
stw r0, GlobalErrorCode(r0)
b _NWC24Check_return
_NWC24Check_scheduler:
li r0, 0
mr r4, r27
stw r0, 8(r1)
addi r3, r1, 8
bl AnalyzeScdErrors
cmpwi r3, 0
bge _NWC24Check_mbox
lwz r0, 8(r1)
mr r31, r3
stw r0, GlobalErrorCode(r0)
b _NWC24Check_return
_NWC24Check_mbox:
li r3, 0
li r4, 0
bl NWC24iMBoxCheck
cmpwi r3, -6
mr r31, r3
bne _NWC24Check_mbox_done
lis r4, -2
addi r0, r4, 0x55ce
stw r0, GlobalErrorCode(r0)
_NWC24Check_mbox_done:
cmpwi r3, -6
beq _NWC24Check_return
li r31, 0
_NWC24Check_return:
addi r11, r1, 0x80
mr r3, r31
bl _restgpr_27
lwz r0, 0x84(r1)
mtlr r0
addi r1, r1, 0x80
blr
}
#endif
s32 NWC24GetErrorCode() {
return GlobalErrorCode;
}
void NWC24iSetErrorCode(s32 code) {
GlobalErrorCode = code;
}
NWC24Err NWC24InitFiles(void* work, BOOL force) {
NWC24Err result = NWC24BlockOpenMsgLib(TRUE);
NWC24Err result2;
if (result != NWC24_OK) {
return result;
}
NWC24SuspendScheduler();
result = InitAllFiles(work, force, force, force, force);
if (result == NWC24_OK) {
NWC24UserId userId;
u32 arg1;
result = NWC24iRequestGenerateUserId(&userId, &arg1);
if (result == NWC24_ERR_ID_GENERATED || result == NWC24_ERR_ID_REGISTERED) {
result = NWC24_OK;
}
}
NWC24ResumeScheduler();
result2 = NWC24BlockOpenMsgLib(FALSE);
if (result != NWC24_OK) {
return result;
}
return result2;
}
NWC24Err NWC24InitFilesIndividually(void* work, BOOL forceConfig, BOOL forceMBox, BOOL forceFriendList, BOOL forceDlTask) {
NWC24Err result = NWC24BlockOpenMsgLib(TRUE);
if (result != NWC24_OK) {
return result;
}
NWC24SuspendScheduler();
result = InitAllFiles(work, forceConfig, forceMBox, forceFriendList, forceDlTask);
NWC24ResumeScheduler();
NWC24BlockOpenMsgLib(FALSE);
if (result != NWC24_OK) {
return result;
}
}
NWC24Err InitAllFiles(NWC24Work* work, BOOL forceConfig, BOOL forceMBox, BOOL forceFriendList, BOOL forceDlTask) {
NWC24Err result;
if ((u32)work % 32 != 0) {
return NWC24_ERR_ALIGNMENT;
}
NWC24WorkP = work;
result = NWC24iInitMsgBoxDir(forceMBox);
if (result != NWC24_OK) {
return result;
}
result = NWC24iInitMBox();
if (result != NWC24_OK) {
return result;
}
result = NWC24iConfigInit(forceConfig);
if (result != NWC24_OK) {
return result;
}
result = NWC24iInitFriendList(forceFriendList);
if (result != NWC24_OK) {
return result;
}
result = NWC24iInitSecretFriendList(forceFriendList);
if (result != NWC24_OK) {
return result;
}
return NWC24iInitDlTaskList(forceDlTask);
}
NWC24Err NWC24iInitMsgBoxDir(BOOL force) {
char path[0x40];
const char* mboxDir = NWC24GetMBoxDir();
char* p;
u32 num;
s32 result;
int slashCount;
Mail_strcpy(path, mboxDir);
p = path + 1;
while (*p != '\0') {
if (*p == '/') {
*p = '\0';
break;
}
p++;
}
result = NANDPrivateReadDir(path, NULL, &num);
if (result != 0) {
return NWC24_ERR_FATAL;
}
Mail_strcpy(path, mboxDir);
p = path + 1;
slashCount = 0;
while (*p != '\0') {
if (*p == '/') {
slashCount++;
if (slashCount == 2) {
*p = '\0';
break;
}
}
p++;
}
result = NANDPrivateReadDir(path, NULL, &num);
if (result == -12) {
result = NWC24CreateDir(path);
if (result != NWC24_OK) {
return NWC24_ERR_FATAL;
}
} else if (result != 0) {
return NWC24_ERR_FATAL;
}
if (force) {
result = NANDPrivateDelete(mboxDir);
if (result != 0 && result != -12) {
if (result == -4) {
return -38;
}
return NWC24_ERR_FATAL;
}
}
result = NWC24CreateDir(mboxDir);
if (result != -15 && result != 0) {
return NWC24_ERR_FATAL;
}
return NWC24_OK;
}
NWC24Err AnalyzeScdErrors(s32* errorCode, u32 usage) {
NWC24ScdStat* stat;
NWC24Err result;
u32 totalScore;
u32 numErrors;
u32 i;
u32 count;
s32 index;
u32 score;
stat = (NWC24ScdStat*)nwc24Work->mainWork;
totalScore = 0;
*errorCode = 0;
result = NWC24iGetSchedulerStat(stat, sizeof(NWC24ScdStat));
if (result == NWC24_ERR_FATAL || result == NWC24_ERR_NOMEM || result == NWC24_ERR_INTERNAL_IPC) {
*errorCode = NWC24iMakeCode(NWC24_ERRCODE_1091XX, result);
return NWC24_ERR_FATAL;
}
if (result != NWC24_OK) {
return NWC24_OK;
}
if ((usage & 1) != 0) {
if ((stat->mailTaskTrace & 3) == 3) {
return NWC24_OK;
}
} else if ((usage & 2) != 0 && (stat->dlTaskTrace & 15) == 15) {
return NWC24_OK;
}
numErrors = stat->numErrors;
if (numErrors < 32) {
i = numErrors;
} else {
i = 32;
}
count = 0;
index = (s32)(numErrors + 31) % 32;
for (; count < i; count++) {
result = AnalyzeErrorCode(stat->errorLog[index], usage, &score);
if (result != NWC24_OK) {
totalScore += score;
if (totalScore >= 60) {
*errorCode = stat->errorLog[index];
return result;
}
}
if (--index < 0) {
index = 31;
}
}
*errorCode = 0;
return NWC24_OK;
}
NWC24Err AnalyzeErrorCode(s32 errorCode, u32 usage, u32* score) {
char digit[6];
int i;

View File

@@ -108,6 +108,57 @@ NWC24Err NWC24SetMsgToId(NWC24MsgObj* msg, NWC24UserId id) {
return NWC24_OK;
}
NWC24Err NWC24SetMsgToAddr(NWC24MsgObj* msg, const char* addr, u32 length) {
NWC24MsgObjPrivate* msgObj = (NWC24MsgObjPrivate*)msg;
if (!(msgObj->type & MSG_OBJ_INITIALIZED) || (msgObj->type & MSG_OBJ_DELIVERING)) {
return NWC24_ERR_PROTECTED;
}
if (addr == NULL || addr[0] == '\0') {
return NWC24_ERR_NULL;
}
if (!(msgObj->type & MSG_OBJ_FOR_PUBLIC)) {
return NWC24_ERR_NOT_SUPPORTED;
}
if (msgObj->numTo >= NWC24_MSG_RECIPIENT_MAX) {
return NWC24_ERR_FULL;
}
if (length >= NWC24_MSG_SUBJECT_LENGTH) {
return NWC24_ERR_OVERFLOW;
}
if (addr[length] != '\0') {
return NWC24_ERR_STRING_END;
}
NWC24Data_SetDataP(&msgObj->toAddrs[msgObj->numTo], addr, length);
msgObj->numTo++;
return NWC24_OK;
}
NWC24Err NWC24SetMsgSubject(NWC24MsgObj* msg, const char* subject, u32 length) {
NWC24MsgObjPrivate* msgObj = (NWC24MsgObjPrivate*)msg;
if (!(msgObj->type & MSG_OBJ_INITIALIZED) || (msgObj->type & MSG_OBJ_DELIVERING)) {
return NWC24_ERR_PROTECTED;
}
if (subject == NULL || subject[0] == '\0') {
return NWC24_ERR_NULL;
}
if (subject[length] != '\0') {
return NWC24_ERR_STRING_END;
}
NWC24Data_SetDataP(&msgObj->subject, subject, length);
return NWC24_OK;
}
NWC24Err NWC24SetMsgText(NWC24MsgObj* msg, const char* text, u32 len, NWC24Charset charset, NWC24Encoding encoding) {
NWC24MsgObjPrivate* msgObj = (NWC24MsgObjPrivate*)msg;
@@ -136,7 +187,8 @@ NWC24Err NWC24SetMsgText(NWC24MsgObj* msg, const char* text, u32 len, NWC24Chars
if (encoding == NWC24_ENC_7BIT) {
u32 lineLength = 0;
const char* it;
for (it = text; it < text + len; it++) {
const char* end = text + len;
for (it = text; it < end; it++) {
if (it[0] == '\r' && it[1] == '\n') {
lineLength = 0;
it++;
@@ -153,3 +205,296 @@ NWC24Err NWC24SetMsgText(NWC24MsgObj* msg, const char* text, u32 len, NWC24Chars
msgObj->encoding = encoding;
return NWC24_OK;
}
NWC24Err NWC24SetMsgAttached(NWC24MsgObj* msg, const void* attachData, u32 attachSize, NWC24MIMEType type) {
NWC24MsgObjPrivate* msgObj = (NWC24MsgObjPrivate*)msg;
u32 i;
u32 totalSize = 0;
if (!(msgObj->type & MSG_OBJ_INITIALIZED) || (msgObj->type & MSG_OBJ_DELIVERING)) {
return NWC24_ERR_PROTECTED;
}
if (attachData == NULL || attachSize == 0) {
return NWC24_ERR_NULL;
}
if (msgObj->numAttached >= NWC24_MSG_ATTACHMENT_MAX) {
return NWC24_ERR_FULL;
}
if (NWC24GetMIMETypeStr(type) == NULL) {
return NWC24_ERR_INVALID_VALUE;
}
if ((msgObj->type & MSG_OBJ_FOR_PUBLIC) && type != NWC24_TEXT_PLAIN && type != NWC24_TEXT_HTML && type != NWC24_IMAGE_JPEG &&
type != NWC24_APPLICATION_OCTET_STREAM) {
return NWC24_ERR_NOT_SUPPORTED;
}
if (type == NWC24_X_WII_MINIDATA && attachSize > 0x80) {
return NWC24_ERR_INVALID_VALUE;
}
for (i = 0; i < msgObj->numAttached; i++) {
totalSize += msgObj->attachedSize[i];
}
totalSize += attachSize;
if (totalSize >= 0x245B0) {
return NWC24_ERR_OVERFLOW;
}
NWC24Data_SetDataP(&msgObj->attached[msgObj->numAttached], attachData, attachSize);
msgObj->attachedSize[msgObj->numAttached] = attachSize;
msgObj->attachedType[msgObj->numAttached] = type;
msgObj->numAttached++;
msgObj->type |= 0x10000;
return NWC24_OK;
}
NWC24Err NWC24SetMsgFaceData(NWC24MsgObj* msg, const void* faceData) {
NWC24MsgObjPrivate* msgObj = (NWC24MsgObjPrivate*)msg;
if (!(msgObj->type & MSG_OBJ_INITIALIZED) || (msgObj->type & MSG_OBJ_DELIVERING)) {
return NWC24_ERR_PROTECTED;
}
if (msgObj->faceData.size != 0) {
return NWC24_ERR_FULL;
}
NWC24Data_SetDataP(&msgObj->faceData, faceData, NWC24_FACE_DATA_SIZE);
return NWC24_OK;
}
NWC24Err NWC24SetMsgMBNoReply(NWC24MsgObj* msg, BOOL mbNoReplyFlag) {
NWC24MsgObjPrivate* msgObj = (NWC24MsgObjPrivate*)msg;
if (!(msgObj->type & MSG_OBJ_INITIALIZED) || (msgObj->type & MSG_OBJ_DELIVERING)) {
return NWC24_ERR_PROTECTED;
}
if (!(msgObj->type & MSG_OBJ_FOR_MENU)) {
return NWC24_ERR_NOT_SUPPORTED;
}
if (mbNoReplyFlag) {
msgObj->msgBoardFlags.noreply = 1;
} else {
msgObj->msgBoardFlags.noreply = 0;
}
return NWC24_OK;
}
NWC24Err NWC24SetMsgMBRegDate(NWC24MsgObj* msg, u16 year, u8 month, u8 day) {
NWC24MsgObjPrivate* msgObj = (NWC24MsgObjPrivate*)msg;
NWC24Err err;
if (!(msgObj->type & MSG_OBJ_INITIALIZED) || (msgObj->type & MSG_OBJ_DELIVERING)) {
return NWC24_ERR_PROTECTED;
}
if (!(msgObj->type & MSG_OBJ_FOR_MENU)) {
return NWC24_ERR_NOT_SUPPORTED;
}
if (year < 2000 || year > 2035) {
return NWC24_ERR_INVALID_VALUE;
}
err = NWC24iIsValidDate(year, month, day);
if (err != NWC24_OK) {
return err;
}
msgObj->msgBoardFlags.raw = (msgObj->msgBoardFlags.raw & 0xFFFF0000) |
((((year - 2000) << 9) | (month << 5) | day) & 0xFFFF);
return NWC24_OK;
}
NWC24Err NWC24SetMsgAppId(NWC24MsgObj* msg, u32 appId) {
NWC24MsgObjPrivate* msgObj = (NWC24MsgObjPrivate*)msg;
if (!(msgObj->type & MSG_OBJ_INITIALIZED) || (msgObj->type & MSG_OBJ_DELIVERING)) {
return NWC24_ERR_PROTECTED;
}
if (!NWC24IsMsgLibOpenedByTool() && NWC24GetAppId() != 0x48414541) {
return NWC24_ERR_PROTECTED;
}
msgObj->appId = appId;
return NWC24_OK;
}
NWC24Err NWC24SetMsgLedPattern(NWC24MsgObj* msg, int ledPattern) {
NWC24MsgObjPrivate* msgObj = (NWC24MsgObjPrivate*)msg;
if (!(msgObj->type & MSG_OBJ_INITIALIZED) || (msgObj->type & MSG_OBJ_DELIVERING)) {
return NWC24_ERR_PROTECTED;
}
if (ledPattern == 0) {
return NWC24_ERR_INVALID_VALUE;
}
if (!(msgObj->type & MSG_OBJ_FOR_RECIPIENT) || !(msgObj->type & MSG_OBJ_FOR_MENU)) {
return NWC24_ERR_NOT_SUPPORTED;
}
if (msgObj->ledPattern != 0 && !(msgObj->ledPattern & (1 << 18))) {
return NWC24_ERR_NOT_SUPPORTED;
}
if (!NWC24IsMsgLibOpenedByTool() && NWC24GetAppId() != 0x48414541 && (u32)ledPattern >= 0x4000) {
return NWC24_ERR_INVALID_VALUE;
}
msgObj->ledPattern = ledPattern | (1 << 18);
return NWC24_OK;
}
NWC24Err NWC24GetMsgType(const NWC24MsgObj* msg, NWC24MsgType* type) {
const NWC24MsgObjPrivate* msgObj = (const NWC24MsgObjPrivate*)msg;
u32 flags = msgObj->type;
if (flags & MSG_OBJ_FOR_RECIPIENT) {
if (flags & MSG_OBJ_FOR_APP) {
if (flags & MSG_OBJ_FOR_MENU) {
*type = NWC24_MSGTYPE_RVL_MENU_SHARED;
} else {
*type = NWC24_MSGTYPE_RVL;
}
} else if (flags & MSG_OBJ_FOR_MENU) {
*type = NWC24_MSGTYPE_RVL_MENU;
} else {
*type = NWC24_MSGTYPE_RVL_HIDDEN;
}
} else if (flags & MSG_OBJ_FOR_PUBLIC) {
*type = NWC24_MSGTYPE_PUBLIC;
} else {
return NWC24_ERR_INVALID_VALUE;
}
return NWC24_OK;
}
NWC24Err NWC24GetMsgSubjectSize(const NWC24MsgObj* msg, u32* subjectSize) {
const NWC24MsgObjPrivate* msgObj = (const NWC24MsgObjPrivate*)msg;
u32 size = msgObj->subject.size;
if (size != 0) {
*subjectSize = size + 1;
} else {
*subjectSize = 0;
}
return NWC24_OK;
}
NWC24Err NWC24GetMsgTextSize(const NWC24MsgObj* msg, u32* textSize) {
const NWC24MsgObjPrivate* msgObj = (const NWC24MsgObjPrivate*)msg;
u32 size = msgObj->textSize;
if (size != 0) {
*textSize = size + 1;
} else {
size = msgObj->text.size;
if (size != 0) {
*textSize = size + 1;
} else {
*textSize = 0;
}
}
return NWC24_OK;
}
NWC24Err NWC24GetMsgNumAttached(const NWC24MsgObj* msg, u32* numAttach) {
const NWC24MsgObjPrivate* msgObj = (const NWC24MsgObjPrivate*)msg;
u8 numAttached = msgObj->numAttached;
*numAttach = numAttached;
if (numAttached > NWC24_MSG_ATTACHMENT_MAX) {
return NWC24_ERR_BROKEN;
}
return NWC24_OK;
}
NWC24Err NWC24GetMsgAttachedSize(const NWC24MsgObj* msg, u32 attachIndex, u32* attachSize) {
const NWC24MsgObjPrivate* msgObj = (const NWC24MsgObjPrivate*)msg;
if (attachIndex >= NWC24_MSG_ATTACHMENT_MAX || attachIndex >= msgObj->numAttached) {
return NWC24_ERR_INVALID_VALUE;
}
*attachSize = msgObj->attachedSize[attachIndex];
return NWC24_OK;
}
NWC24Err NWC24GetMsgAttachedType(const NWC24MsgObj* msg, u32 attachIndex, NWC24MIMEType* attachType) {
const NWC24MsgObjPrivate* msgObj = (const NWC24MsgObjPrivate*)msg;
u32 flags;
NWC24MIMEType type;
if (attachIndex >= NWC24_MSG_ATTACHMENT_MAX || attachIndex >= msgObj->numAttached) {
return NWC24_ERR_INVALID_VALUE;
}
flags = msgObj->type;
type = msgObj->attachedType[attachIndex];
*attachType = type;
if ((flags & MSG_OBJ_FOR_PUBLIC) && !(flags & (1 << 12))) {
if (type != NWC24_TEXT_PLAIN && type != NWC24_TEXT_HTML && type != NWC24_IMAGE_JPEG && type != NWC24_APPLICATION_OCTET_STREAM) {
*attachType = 0;
}
}
return NWC24_OK;
}
NWC24Err NWC24GetMsgAppId(const NWC24MsgObj* msg, u32* appId) {
const NWC24MsgObjPrivate* msgObj = (const NWC24MsgObjPrivate*)msg;
*appId = msgObj->appId;
return NWC24_OK;
}
NWC24Err NWC24GetMsgGroupId(const NWC24MsgObj* msg, u16* groupId) {
const NWC24MsgObjPrivate* msgObj = (const NWC24MsgObjPrivate*)msg;
*groupId = msgObj->groupId;
return NWC24_OK;
}
NWC24Err NWC24GetMsgFromId(const NWC24MsgObj* msg, NWC24UserId* fromId) {
const NWC24MsgObjPrivate* msgObj = (const NWC24MsgObjPrivate*)msg;
if (!(msgObj->type & MSG_OBJ_FOR_RECIPIENT)) {
return NWC24_ERR_NOT_SUPPORTED;
}
*fromId = msgObj->fromId;
return NWC24_OK;
}
NWC24Err NWC24GetMsgDate(const NWC24MsgObj* msg, OSCalendarTime* msgDate) {
const NWC24MsgObjPrivate* msgObj = (const NWC24MsgObjPrivate*)msg;
NWC24iMinutesToOSCalendarTime(msgDate, msgObj->unk_0x28);
return NWC24_OK;
}
NWC24Err NWC24GetMsgIconNewSign(const NWC24MsgObj* msg, u32* iconNewSign) {
const NWC24MsgObjPrivate* msgObj = (const NWC24MsgObjPrivate*)msg;
u32 flags = msgObj->type;
u32 iconNew;
if ((flags & MSG_OBJ_FOR_MENU) || (flags & MSG_OBJ_FOR_PUBLIC)) {
return NWC24_ERR_NOT_FOUND;
}
iconNew = msgObj->iconNew;
*iconNewSign = iconNew;
if (iconNew == 0 || iconNew == (1 << 31)) {
return NWC24_ERR_NOT_FOUND;
}
return NWC24_OK;
}

View File

@@ -3,31 +3,409 @@
#include <ctype.h>
char* Mail_strcpy(char* dest, const char* src) {
char* pDest;
char cSrc;
for (pDest = dest; *src != 0; pDest++) {
cSrc = *src++;
*pDest = cSrc;
char* Mail_strcpy(char* pDst, const char* pSrc) {
char* pOrigin = pDst;
while (*pSrc != '\0') {
*pDst++ = *pSrc++;
}
*pDest = 0;
return dest;
*pDst = '\0';
return pOrigin;
}
int Mail_strlen(const char* str) {
int i;
for (i = 0; *str != 0; i++, str++) {
int Mail_strlen(const char* pStr) {
int len = 0;
while (pStr[len] != '\0') {
len++;
}
return i;
return len;
}
int STD_strnlen(const char* str, u32 len) {
int i;
for (i = 0; i < len; i++, str++) {
if (*str == 0) {
int STD_strnlen(const char* pStr, size_t maxlen) {
size_t len = 0;
for (; len < maxlen; len++) {
if (pStr[len] == '\0') {
break;
}
}
return i;
return len;
}
void* Mail_memcpy(void* pDst, const void* pSrc, u32 n) {
size_t i;
for (i = 0; i < n; i++) {
((u8*)pDst)[i] = ((u8*)pSrc)[i];
}
return pDst;
}
void* Mail_memset(void* pDst, int ch, u32 n) {
size_t i;
for (i = 0; i < n; i++) {
((u8*)pDst)[i] = ch;
}
return pDst;
}
char* Mail_strncpy(char* dest, const char* src, u32 len) {
u32 i;
i = 0;
for (; i < len; i++) {
dest[i] = src[i];
if (src[i] == 0) {
while (++i < len) {
dest[i] = 0;
}
return dest;
}
}
return dest;
}
char* Mail_strcat(char* pDst, const char* pSrc) {
Mail_strcpy(pDst + Mail_strlen(pDst), pSrc);
return pDst;
}
char* Mail_strncat(char* pDst, const char* pSrc, u32 maxlen) {
int len = Mail_strlen(pDst);
int i;
for (i = 0; i < maxlen && pSrc[i] != '\0'; i++) {
pDst[len + i] = pSrc[i];
}
pDst[len + i] = '\0';
return pDst;
}
int Mail_strncmp(const char* str1, const char* str2, u32 len) {
int i;
char c1;
char c2;
int result;
result = 0;
for (i = 0; i < len; i++) {
c2 = *str2;
c1 = *str1;
result = c1 - c2;
if (result != 0) {
break;
}
if (c2 == 0) {
break;
}
str1++;
str2++;
}
return result;
}
int Mail_isdigit(int ch) {
if (ch >= '0' && ch <= '9') {
return 1;
}
return 0;
}
int Util_xtoi(char ch) {
if (ch >= '0' && ch <= '9') {
return ch - '0';
}
if (ch >= 'A' && ch <= 'F') {
return ch - 0x37;
}
if (ch >= 'a' && ch <= 'f') {
return ch - 0x57;
}
return -1;
}
int Mail_tolower(int ch) {
if (ch >= 'A') {
if (ch <= 'Z') {
return ch + 0x20;
}
}
return ch;
}
static void set_to_head(char* pStr, char ch) {
int i;
for (i = Mail_strlen(pStr); i >= 0; i--) {
pStr[i + 1] = pStr[i];
}
*pStr = ch;
}
static void set_to_tail(char* pStr, char ch) {
int i = Mail_strlen(pStr);
pStr[i++] = ch;
pStr[i] = '\0';
}
static s32 convNum(char* pDst, u32 number, s32 numberBase, char charBase,
BOOL isSigned, s32 width, char specifierChar,
char justifyChar) {
s32 charsWritten;
s32 digitsWritten;
char remainder;
if (isSigned && (number & 0x80000000)) {
isSigned = TRUE;
number = -number;
} else {
isSigned = FALSE;
number = number;
}
charsWritten = digitsWritten = 0;
while (number != 0) {
remainder = number % numberBase;
number /= numberBase;
set_to_head(pDst, remainder + (char)(remainder > 9 ? charBase : '0'));
digitsWritten++;
charsWritten++;
}
if (*pDst == '\0') {
set_to_head(pDst, '0');
digitsWritten++;
charsWritten++;
}
if (specifierChar != '0') {
specifierChar = ' ';
}
digitsWritten += isSigned;
while (digitsWritten < width) {
if (justifyChar == 'L') {
set_to_tail(pDst, ' ');
charsWritten++;
} else {
set_to_head(pDst, specifierChar);
charsWritten++;
}
digitsWritten++;
}
if (isSigned) {
set_to_head(pDst, '-');
}
return charsWritten;
}
int Mail_sprintf(char* pDst, char* pFmt, ...) {
va_list argv;
int ret;
va_start(argv, pFmt);
ret = Mail_vsprintf(pDst, pFmt, &argv);
va_end(argv);
return ret;
}
int Mail_vsprintf(char* pDst, char* pFmt, va_list* argv) {
int charsWritten;
BOOL isNumberFormat;
BOOL isSigned;
s32 stringLength;
s32 numberBase;
s32 width;
char formatChar;
char justifyChar;
char specifierChar;
char charBase;
char* pStrArg;
char longFlag;
u32 number;
*pDst = 0;
charsWritten = 0;
while ((formatChar = *pFmt++) != '\0') {
while (*pDst != '\0') {
pDst++;
}
if (formatChar == '%') {
formatChar = *pFmt++;
if (formatChar == '%') {
set_to_tail(pDst++, formatChar);
charsWritten++;
} else {
justifyChar = formatChar;
if (formatChar == '-') {
formatChar = *pFmt++;
}
specifierChar = formatChar;
isSigned = FALSE;
numberBase = 10;
charBase = '0';
isNumberFormat = FALSE;
if (formatChar == '*') {
width = va_arg(*argv, s32);
formatChar = *pFmt++;
} else {
width = 0;
while (formatChar >= '0' && formatChar <= '9') {
width = width * 10 + formatChar - '0';
formatChar = *pFmt++;
}
}
if ((longFlag = formatChar & (u8)~0x20) == 'L') {
formatChar = *pFmt++;
}
switch (formatChar) {
case 'd': {
isNumberFormat = TRUE;
isSigned = TRUE;
break;
}
case 'o': {
isNumberFormat = TRUE;
numberBase = 8;
break;
}
case 'u': {
isNumberFormat = TRUE;
break;
}
case 'x': {
isNumberFormat = TRUE;
numberBase = 16;
charBase = 'a' - 10;
break;
}
case 'X': {
isNumberFormat = TRUE;
numberBase = 16;
charBase = 'A' - 10;
break;
}
case 'c': {
formatChar = va_arg(*argv, s32);
set_to_tail(pDst++, formatChar);
charsWritten++;
break;
}
case 's': {
pStrArg = va_arg(*argv, char*);
if (pStrArg) {
stringLength = Mail_strlen(pStrArg);
Mail_strcat(pDst, pStrArg);
} else {
stringLength = 0;
}
charsWritten += stringLength;
while (stringLength < width) {
charsWritten++;
if (justifyChar == '-') {
set_to_tail(pDst, ' ');
} else {
set_to_head(pDst, ' ');
}
stringLength++;
}
break;
}
}
if (isNumberFormat) {
if (longFlag == 'L') {
number = va_arg(*argv, u32);
} else if (isSigned) {
number = va_arg(*argv, s32);
} else {
number = va_arg(*argv, u32);
}
charsWritten +=
convNum(pDst, number, numberBase, charBase, isSigned,
width, specifierChar, justifyChar);
}
}
} else {
set_to_tail(pDst++, formatChar);
charsWritten++;
}
}
return charsWritten;
}
int Mail_strnicmp(const char* str1, const char* str2, int len) {
int i;
int c2;
int c1;
int result;
result = 0;
for (i = 0; i < len; i++) {
c1 = *str1;
c2 = *str2;
if (c1 >= 'A') {
if (c1 <= 'Z') {
c1 += 0x20;
}
}
if (c2 >= 'A') {
if (c2 <= 'Z') {
c2 += 0x20;
}
}
result = c1 - c2;
if (result != 0) {
break;
}
if (c2 == 0) {
break;
}
str2++;
str1++;
}
return result;
}

View File

@@ -1,19 +1,257 @@
#include <private/nwc24.h>
#include <revolution/nwc24.h>
const u8 TtableInv[] = {13, 5, 9, 7, 0, 15, 10, 2, 12, 3, 14, 1, 8, 6, 11, 4};
const u8 ExcTable[] = {1, 5, 0, 4, 2, 3, 6, 7};
static const u8 TtableInv[] = {13, 5, 9, 7, 0, 15, 10, 2, 12, 3, 14, 1, 8, 6, 11, 4};
extern void _savegpr_27(void);
extern void _restgpr_27(void);
extern void __shr2u(void);
extern void __shl2i(void);
static u8 getbyte(NWC24UserId value, u8 index);
static NWC24UserId setbyte(NWC24UserId value, u8 index, u8 set);
NWC24UserId getUnScrambleId(NWC24UserId id);
static int checkCRC(NWC24UserId id);
static u8 getbyte(NWC24UserId value, u8 index) {
return (value >> (index * 8)) & 0xFF;
static NWC24UserId getUnScrambleId(NWC24UserId id);
asm NWC24Err NWC24CheckUserId(register NWC24UserId id) {
stwu r1,-0x30(r1)
mfspr r0,LR
stw r0,0x34(r1)
addi r11,r1,0x30
bl _savegpr_27
or r28,r3,r3
or r27,r4,r4
addi r3,r1,0x8
bl NWC24GetMyUserId
lwz r3,0x8(r1)
lwz r4,0xc(r1)
xor r0,r3,r28
xor r5,r4,r27
or. r0,r5,r0
bne NWC24CheckUserId_not_same
li r3,-0x23
b NWC24CheckUserId_return
NWC24CheckUserId_not_same:
bl getUnScrambleId
or r4,r27,r27
rlwinm r27,r3,0x11,0x1d,0x1f
or r3,r28,r28
bl getUnScrambleId
or r30,r4,r4
or r31,r3,r3
rlwinm r28,r3,0x11,0x1d,0x1f
li r29,0
NWC24CheckUserId_crc_loop:
addi r0,r29,1
or r3,r31,r31
or r4,r30,r30
subfic r5,r0,0x35
bl __shr2u
rlwinm. r0,r4,0,0x1f,0x1f
beq NWC24CheckUserId_crc_next
subfic r5,r29,0x2a
li r4,0x635
li r3,0
bl __shl2i
xor r30,r30,r4
xor r31,r31,r3
NWC24CheckUserId_crc_next:
addi r29,r29,1
cmpwi r29,0x2b
blt NWC24CheckUserId_crc_loop
or. r0,r30,r31
beq NWC24CheckUserId_crc_ok
li r3,-0x25
b NWC24CheckUserId_return
NWC24CheckUserId_crc_ok:
cmpwi r27,0
bne NWC24CheckUserId_return_ok
cmpwi r28,0
beq NWC24CheckUserId_return_ok
li r3,-0x7
b NWC24CheckUserId_return
NWC24CheckUserId_return_ok:
li r3,0
NWC24CheckUserId_return:
addi r11,r1,0x30
bl _restgpr_27
lwz r0,0x34(r1)
mtspr LR,r0
addi r1,r1,0x30
blr
}
static NWC24UserId setbyte(NWC24UserId value, u8 index, u8 set) {
return (value & ~(((u64)0xFF << (index * 8)))) | (((u64)set << (index * 8)));
NWC24Err NWC24iCheckUserIdCRC(NWC24UserId id) {
u64 value = getUnScrambleId(id);
int i;
for (i = 0; i < 0x2B; i++) {
if ((value >> (0x35 - (i + 1))) & 1) {
value ^= (u64)0x635 << (0x2A - i);
}
}
if (value != 0) {
return NWC24_ERR_ID_CRC;
}
return NWC24_OK;
}
static asm NWC24UserId getUnScrambleId(register NWC24UserId id) {
li r9,-1
lis r7,0x20
lis r6,0x5e5e
stwu r1,-0x20(r1)
subi r7,r7,1
and r8,r4,r9
addi r0,r6,0x5e5e
stw r31,0x1c(r1)
and r3,r3,r7
lis r5,-1
xor r8,r8,r0
stw r30,0x18(r1)
and r8,r8,r9
xori r3,r3,0x5e5e
rlwinm r0,r8,0x15,0xa,0xa
li r6,-0x100
and r3,r3,r7
rlwinm r8,r8,0x1f,0,0x1f
or r3,r3,r0
stw r29,0x14(r1)
rlwimi r8,r3,0x1f,0,0
lis r4,-0xff
rlwinm r7,r3,0x1f,1,0x1f
addi r5,r5,0xff
rlwinm r30,r8,0x18,0,0x1f
rlwinm r29,r3,0x17,0x18,0x1f
and r12,r7,r9
li r0,0
rlwimi r30,r3,0x17,0,7
and r31,r8,r6
rlwimi r31,r30,0,0x18,0x1f
rlwinm r11,r3,0x1f,0x10,0x17
and r30,r31,r5
and r12,r12,r9
rlwimi r0,r29,8,0x18,0x1f
subi r4,r4,1
or r12,r12,r0
or r11,r30,r11
and r30,r11,r4
rlwinm r31,r8,0,0x18,0x1f
li r0,0
rlwinm r11,r8,0x10,8,0xf
lis r10,0x100
and r12,r12,r9
rlwimi r0,r31,0x10,0x10,0x1f
or r30,r30,r11
or r29,r12,r0
rlwinm r12,r3,0x1f,0x18,0x1f
subi r0,r10,1
li r10,0
rlwimi r10,r12,0x18,8,0x1f
and r11,r29,r9
and r12,r30,r0
rlwinm r3,r3,0x17,0,7
or r3,r12,r3
or r12,r11,r10
and r10,r3,r9
lis r3,TtableInv@ha
and r31,r10,r9
rlwinm r30,r8,0x10,0,0x1f
rlwinm r11,r31,0x1c,0x1c,0x1f
addi r3,r3,TtableInv@l
rlwimi r30,r7,0x10,0,0xf
rlwinm r10,r31,0,0x1c,0x1f
and r29,r12,r6
rlwinm r12,r8,8,0,0x1f
lbzx r11,r3,r11
rlwimi r12,r7,8,0,0x17
lbzx r7,r3,r10
rlwimi r29,r30,0,0x18,0x1f
rlwinm r8,r11,4,0,0x1b
rlwinm r10,r12,8,0x10,0x17
and r11,r29,r5
or r10,r11,r10
or r7,r8,r7
and r11,r31,r6
li r8,0
rlwimi r11,r7,0,0x18,0x1f
and r12,r10,r9
rlwinm r10,r11,0x18,0,0x1f
li r7,0
rlwimi r10,r12,0x18,0,7
and r31,r11,r5
rlwinm r11,r10,0x1c,0x1c,0x1f
and r12,r12,r9
rlwinm r10,r10,0,0x1c,0x1f
lbzx r11,r3,r11
lbzx r10,r3,r10
rlwinm r11,r11,4,0,0x1b
or r10,r11,r10
rlwinm r11,r10,0,0x18,0x1f
rlwinm r10,r10,8,0x10,0x17
rlwimi r8,r11,8,0x18,0x1f
or r10,r31,r10
or r8,r12,r8
rlwinm r12,r10,0x10,0,0x1f
and r11,r10,r4
rlwimi r12,r8,0x10,0,0xf
and r10,r8,r9
rlwinm r8,r12,0x1c,0x1c,0x1f
rlwinm r4,r12,0,0x1c,0x1f
lbzx r8,r3,r8
lbzx r4,r3,r4
rlwinm r8,r8,4,0,0x1b
or r4,r8,r4
rlwinm r8,r4,0,0x18,0x1f
rlwinm r4,r4,0x10,8,0xf
or r29,r11,r4
rlwimi r7,r8,0x10,0x10,0x1f
or r11,r10,r7
lis r4,1
rlwinm r8,r29,8,0,0x1f
and r31,r29,r0
rlwimi r8,r11,8,0,0x17
and r12,r11,r9
rlwinm r10,r8,0x1c,0x1c,0x1f
subi r0,r4,0x4c4d
lbzx r11,r3,r10
rlwinm r8,r8,0,0x1c,0x1f
lbzx r10,r3,r8
li r8,0
rlwinm r11,r11,4,0,0x1b
lis r7,-0x4c4c
or r11,r11,r10
rlwinm r10,r11,0,0x18,0x1f
subi r7,r7,0x4c4d
rlwimi r8,r10,0x18,8,0x1f
rlwinm r4,r11,0x18,0,7
or r10,r12,r8
rlwinm r8,r10,0x1c,0x1c,0x1f
or r12,r31,r4
rlwinm r4,r10,0,0x1c,0x1f
lbzx r8,r3,r8
and r11,r10,r6
lbzx r4,r3,r4
rlwinm r6,r8,4,0,0x1b
and r8,r12,r9
or r4,r6,r4
rlwimi r11,r4,0,0x18,0x1f
and r10,r8,r9
rlwinm r6,r11,0x14,0x1c,0x1f
rlwinm r4,r11,0x18,0x1c,0x1f
lbzx r6,r3,r6
lbzx r3,r3,r4
and r8,r11,r5
rlwinm r5,r6,4,0,0x1b
and r4,r10,r9
or r3,r5,r3
rlwinm r3,r3,8,0x10,0x17
or r3,r8,r3
rlwinm r5,r3,0xa,0xb,0x15
rlwinm r3,r3,0x15,0x16,0x1f
rlwimi r5,r4,0xa,0x16,0x1f
rlwimi r3,r4,0xa,0,0x15
xor r4,r3,r7
xor r3,r5,r0
lwz r31,0x1c(r1)
lwz r30,0x18(r1)
lwz r29,0x14(r1)
addi r1,r1,0x20
blr
}

View File

@@ -0,0 +1,713 @@
#include <revolution/ncd.h>
#include <revolution/os.h>
#include <revolution/soex.h>
#include <private/ios.h>
#include <private/nwc24/NWC24Schedule.h>
#include <private/os/OSTime.h>
#include <string.h>
typedef struct SOSysWork {
SOAlloc allocFunc;
SOFree freeFunc;
s32 rmState;
s32 rmFd;
u32 unk10;
s32 allocCount;
} SOSysWork;
enum {
SO_INTERNAL_STATE_TERMINATED = 0,
SO_INTERNAL_STATE_READY = 1,
SO_INTERNAL_STATE_ACTIVE = 2,
};
enum {
SO_INTERNAL_RM_STATE_OPENED = 0,
SO_INTERNAL_RM_STATE_WORKING = -1,
SO_INTERNAL_RM_STATE_CLOSED = -2,
};
enum {
SO_SUCCESS = 0,
SO_EFATAL = (s32)0x80000000,
SO_EAGAIN = -6,
SO_EALREADY = -7,
SO_EBUSY = -10,
SO_EINPROGRESS = -26,
SO_EINVAL = -28,
SO_ENETRESET = -39,
SO_ENOENT = -45,
SO_ENOLINK = -48,
SO_ENOMEM = -49,
SO_ETIMEDOUT = -76,
};
enum {
SO_ERR_LINK_UP_TIMEOUT = -121,
};
enum {
NCD_LINKSTATUS_WORKING = 1,
NCD_LINKSTATUS_NONE = 2,
};
enum {
NET_SO_SOCKET = 0xF,
};
typedef struct NETSoSocket {
int af;
int type;
int protocol;
} NETSoSocket;
static s32 soRegistered;
static s32 soError;
static u8 soState;
static SOSysWork soWork;
const char* __SOVersion =
"<< RVL_SDK - SO \trelease build: Dec 12 2008 03:06:16 (0x4199_60831) >>";
static int soBufAddrCheck = 1;
static char NET_RM_SOCK[] = "/dev/net/ip/top";
extern OSTime __OSGetSystemTime(void);
static int SOStartupErr(s32 errNwc24, s32 exErr);
void* SOiAlloc(u32 name, s32 size);
void SOiFree(u32 name, void* ptr, s32 size);
int SOiPrepare(const char* funcName, s32* pRmId);
int SOiConclude(const char* funcName, int result);
int SOiWaitForDHCPEx(int timeout);
int SOCleanup(void);
int SOiConcludeTempRm(const char* funcName, int result, int isTempRm);
int SOInit(SOLibraryConfig* config) {
int result = 0;
int enabled;
void* ptr;
OSThread* cur;
SOSysWork* work;
enabled = OSDisableInterrupts();
if (!soRegistered) {
OSRegisterVersion(__SOVersion);
soRegistered = 1;
}
if (!((int)soState == 0 || (int)soState < 0 || (int)soState >= 3)) {
result = -7;
goto finish;
}
if (config == NULL || config->alloc == NULL || config->free == NULL) {
result = -28;
} else {
memset(&soWork, 0, sizeof(soWork));
soWork.allocFunc = config->alloc;
work = &soWork;
work->freeFunc = config->free;
work->allocCount = 0;
work->rmState = -2;
work->rmFd = -1;
ptr = SOiAlloc(0xB, 0x460);
soWork.unk10 = (u32)ptr;
if (ptr == NULL) {
result = -49;
} else {
soState = 1;
}
}
finish:
cur = OSGetCurrentThread();
if (cur != NULL)
cur->error = result;
else
soError = result;
OSRestoreInterrupts(enabled);
return result;
}
int SOFinish(void) {
int result = 0;
int enabled = OSDisableInterrupts();
OSThread* cur;
switch (soState) {
case SO_INTERNAL_STATE_TERMINATED:
result = SO_EALREADY;
break;
case SO_INTERNAL_STATE_READY:
if (soWork.rmState > SO_INTERNAL_RM_STATE_CLOSED) {
result = SO_EBUSY;
break;
} else if (soWork.allocCount > 1) {
result = SO_EAGAIN;
break;
}
soState = SO_INTERNAL_STATE_TERMINATED;
if (soWork.unk10 != 0 && soWork.freeFunc) {
soWork.allocCount--;
soWork.freeFunc(0x0b, (void*)soWork.unk10, 0x460);
}
break;
case SO_INTERNAL_STATE_ACTIVE:
result = SO_EINPROGRESS;
break;
}
cur = OSGetCurrentThread();
if (cur)
cur->error = result;
else
soError = result;
OSRestoreInterrupts(enabled);
return result;
}
int SOStartup(void) { return SOStartupEx(0x927c0); }
static int SOStartupErr(s32 errNwc24, s32 exErr) {
s32 result = -0x1c;
switch (errNwc24) {
case 0:
result = 0;
break;
case -0x16:
case -0xd:
result = -0x30;
break;
case -0x21:
case -2:
result = exErr;
break;
case -1:
result = -0x80000000;
break;
case -0x1d:
result = -0x1a;
break;
}
return result;
}
int SOStartupEx(int timeout) {
int result;
int enabled;
s32 exErr;
s64 limitTime;
s32 linkupRetryCount;
limitTime = 0;
if (timeout != 0)
limitTime = __OSGetSystemTime() + ((timeout) * ((__OSBusClock / 4) / 1000));
linkupRetryCount = 4;
begin_startup:
result = SO_SUCCESS;
enabled = OSDisableInterrupts();
switch (soState) {
case SO_INTERNAL_STATE_TERMINATED:
default:
result = SO_ENETRESET;
break;
case SO_INTERNAL_STATE_ACTIVE:
result = SO_EALREADY;
break;
case SO_INTERNAL_STATE_READY:
if (soWork.rmState > SO_INTERNAL_RM_STATE_CLOSED) {
result = SO_EBUSY;
break;
} else if (!OSGetCurrentThread()) {
result = SO_EFATAL;
break;
} else {
int resultNCD;
soWork.rmState = SO_INTERNAL_RM_STATE_WORKING;
(void)OSRestoreInterrupts(enabled);
while (1) {
resultNCD = NCDGetLinkStatus();
if (resultNCD != NCD_RESULT_INPROGRESS &&
resultNCD != NCD_LINKSTATUS_WORKING)
break;
OSSleepTicks((((s64)100) * ((__OSBusClock / 4) / 1000)));
if (limitTime != 0 && limitTime < __OSGetSystemTime()) {
if (resultNCD == NCD_LINKSTATUS_WORKING)
result = SO_ERR_LINK_UP_TIMEOUT;
else
result = SO_EFATAL;
goto change_state;
}
}
if (resultNCD < NCD_RESULT_SUCCESS) {
result = SO_EFATAL;
goto change_state;
} else if (resultNCD == NCD_LINKSTATUS_NONE) {
result = SO_ENOENT;
goto change_state;
}
while (1) {
soWork.rmFd = IOS_Open(NET_RM_SOCK, 0);
if (soWork.rmFd != -6)
break;
OSSleepTicks((((s64)100) * ((__OSBusClock / 4) / 1000)));
if (limitTime != 0 && limitTime < __OSGetSystemTime()) {
result = SO_EFATAL;
goto change_state;
}
};
if (soWork.rmFd < 0) {
result = SO_EFATAL;
goto change_state;
} else {
s32 errNwc24;
result = SO_SUCCESS;
exErr = SO_SUCCESS;
while (1) {
errNwc24 = NWC24iStartupSocket(&exErr);
if (errNwc24 != NWC24_ERR_INPROGRESS)
break;
OSSleepTicks((((s64)100) * ((__OSBusClock / 4) / 1000)));
if (limitTime != 0 && limitTime < __OSGetSystemTime()) {
result = SO_EFATAL;
break;
}
}
if (result == SO_SUCCESS)
result = SOStartupErr(errNwc24, exErr);
if (result != SO_SUCCESS) {
if (IOS_Close(soWork.rmFd) < 0) {
result = SO_EFATAL;
goto change_state;
} else {
soWork.rmFd = -1;
}
}
}
change_state:
enabled = OSDisableInterrupts();
if (result == SO_SUCCESS) {
soState = SO_INTERNAL_STATE_ACTIVE;
soWork.rmState = SO_INTERNAL_RM_STATE_OPENED;
} else {
soState = 1;
if (result != SO_EFATAL)
soWork.rmState = SO_INTERNAL_RM_STATE_CLOSED;
}
}
break;
}
{
OSThread* cur = OSGetCurrentThread();
if (cur)
cur->error = result;
else
soError = result;
}
(void)OSRestoreInterrupts(enabled);
if (result == 0) {
s64 dhcpTimeOutTicks;
if (limitTime != 0) {
dhcpTimeOutTicks = limitTime - __OSGetSystemTime();
} else {
dhcpTimeOutTicks = 0;
}
if (limitTime != 0 && dhcpTimeOutTicks <= 0) {
result = -76;
} else {
result = SOiWaitForDHCPEx(
(int)((dhcpTimeOutTicks) / ((__OSBusClock / 4) / 1000)));
}
if (result != 0) {
(void)SOCleanup();
}
}
{
OSThread* cur = OSGetCurrentThread();
if (cur)
cur->error = result;
else
soError = result;
}
if (result == -112) {
linkupRetryCount--;
if (linkupRetryCount >= 0) {
goto begin_startup;
}
}
return result;
}
int SOCleanup(void) {
int result = SO_SUCCESS;
int enabled = OSDisableInterrupts();
s32 exErr = SO_SUCCESS;
int errNwc24;
switch (soState) {
case SO_INTERNAL_STATE_TERMINATED:
default:
result = SO_ENETRESET;
break;
case SO_INTERNAL_STATE_READY:
result = SO_EALREADY;
break;
case SO_INTERNAL_STATE_ACTIVE:
if (soWork.rmState < SO_INTERNAL_RM_STATE_OPENED) {
result = SO_EBUSY;
break;
} else if (!OSGetCurrentThread()) {
result = SO_EFATAL;
break;
} else {
soWork.rmState = SO_INTERNAL_RM_STATE_WORKING;
(void)OSRestoreInterrupts(enabled);
errNwc24 = NWC24iCleanupSocket(&exErr);
result = SOStartupErr(errNwc24, exErr);
if (result != SO_SUCCESS) {
} else {
if (IOS_Close(soWork.rmFd) < 0)
result = SO_EFATAL;
else
soWork.rmFd = -1;
}
enabled = OSDisableInterrupts();
if (result == SO_SUCCESS) {
soState = SO_INTERNAL_STATE_READY;
soWork.rmState = SO_INTERNAL_RM_STATE_CLOSED;
} else {
if (result != SO_EFATAL) {
soState = SO_INTERNAL_STATE_ACTIVE;
soWork.rmState = SO_INTERNAL_RM_STATE_OPENED;
}
}
}
break;
}
{
OSThread* cur = OSGetCurrentThread();
if (cur)
cur->error = result;
else
soError = result;
}
OSRestoreInterrupts(enabled);
return result;
}
SOSysWork* SOiGetSysWork(void) { return &soWork; }
int SOiIsBufferAddrCheck(void) { return soBufAddrCheck; }
int SOiIsInitialized(void) {
int result = 0;
int enabled = OSDisableInterrupts();
switch (soState) {
case SO_INTERNAL_STATE_READY:
case SO_INTERNAL_STATE_ACTIVE:
result = 1;
break;
}
OSRestoreInterrupts(enabled);
return result;
}
void* SOiAlloc(u32 name, s32 size) {
if (size > 0 && soWork.allocFunc) {
void* ptr = soWork.allocFunc(name, size);
if (ptr) {
soWork.allocCount++;
if (SOiIsBufferAddrCheck() && !(((u32)ptr & 0x1fffffff) >= 0x10000000 &&
((u32)ptr & 0x1fffffff) < 0x18000000)) {
if (ptr != NULL && soWork.freeFunc != NULL) {
soWork.allocCount--;
soWork.freeFunc(name, ptr, size);
}
ptr = NULL;
}
}
return ptr;
}
return NULL;
}
void SOiFree(u32 name, void* ptr, s32 size) {
if ((ptr != NULL) && (soWork.freeFunc != NULL)) {
soWork.allocCount--;
soWork.freeFunc(name, ptr, size);
}
}
int SOiPrepare(const char*, s32* pRmId) {
int result = SO_SUCCESS;
int enabled = OSDisableInterrupts();
switch (soState) {
case SO_INTERNAL_STATE_TERMINATED:
result = SO_ENETRESET;
break;
case SO_INTERNAL_STATE_READY:
default:
result = SO_EINVAL;
break;
case SO_INTERNAL_STATE_ACTIVE:
if (soWork.rmState < SO_INTERNAL_RM_STATE_OPENED) {
result = SO_EBUSY;
break;
} else if (!OSGetCurrentThread()) {
result = SO_EFATAL;
break;
}
*pRmId = soWork.rmFd;
break;
}
if (result != SO_SUCCESS) {
OSThread* cur = OSGetCurrentThread();
if (cur)
cur->error = result;
else
soError = result;
}
(void)OSRestoreInterrupts(enabled);
return result;
}
int SOiConclude(const char*, int result) {
int enabled = OSDisableInterrupts();
OSThread* cur;
cur = OSGetCurrentThread();
if (cur)
cur->error = result;
else
soError = result;
(void)OSRestoreInterrupts(enabled);
return result;
}
int SOiPrepareTempRm(const char* funcName, s32* pRmId, int* pIsTempRm) {
int result = SO_SUCCESS;
int enabled = OSDisableInterrupts();
int errNwc24;
switch (soState) {
case SO_INTERNAL_STATE_TERMINATED:
result = SO_ENETRESET;
break;
case SO_INTERNAL_STATE_READY:
default:
if (soWork.rmState > SO_INTERNAL_RM_STATE_CLOSED) {
result = SO_EBUSY;
break;
} else if (!OSGetCurrentThread()) {
result = SO_EFATAL;
break;
}
soWork.rmState = SO_INTERNAL_RM_STATE_WORKING;
(void)OSRestoreInterrupts(enabled);
soWork.rmFd = IOS_Open(NET_RM_SOCK, 0);
if (soWork.rmFd < 0) {
enabled = OSDisableInterrupts();
if (soWork.rmFd == -6) {
result = SO_EINPROGRESS;
soWork.rmState = SO_INTERNAL_RM_STATE_CLOSED;
} else {
result = SO_EFATAL;
}
} else {
*pRmId = soWork.rmFd;
if ((errNwc24 = NWC24iLockSocket()) == NWC24_OK) {
s32 errNcd = NCDGetLinkStatus();
switch (errNcd) {
case 3:
case 4:
case 5:
result = (int)IOS_Ioctl(soWork.rmFd, 0x1f, NULL, 0, NULL, 0);
if (result == SO_SUCCESS) {
*pIsTempRm = 1;
} else {
result = SOiConcludeTempRm(funcName, result, 1);
}
break;
case -8:
result = SOiConcludeTempRm(funcName, SO_EINPROGRESS, 1);
break;
case -1:
case -2:
result = SOiConcludeTempRm(funcName, SO_EFATAL, 1);
break;
default:
result = SOiConcludeTempRm(funcName, SO_ENOLINK, 1);
}
enabled = OSDisableInterrupts();
} else {
switch (errNwc24) {
case NWC24_ERR_INPROGRESS:
result = SO_EINPROGRESS;
break;
case NWC24_ERR_FAILED:
result = SO_ENETRESET;
break;
case NWC24_ERR_DONE:
result = SO_ENOLINK;
break;
case NWC24_ERR_MUTEX:
case NWC24_ERR_FATAL:
default:
result = SO_EFATAL;
break;
}
if (IOS_Close(soWork.rmFd) < 0) {
result = SO_EFATAL;
}
enabled = OSDisableInterrupts();
if (result != SO_EFATAL) {
soWork.rmFd = -1;
soWork.rmState = SO_INTERNAL_RM_STATE_CLOSED;
}
}
}
break;
case SO_INTERNAL_STATE_ACTIVE:
if (soWork.rmState < SO_INTERNAL_RM_STATE_OPENED) {
result = SO_EBUSY;
break;
} else if (!OSGetCurrentThread()) {
result = SO_EFATAL;
break;
}
*pIsTempRm = 0;
*pRmId = soWork.rmFd;
break;
}
if (result != SO_SUCCESS) {
OSThread* cur = OSGetCurrentThread();
if (cur)
cur->error = result;
else
soError = result;
}
(void)OSRestoreInterrupts(enabled);
return result;
}
int SOiConcludeTempRm(const char*, int result, int isTempRm) {
int enabled;
OSThread* cur;
if (isTempRm == 1) {
switch (NWC24iUnlockSocket()) {
case NWC24_OK:
break;
case NWC24_ERR_INPROGRESS:
result = SO_EINPROGRESS;
break;
case NWC24_ERR_FATAL:
default:
result = SO_EFATAL;
}
if (IOS_Close(soWork.rmFd) < 0) {
result = SO_EFATAL;
}
enabled = OSDisableInterrupts();
if (result != SO_EFATAL) {
soWork.rmFd = -1;
soWork.rmState = SO_INTERNAL_RM_STATE_CLOSED;
}
} else {
enabled = OSDisableInterrupts();
}
cur = OSGetCurrentThread();
if (cur)
cur->error = result;
else
soError = result;
(void)OSRestoreInterrupts(enabled);
return result;
}
int SOiWaitForDHCPEx(int timeout) {
int result = SO_SUCCESS;
int gioResult;
int ifError;
int ifErrorSize;
s64 limitTime;
limitTime = 0;
if (timeout != 0)
limitTime = __OSGetSystemTime() + ((timeout) * ((__OSBusClock / 4) / 1000));
while (1) {
OSSleepTicks((((s64)10) * ((__OSBusClock / 4) / 1000)));
ifErrorSize = sizeof(ifError);
gioResult = SOGetInterfaceOpt(NULL, 0xfffe, 0x1003, &ifError, &ifErrorSize);
if (gioResult != SO_SUCCESS) {
result = gioResult;
break;
}
if (gioResult == SO_SUCCESS && ifError != SO_SUCCESS) {
result = ifError;
break;
}
if (SOGetHostID() != 0)
break;
if (limitTime != 0 && limitTime < __OSGetSystemTime()) {
result = SO_ETIMEDOUT;
break;
}
}
return result;
}
#pragma dont_inline on
int __SOCreateSocket(int pf, int type, int protocol) {
int result;
s32 rmId;
NETSoSocket* soc;
if ((result = SOiPrepare(0, &rmId)) == SO_SUCCESS) {
if (pf == 0x17) {
result = -5;
} else {
soc = (NETSoSocket*)SOiAlloc(0xC, 0x20);
if (soc == NULL) {
result = SO_ENOMEM;
} else {
soc->af = pf;
soc->type = type;
soc->protocol = protocol;
result = IOS_Ioctl(rmId, NET_SO_SOCKET, soc, 0xC, NULL, 0);
SOiFree(0xC, soc, 0x20);
}
}
result = SOiConclude(0, result);
}
return result;
}
#pragma dont_inline reset

View File

@@ -25,7 +25,7 @@ enum {
#define MAX_IOS_VECS 4
SDKDefineVersionEx(SSL, "Jun 21 2007", "13:10:10", 60726);
const char* __SSLVersion = "<< RVL_SDK - SSL \trelease build: Jun 21 2007 13:10:10 (0x4199_60726) >>";
static BOOL sslRegistered = FALSE;
static s32 l_initialized = 0;
@@ -547,3 +547,10 @@ static u32 SSL_strnlen(const char* s, u32 n) {
}
return t - s;
}
#pragma push
#pragma section data_type ".data"
#pragma pop
#pragma push
#pragma section data_type ".sdata"
#pragma pop

View File

@@ -385,7 +385,7 @@ VFErr VFSysSetSyncMode(s32 i_handle_idx, u32 i_mode) {
return VF_ERR_SYSTEM;
}
u32 VFSysGetSyncMode(s32 i_handle_idx) {
static u32 VFSysGetSyncMode(s32 i_handle_idx) {
VFSys_handle* handle_p = VFSysGetHandleP(i_handle_idx);
if (handle_p == NULL || handle_p->drive.pf_disk_p == NULL || handle_p->device_p == NULL) {
@@ -541,7 +541,7 @@ s32 VFSysHandleP2Idx(VFSys_handle* i_handle_p) {
return VF_ERR_SYSTEM;
}
VFSys_handle* VFSysVol2HandleP(PF_VOLUME* i_vol_p) {
static VFSys_handle* VFSysVol2HandleP(PF_VOLUME* i_vol_p) {
if (i_vol_p != NULL) {
VFSys_handle* handle_p = VFSysGetHandleP(0);
VFSys_handle* handle_end_p = &handle_p[l_vfsys_vol_max];
@@ -635,6 +635,7 @@ VFErr VFSysSetDeviceNANDFlash(s32* o_idx_p, void* i_cache_heap_p, u32 i_cache_si
static void VFiSysClearDeviceSDDirect(VFSys_deviceSD* o_sd_p);
#pragma dont_inline on
VFErr VFSysSetDeviceSDDirect(s32* o_idx_p, u32 i_slot_no, void* i_cache_heap_p, u32 i_cache_size, VFSDEventCallback i_eventCallback) {
s32 idx = VFiSysGetFreeHandleIdx();
VFSys_handle* handle_p = VFSysGetHandleP(idx);
@@ -676,6 +677,7 @@ VFErr VFSysSetDeviceSDDirect(s32* o_idx_p, u32 i_slot_no, void* i_cache_heap_p,
VFiSysClearHandle(handle_p);
return VFipf2_errnum();
}
#pragma dont_inline reset
VFErr VFSysGetSlotNoSDDirect(s32 i_handle_idx) {
VFSys_handle* handle_p;
@@ -726,7 +728,7 @@ static void VFiSysClearDeviceSDDirect(VFSys_deviceSD* o_sd_p) {
o_sd_p->slotNo = -1;
}
VFSys_device* VFSysGetDeviceP(s32 i_idx) {
static VFSys_device* VFSysGetDeviceP(s32 i_idx) {
VFSys_handle* handle_p = VFSysGetHandleP(i_idx);
if (handle_p != NULL) {
return handle_p->device_p;
@@ -1168,7 +1170,7 @@ static VFErr VFiSysGetLastDeviceError_common(VFSys_handle* i_handle_p) {
return VF_ERR_SYSTEM;
}
void VFSysSetDevErrInfo(s32 i_handle_idx, VFErr i_err) {
static void VFSysSetDevErrInfo(s32 i_handle_idx, VFErr i_err) {
VFSys_handle* handle_p = VFSysGetHandleP(i_handle_idx);
if (handle_p != NULL) {
VFiSysSetDeviceErrInfo(handle_p, i_err);

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