Compare commits
1083 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
1b1762f872 | ||
![]() |
04b9418dd9 | ||
![]() |
30dc65121d | ||
![]() |
8cbcce773b | ||
![]() |
a88b5af7a8 | ||
![]() |
8e55cdf05d | ||
![]() |
5f06a037d7 | ||
![]() |
cc5b884d7d | ||
![]() |
c5ecf54d51 | ||
![]() |
faf5162b60 | ||
![]() |
a6a6548348 | ||
![]() |
0da8705527 | ||
![]() |
d0936b879b | ||
![]() |
c579a65655 | ||
![]() |
bf4a24a4e7 | ||
![]() |
bd69c96b7d | ||
![]() |
41e31d3921 | ||
![]() |
687aaf6cfc | ||
![]() |
4de90c3436 | ||
![]() |
5b2a9f6136 | ||
![]() |
0f098853f2 | ||
![]() |
a4634c0290 | ||
![]() |
e9fa000e94 | ||
![]() |
0cbae436c8 | ||
![]() |
a9a9d9ab69 | ||
![]() |
6714c04806 | ||
![]() |
39a53c4fe5 | ||
![]() |
8d90551306 | ||
![]() |
032f3dad40 | ||
![]() |
b18f04d887 | ||
![]() |
98324d412f | ||
![]() |
cd78fb05cb | ||
![]() |
a30628058c | ||
![]() |
cb9d682f65 | ||
![]() |
1de86ea38a | ||
![]() |
e253c2c005 | ||
![]() |
08b76e2e17 | ||
![]() |
da323fa50b | ||
![]() |
af5321c78e | ||
![]() |
58719f32ac | ||
![]() |
ef806d5bd8 | ||
![]() |
e6fcbef36c | ||
![]() |
b20ac22ab7 | ||
![]() |
59cf50c201 | ||
![]() |
607f1d1fb6 | ||
![]() |
10cf9bb95a | ||
![]() |
813d28ddc4 | ||
![]() |
82f821156a | ||
![]() |
59e0d7596f | ||
![]() |
d4e08aa2cc | ||
![]() |
b76a245b79 | ||
![]() |
11686876ac | ||
![]() |
c36d9cc4a6 | ||
![]() |
cf538b1fa8 | ||
![]() |
ebb5305188 | ||
![]() |
4815537048 | ||
![]() |
4d36c74be4 | ||
![]() |
8ad7b5a71a | ||
![]() |
bb9c49b84d | ||
![]() |
2564d708e6 | ||
![]() |
c83c12357e | ||
![]() |
982be53414 | ||
![]() |
5f13628dac | ||
![]() |
6360f4bdb1 | ||
![]() |
48967dc417 | ||
![]() |
1f4669fa4c | ||
![]() |
2a9f86fcbc | ||
![]() |
bf06f27a0e | ||
![]() |
4e25fb1d6c | ||
![]() |
858ef9408c | ||
![]() |
1fb16e21c2 | ||
![]() |
75b4d1f563 | ||
![]() |
4fdc40228a | ||
![]() |
e996cef24d | ||
![]() |
dcf83900b9 | ||
![]() |
02f516111f | ||
![]() |
3cefb61d91 | ||
![]() |
d085de370e | ||
![]() |
4866df79a5 | ||
![]() |
958e0c74ea | ||
![]() |
e70908afc7 | ||
![]() |
e7b0b82bf6 | ||
![]() |
5872ad60be | ||
![]() |
c1c93b0880 | ||
![]() |
bc6c097dbb | ||
![]() |
3874788e85 | ||
![]() |
846b79e5a6 | ||
![]() |
bd9e559309 | ||
![]() |
4a9c547d8b | ||
![]() |
ef6289f977 | ||
![]() |
1ba8d40069 | ||
![]() |
58b30bad06 | ||
![]() |
577fe60268 | ||
![]() |
75a7312e40 | ||
![]() |
24dded1c79 | ||
![]() |
33a570b1c3 | ||
![]() |
da529aed21 | ||
![]() |
1c7914e2f4 | ||
![]() |
3e1d03aecd | ||
![]() |
83e1f97b5b | ||
![]() |
818931b51c | ||
![]() |
976d284f3a | ||
![]() |
4e387679f7 | ||
![]() |
53cbfc231f | ||
![]() |
dfbfc1564f | ||
![]() |
64f29fa024 | ||
![]() |
41d0d615f5 | ||
![]() |
9a707b2269 | ||
![]() |
19fd446ac5 | ||
![]() |
9974ed1aa3 | ||
![]() |
8662687a2a | ||
![]() |
03c41754e8 | ||
![]() |
2ff08fbac8 | ||
![]() |
b93e7f19bf | ||
![]() |
b559d93eda | ||
![]() |
bfc6ea48fb | ||
![]() |
bf55423903 | ||
![]() |
5ac710a0a2 | ||
![]() |
d521c99769 | ||
![]() |
09d629aa85 | ||
![]() |
6ef91576ae | ||
![]() |
26f5f7eb33 | ||
![]() |
9c1c847388 | ||
![]() |
528f8feb0b | ||
![]() |
6c0f7ac99c | ||
![]() |
f49efc3cc7 | ||
![]() |
8e3c9f9784 | ||
![]() |
1442eef9e4 | ||
![]() |
ea57fb8821 | ||
![]() |
80fad02255 | ||
![]() |
08bff23736 | ||
![]() |
5986713066 | ||
![]() |
b48b5da211 | ||
![]() |
6ce690828c | ||
![]() |
ac8656f8b2 | ||
![]() |
7171a87d53 | ||
![]() |
59b8fd8283 | ||
![]() |
36b618e3bb | ||
![]() |
beaebaaf26 | ||
![]() |
34f690d9d0 | ||
![]() |
80be51e93b | ||
![]() |
8f06d03ca6 | ||
![]() |
26e4f20078 | ||
![]() |
59e12a1b5e | ||
![]() |
2e48185aed | ||
![]() |
aefdcf203d | ||
![]() |
0053d8d076 | ||
![]() |
e3be4b8678 | ||
![]() |
1bafb08f34 | ||
![]() |
69483a473a | ||
![]() |
c9326f6bce | ||
![]() |
e86e906895 | ||
![]() |
48f330e56a | ||
![]() |
ed59061172 | ||
![]() |
9d27eb80de | ||
![]() |
8d64007d70 | ||
![]() |
65ff0a1fcc | ||
![]() |
1389fcdfcd | ||
![]() |
b03b64dd09 | ||
![]() |
750bceebf2 | ||
![]() |
b161b7e578 | ||
![]() |
51c0bdfc90 | ||
![]() |
6f34257b57 | ||
![]() |
92ddd9e9b3 | ||
![]() |
98664af53c | ||
![]() |
fddc517a6b | ||
![]() |
1ca796b3a3 | ||
![]() |
175dd62a90 | ||
![]() |
87734ae8d9 | ||
![]() |
7956f6ba24 | ||
![]() |
0e4d8fbd05 | ||
![]() |
6bca5af849 | ||
![]() |
8566366b02 | ||
![]() |
8acc1871bc | ||
![]() |
751dd3b42d | ||
![]() |
ed7674626e | ||
![]() |
754c334c29 | ||
![]() |
e842cfd011 | ||
![]() |
188d175579 | ||
![]() |
309c3f1d7b | ||
![]() |
d3ea737071 | ||
![]() |
c550a22259 | ||
![]() |
67933816ba | ||
![]() |
59b71196ac | ||
![]() |
f919af3182 | ||
![]() |
9b4ac1118d | ||
![]() |
d0b6343342 | ||
![]() |
d4036d97ef | ||
![]() |
fd1006b682 | ||
![]() |
2750c4a70b | ||
![]() |
09688ea6fc | ||
![]() |
8ffc9461ea | ||
![]() |
0ed1f2beb2 | ||
![]() |
7663a701c0 | ||
![]() |
0536cc5493 | ||
![]() |
5fd623da44 | ||
![]() |
da0af223a2 | ||
![]() |
ffba52bcd0 | ||
![]() |
79ee260c15 | ||
![]() |
dacacfa403 | ||
![]() |
550793b262 | ||
![]() |
67f10f0ba9 | ||
![]() |
79a77cd862 | ||
![]() |
b9b4d486a3 | ||
![]() |
5f3b369a81 | ||
![]() |
a482822fb8 | ||
![]() |
14fdf2dee4 | ||
![]() |
56d3b0b76e | ||
![]() |
64bdf022a8 | ||
![]() |
3810a5586b | ||
![]() |
c579e745a8 | ||
![]() |
2c1f84406e | ||
![]() |
18267ef6fb | ||
![]() |
d1ca5c4ea6 | ||
![]() |
510504a853 | ||
![]() |
fcf9ca767b | ||
![]() |
5450b2bee5 | ||
![]() |
cc22550296 | ||
![]() |
1165b4cb8b | ||
![]() |
caacf37594 | ||
![]() |
f214b2e535 | ||
![]() |
74b8aa00cd | ||
![]() |
c1cee4a115 | ||
![]() |
555f31b35e | ||
![]() |
8840ebf813 | ||
![]() |
a087e33414 | ||
![]() |
a4210af6c2 | ||
![]() |
6dcbee7f4c | ||
![]() |
29418f4d3d | ||
![]() |
2158f71eb2 | ||
![]() |
c598c445cd | ||
![]() |
abf8064771 | ||
![]() |
52be537b48 | ||
![]() |
fdf31f7556 | ||
![]() |
4ceebb8b44 | ||
![]() |
3bbd2dca16 | ||
![]() |
c941b0d2d2 | ||
![]() |
3a1a501867 | ||
![]() |
6f64dee330 | ||
![]() |
65673fd3f3 | ||
![]() |
8e2d82ae9a | ||
![]() |
fc67757066 | ||
![]() |
632f9866e6 | ||
![]() |
53c42003f3 | ||
![]() |
213f586c7d | ||
![]() |
7c348aa3ad | ||
![]() |
25123ba057 | ||
![]() |
04bde1de19 | ||
![]() |
d6a628b7d3 | ||
![]() |
aaa92f619c | ||
![]() |
fa6eb5db9e | ||
![]() |
8196e383c3 | ||
![]() |
0d950af680 | ||
![]() |
967b0223ad | ||
![]() |
010dde085b | ||
![]() |
f132a7a2a9 | ||
![]() |
4dafd78e26 | ||
![]() |
6a6dc3be4a | ||
![]() |
532fbef44f | ||
![]() |
e1ddc74c1c | ||
![]() |
f05c56435d | ||
![]() |
57152061b0 | ||
![]() |
46b29af821 | ||
![]() |
5843fdcc0d | ||
![]() |
3cea84f315 | ||
![]() |
5d245e5cc8 | ||
![]() |
31ca6f5c53 | ||
![]() |
bc87466400 | ||
![]() |
41c1fee88e | ||
![]() |
8d177742ae | ||
![]() |
49f99a0650 | ||
![]() |
4d8c2ea9f5 | ||
![]() |
325dbf02b7 | ||
![]() |
0475b59e12 | ||
![]() |
be79735c31 | ||
![]() |
eb062ce0a9 | ||
![]() |
1e6df47adb | ||
![]() |
ff559d2a90 | ||
![]() |
94aabe35f3 | ||
![]() |
8778d8c5d6 | ||
![]() |
e43d368fbc | ||
![]() |
1ed97e8ba2 | ||
![]() |
3f7a4d227d | ||
![]() |
e64d859d36 | ||
![]() |
708ece10df | ||
![]() |
8ada484dad | ||
![]() |
422c3c3272 | ||
![]() |
82049e7fc2 | ||
![]() |
28827803ce | ||
![]() |
4f98439f86 | ||
![]() |
b3742567d4 | ||
![]() |
eb681db5af | ||
![]() |
cdababc38d | ||
![]() |
f4232926c3 | ||
![]() |
d9933cb2db | ||
![]() |
d8374c2883 | ||
![]() |
929468371a | ||
![]() |
c44da0636a | ||
![]() |
10cb9babc9 | ||
![]() |
064f9fdf9e | ||
![]() |
636dfb2f1d | ||
![]() |
65171be4d8 | ||
![]() |
e5fc424414 | ||
![]() |
cc2928427b | ||
![]() |
ec0b9d8033 | ||
![]() |
eeacb2faa9 | ||
![]() |
da97a8802c | ||
![]() |
c6c994ca60 | ||
![]() |
2edbc6fe2e | ||
![]() |
492fffd445 | ||
![]() |
c195a19683 | ||
![]() |
9b99862696 | ||
![]() |
b3ed60d123 | ||
![]() |
112163e580 | ||
![]() |
cffb347407 | ||
![]() |
991eb2357b | ||
![]() |
97d01a7325 | ||
![]() |
093b3441ea | ||
![]() |
95c4a3e6ef | ||
![]() |
fb0ef2a459 | ||
![]() |
7be0b5b026 | ||
![]() |
97d6149e3e | ||
![]() |
e06c8e542f | ||
![]() |
6eb53df563 | ||
![]() |
ee2a1d2eba | ||
![]() |
e50802b90f | ||
![]() |
400e85d674 | ||
![]() |
50cafaa700 | ||
![]() |
396d341a8f | ||
![]() |
648ee46742 | ||
![]() |
6e107a1aa5 | ||
![]() |
d42efe636b | ||
![]() |
635d3e6640 | ||
![]() |
66d1f7c957 | ||
![]() |
f744a85e5a | ||
![]() |
47d9585624 | ||
![]() |
d14fa59ba5 | ||
![]() |
95bcb4d69a | ||
![]() |
7ccfe71e45 | ||
![]() |
435fad724b | ||
![]() |
88da2f456b | ||
![]() |
4abf42f16d | ||
![]() |
ba23d7224b | ||
![]() |
84db84c05f | ||
![]() |
fbdcf91c8b | ||
![]() |
7e8a480b45 | ||
![]() |
c23ed61457 | ||
![]() |
066a9cc6fd | ||
![]() |
65240d6202 | ||
![]() |
bd832dbb25 | ||
![]() |
131e71b5e7 | ||
![]() |
b04568fd53 | ||
![]() |
955ae2af3e | ||
![]() |
ee23569db8 | ||
![]() |
e8c3a9139e | ||
![]() |
b5a8183dbd | ||
![]() |
34015acd3f | ||
![]() |
e37ebf3ef1 | ||
![]() |
3501efd7e5 | ||
![]() |
664ae583c4 | ||
![]() |
744ca95390 | ||
![]() |
39e54e3634 | ||
![]() |
9048408bd3 | ||
![]() |
5e568d78b1 | ||
![]() |
f7eed42835 | ||
![]() |
0eb70a4350 | ||
![]() |
bd34fd59db | ||
![]() |
b0768e552b | ||
![]() |
1258cfcccb | ||
![]() |
0955035671 | ||
![]() |
ada9559c11 | ||
![]() |
277fc287a1 | ||
![]() |
fcbc24a895 | ||
![]() |
3b3c0fabdf | ||
![]() |
e6ebe9abea | ||
![]() |
3474ac5121 | ||
![]() |
7090fbd02d | ||
![]() |
c741d7d5cc | ||
![]() |
71cdc3cdbc | ||
![]() |
ae6be1cf97 | ||
![]() |
9efe374dc1 | ||
![]() |
6a94d99dc2 | ||
![]() |
d149355fb7 | ||
![]() |
5310f1a900 | ||
![]() |
9e53a7cd61 | ||
![]() |
4dc8493d77 | ||
![]() |
7aad0b4968 | ||
![]() |
88a9c58bec | ||
![]() |
5725ec2ded | ||
![]() |
24b9341c99 | ||
![]() |
343d53f540 | ||
![]() |
afa261eecd | ||
![]() |
baf7dee858 | ||
![]() |
ea0a96c29b | ||
![]() |
cfdb8d1b58 | ||
![]() |
3bed534f87 | ||
![]() |
da7ecc255b | ||
![]() |
bbd0fe92d3 | ||
![]() |
15e24d19a5 | ||
![]() |
bac12e19bb | ||
![]() |
2f6a28f1e3 | ||
![]() |
02a087b588 | ||
![]() |
e863d2a4cf | ||
![]() |
1cef3e5d2f | ||
![]() |
14cdb5a9d3 | ||
![]() |
8c9a32747c | ||
![]() |
3a10698964 | ||
![]() |
56a11197c7 | ||
![]() |
6d65d537b3 | ||
![]() |
1ba7894c8d | ||
![]() |
12f0f638ff | ||
![]() |
94b3748870 | ||
![]() |
7fa3adc716 | ||
![]() |
8876b1eb5f | ||
![]() |
c36bdb9013 | ||
![]() |
191e286283 | ||
![]() |
d72842f898 | ||
![]() |
9489aadb5a | ||
![]() |
53e3b35466 | ||
![]() |
7ce124e744 | ||
![]() |
3ed89e6bd9 | ||
![]() |
2810c4d3a8 | ||
![]() |
f22b8f7d9a | ||
![]() |
c81239a407 | ||
![]() |
cf91be5041 | ||
![]() |
863ea8ef68 | ||
![]() |
3129c35e71 | ||
![]() |
98adfa0536 | ||
![]() |
25aae300b2 | ||
![]() |
102adfe872 | ||
![]() |
a65a2e0def | ||
![]() |
030393a753 | ||
![]() |
570f46f281 | ||
![]() |
19175f7de3 | ||
![]() |
b1f4f431e8 | ||
![]() |
1578cd7e82 | ||
![]() |
6f378c8297 | ||
![]() |
f9f7eccc33 | ||
![]() |
ed5516ba20 | ||
![]() |
2dbed49262 | ||
![]() |
88cffe7703 | ||
![]() |
2f03d17a68 | ||
![]() |
18b44e3780 | ||
![]() |
dcf7449a93 | ||
![]() |
fd566668d3 | ||
![]() |
6606a77719 | ||
![]() |
a653c49aaa | ||
![]() |
e61e45abdc | ||
![]() |
47155d75b6 | ||
![]() |
c4d2110ab9 | ||
![]() |
3a84c7237e | ||
![]() |
c29438af03 | ||
![]() |
e266fa8362 | ||
![]() |
3d243ce567 | ||
![]() |
001623c43d | ||
![]() |
2f7515a814 | ||
![]() |
d1aaf68665 | ||
![]() |
2706026ff4 | ||
![]() |
b6e0555b1a | ||
![]() |
353f7af759 | ||
![]() |
0c1e656a2b | ||
![]() |
f6bf7e7b1f | ||
![]() |
daba63af69 | ||
![]() |
570c834679 | ||
![]() |
72b6b3e48b | ||
![]() |
d7500b3608 | ||
![]() |
6f6926921e | ||
![]() |
bdb2835b62 | ||
![]() |
1671aeb7c2 | ||
![]() |
3b1673b673 | ||
![]() |
688b2649c5 | ||
![]() |
72cb548cb0 | ||
![]() |
9b5c1a3a6a | ||
![]() |
b11004f221 | ||
![]() |
6570ade097 | ||
![]() |
4393593e48 | ||
![]() |
41ea040420 | ||
![]() |
db6432ce0a | ||
![]() |
9ad6e0945c | ||
![]() |
d2f9655d8a | ||
![]() |
4123baba50 | ||
![]() |
fa70037055 | ||
![]() |
d654cf1b88 | ||
![]() |
a896bf772c | ||
![]() |
9aa9d32e11 | ||
![]() |
ed53bcf4a8 | ||
![]() |
c9d2f74815 | ||
![]() |
b9c0ca992d | ||
![]() |
2964d87ed4 | ||
![]() |
3bb7451c3d | ||
![]() |
1346fae04f | ||
![]() |
44b601d7b8 | ||
![]() |
1e5c91989f | ||
![]() |
3d90087481 | ||
![]() |
b7b78414da | ||
![]() |
932630764f | ||
![]() |
7adab4d940 | ||
![]() |
d431a67f31 | ||
![]() |
98fa2f7983 | ||
![]() |
a5b7c58c69 | ||
![]() |
5b7468e5cf | ||
![]() |
d769879933 | ||
![]() |
049d2e2373 | ||
![]() |
e2852d14f1 | ||
![]() |
12a5fa297a | ||
![]() |
2beafaa27f | ||
![]() |
b0c5a3c87d | ||
![]() |
1c55370cee | ||
![]() |
bb9853798b | ||
![]() |
6d5a06227b | ||
![]() |
e4e51e758b | ||
![]() |
5e84447219 | ||
![]() |
e1a9d2ef9c | ||
![]() |
42ce1d8792 | ||
![]() |
c3b22e3922 | ||
![]() |
14005eee52 | ||
![]() |
0c11529000 | ||
![]() |
f700005701 | ||
![]() |
09611e0284 | ||
![]() |
8cd37c627c | ||
![]() |
27b6134bf2 | ||
![]() |
173d258e30 | ||
![]() |
c818410973 | ||
![]() |
2b9dc3c82a | ||
![]() |
3a3ee64b64 | ||
![]() |
92700f4f73 | ||
![]() |
cd054cbadf | ||
![]() |
62c05ea73b | ||
![]() |
b364790a9a | ||
![]() |
818254c55e | ||
![]() |
07faf3d40c | ||
![]() |
5af3dd73de | ||
![]() |
de0a39089c | ||
![]() |
98165a1164 | ||
![]() |
248c02cf8e | ||
![]() |
b8741b35e8 | ||
![]() |
a7a7231085 | ||
![]() |
88c1798c12 | ||
![]() |
097095b557 | ||
![]() |
70f84f4950 | ||
![]() |
6beee4f9fe | ||
![]() |
8b5e753235 | ||
![]() |
07f0fe7e65 | ||
![]() |
722d91b73e | ||
![]() |
abbef70e61 | ||
![]() |
28b3775118 | ||
![]() |
45ff5c4ee6 | ||
![]() |
389807c6a3 | ||
![]() |
464d6c6363 | ||
![]() |
ac7af47956 | ||
![]() |
3df00537cd | ||
![]() |
0b40e7aa2f | ||
![]() |
557fbedb9b | ||
![]() |
15cb718913 | ||
![]() |
e9a476cfe2 | ||
![]() |
6eb23d3fbd | ||
![]() |
517b1c9503 | ||
![]() |
b34ff22dc7 | ||
![]() |
531f8f29a1 | ||
![]() |
c5674b3126 | ||
![]() |
15897d0eab | ||
![]() |
eba67d69ca | ||
![]() |
a75c01c302 | ||
![]() |
e05f841a58 | ||
![]() |
d5931ee336 | ||
![]() |
afae9ad607 | ||
![]() |
57ec5db247 | ||
![]() |
850646ea31 | ||
![]() |
9f98cefa3e | ||
![]() |
43940facdc | ||
![]() |
feb0b095e0 | ||
![]() |
59c62c4596 | ||
![]() |
29176f39ae | ||
![]() |
2741615b85 | ||
![]() |
cf0a0dc8a0 | ||
![]() |
df1d39b060 | ||
![]() |
2feb368dd1 | ||
![]() |
9fee423e8a | ||
![]() |
74a58330e8 | ||
![]() |
aca183a47b | ||
![]() |
85223098c6 | ||
![]() |
20e542c2c8 | ||
![]() |
7defc9053f | ||
![]() |
2d2cafcd86 | ||
![]() |
d4a24169c5 | ||
![]() |
1951d3b793 | ||
![]() |
a7a0613f38 | ||
![]() |
51709c69e2 | ||
![]() |
9410a6db2b | ||
![]() |
3f9513e62c | ||
![]() |
33d05f0fd0 | ||
![]() |
12555d77a4 | ||
![]() |
b1e97f2ca4 | ||
![]() |
05b8ce5b5d | ||
![]() |
1c18b0bffe | ||
![]() |
46ebd3e1d8 | ||
![]() |
02f145b9e2 | ||
![]() |
02beea3ed7 | ||
![]() |
e2037f5795 | ||
![]() |
4eff425593 | ||
![]() |
c048221f86 | ||
![]() |
c14634f323 | ||
![]() |
bd36f283fd | ||
![]() |
3657571591 | ||
![]() |
33ba77db4d | ||
![]() |
f052d22ceb | ||
![]() |
f7798302ea | ||
![]() |
50e804d4d2 | ||
![]() |
5daecd8d24 | ||
![]() |
416cc38797 | ||
![]() |
cc8e0c29b6 | ||
![]() |
19bca8177a | ||
![]() |
b96dd51d33 | ||
![]() |
5ece63029a | ||
![]() |
58b0b9db4d | ||
![]() |
827bbba993 | ||
![]() |
9b57720cee | ||
![]() |
e554f11999 | ||
![]() |
5923112082 | ||
![]() |
10c7711ce5 | ||
![]() |
699748da98 | ||
![]() |
a1157f7b8b | ||
![]() |
f8dec9ec5c | ||
![]() |
b21fa8a57f | ||
![]() |
c0f75ae42b | ||
![]() |
3714fa3810 | ||
![]() |
3fbea733c6 | ||
![]() |
f6ebc7f285 | ||
![]() |
d6dc1d52c5 | ||
![]() |
6e3b2a4cd7 | ||
![]() |
13a5a225b3 | ||
![]() |
651013d3d0 | ||
![]() |
b96697f7a4 | ||
![]() |
083e89628e | ||
![]() |
324fcff1dc | ||
![]() |
c49480f5d5 | ||
![]() |
9083a97014 | ||
![]() |
5d41effb6e | ||
![]() |
375fbce98a | ||
![]() |
6a7f13654d | ||
![]() |
9c98fe54b1 | ||
![]() |
67a1384564 | ||
![]() |
e87ad0ad6c | ||
![]() |
c12c0aace3 | ||
![]() |
65eaba5b2d | ||
![]() |
3d66e29a5d | ||
![]() |
891df76804 | ||
![]() |
c3da3c3057 | ||
![]() |
abdfec701f | ||
![]() |
7440ca7901 | ||
![]() |
fcb370a8c1 | ||
![]() |
d2f772c960 | ||
![]() |
3aa4bdf6e9 | ||
![]() |
24a84a874f | ||
![]() |
2797540a3d | ||
![]() |
e01dfbc392 | ||
![]() |
7b25a0d4d4 | ||
![]() |
2686b57c88 | ||
![]() |
b33b4eb2d0 | ||
![]() |
2ce51cf3d8 | ||
![]() |
e4775572c2 | ||
![]() |
6b40ea9d8e | ||
![]() |
facb701ae9 | ||
![]() |
27469de3c1 | ||
![]() |
7914b41107 | ||
![]() |
9360cd6a7d | ||
![]() |
76e47c02c8 | ||
![]() |
ca356af42c | ||
![]() |
af34e85ab2 | ||
![]() |
6bdfa1a005 | ||
![]() |
f362ae62a0 | ||
![]() |
a35abcb901 | ||
![]() |
8cc5dec1b2 | ||
![]() |
b3e6a64596 | ||
![]() |
28f73801cc | ||
![]() |
ebad126fc0 | ||
![]() |
f06d37659c | ||
![]() |
25d177f5d0 | ||
![]() |
dc40c55285 | ||
![]() |
31382e6a34 | ||
![]() |
d4ba60aff9 | ||
![]() |
f39862a3ea | ||
![]() |
9435477699 | ||
![]() |
15bca44322 | ||
![]() |
89fc70f076 | ||
![]() |
bba6b90ba0 | ||
![]() |
07d5367ed4 | ||
![]() |
807e3db7f2 | ||
![]() |
e12c8ff6a6 | ||
![]() |
942ec4af9b | ||
![]() |
3cb20a965b | ||
![]() |
839289378b | ||
![]() |
5e7fe49422 | ||
![]() |
f14d5721eb | ||
![]() |
b5009a3430 | ||
![]() |
80c76ee8d7 | ||
![]() |
818cd4ac39 | ||
![]() |
5f648ff9d4 | ||
![]() |
0c2a52a467 | ||
![]() |
be64a95c74 | ||
![]() |
791da049d5 | ||
![]() |
a5ad20cc46 | ||
![]() |
5d33682b7a | ||
![]() |
b46e0c6a15 | ||
![]() |
c25e04295a | ||
![]() |
506d9205f3 | ||
![]() |
13adb6a1c2 | ||
![]() |
141703b4ee | ||
![]() |
70e7fb35bc | ||
![]() |
0e7755af01 | ||
![]() |
8f0f83a417 | ||
![]() |
b9e5ddb944 | ||
![]() |
b2e01b17a1 | ||
![]() |
1a24e0e054 | ||
![]() |
034a27adaa | ||
![]() |
56a2712501 | ||
![]() |
d9c133d28a | ||
![]() |
3f9f492ccc | ||
![]() |
e6dd7ac37d | ||
![]() |
fa5f3783ce | ||
![]() |
f4cef43033 | ||
![]() |
66396c5777 | ||
![]() |
0c12a709a9 | ||
![]() |
d9f943ab7b | ||
![]() |
173d386795 | ||
![]() |
83d78a0f7c | ||
![]() |
c0b4a4bae1 | ||
![]() |
d6962f2122 | ||
![]() |
2656225392 | ||
![]() |
7fe0cba7e0 | ||
![]() |
9a3baad7ed | ||
![]() |
b481e6a446 | ||
![]() |
41c35375f5 | ||
![]() |
9fe9493701 | ||
![]() |
8e052004d5 | ||
![]() |
5c7273ef3b | ||
![]() |
167f27cdc4 | ||
![]() |
b9f7f74b58 | ||
![]() |
5788134dc5 | ||
![]() |
7256f74320 | ||
![]() |
a117a287fd | ||
![]() |
123d8c6d6e | ||
![]() |
deb7518153 | ||
![]() |
fa06930406 | ||
![]() |
362a3fce41 | ||
![]() |
64b32816cf | ||
![]() |
8dd1bbb0ce | ||
![]() |
d97d5f26a4 | ||
![]() |
04dd31220c | ||
![]() |
63f7918868 | ||
![]() |
1863bc2e35 | ||
![]() |
a65ae90b36 | ||
![]() |
8f00d34099 | ||
![]() |
8975e848d7 | ||
![]() |
44d9f0e940 | ||
![]() |
db9d0a69eb | ||
![]() |
5e6440b9b7 | ||
![]() |
d074d819ff | ||
![]() |
375f5e497d | ||
![]() |
383acf6575 | ||
![]() |
bc3ef580b2 | ||
![]() |
b9d51cbd87 | ||
![]() |
1c002fc034 | ||
![]() |
8912773f21 | ||
![]() |
c765e3b559 | ||
![]() |
8e43355620 | ||
![]() |
87b9d1302a | ||
![]() |
bfbeb7e6ba | ||
![]() |
04ddaff8cd | ||
![]() |
89e0bcd8cc | ||
![]() |
f1ce480ed9 | ||
![]() |
861c0a10b5 | ||
![]() |
b6817008ac | ||
![]() |
76e3cb0721 | ||
![]() |
2dc74a81ab | ||
![]() |
5426fba742 | ||
![]() |
7bad79e8b4 | ||
![]() |
9e43411a0e | ||
![]() |
abd104fae7 | ||
![]() |
72ea825b2d | ||
![]() |
95f63f280d | ||
![]() |
4603b972fa | ||
![]() |
6590ed3fad | ||
![]() |
56b56955c0 | ||
![]() |
520332e49e | ||
![]() |
0c21183b7e | ||
![]() |
27b5a49c59 | ||
![]() |
c6192c331b | ||
![]() |
066d8873d3 | ||
![]() |
c9a75d6a18 | ||
![]() |
649e95cd39 | ||
![]() |
2b467b48b8 | ||
![]() |
31b724a431 | ||
![]() |
04ab998f7a | ||
![]() |
2836b696bd | ||
![]() |
0a66043e56 | ||
![]() |
cd05ca0887 | ||
![]() |
bf1f162549 | ||
![]() |
6892a71eec | ||
![]() |
e409f1ea1d | ||
![]() |
04ed53659a | ||
![]() |
43e1137148 | ||
![]() |
d08707e3ca | ||
![]() |
aa2153700e | ||
![]() |
c99707ada4 | ||
![]() |
92cad5f971 | ||
![]() |
0f89778297 | ||
![]() |
730899bee6 | ||
![]() |
a68ee14632 | ||
![]() |
77c843f898 | ||
![]() |
9bf546da45 | ||
![]() |
62aa4d8ab0 | ||
![]() |
ce59e60193 | ||
![]() |
9d3b139255 | ||
![]() |
0ace45a746 | ||
![]() |
428a837224 | ||
![]() |
eb87524cd4 | ||
![]() |
c9ad04f70a | ||
![]() |
d227918edc | ||
![]() |
0d7072ecd2 | ||
![]() |
6d1f409dfd | ||
![]() |
fded98b9ed | ||
![]() |
c594170fca | ||
![]() |
530849a4b0 | ||
![]() |
e352f3befd | ||
![]() |
06f7aeb7c4 | ||
![]() |
0d7a7f4d7d | ||
![]() |
1817f90c6d | ||
![]() |
053c71ad08 | ||
![]() |
9b1e6bfc39 | ||
![]() |
15af3eff30 | ||
![]() |
57eb921f1a | ||
![]() |
407dcd141d | ||
![]() |
2707bfad93 | ||
![]() |
604b1f4b43 | ||
![]() |
696ac996d1 | ||
![]() |
5fd4a726ff | ||
![]() |
11a5001f33 | ||
![]() |
2e43fd1a40 | ||
![]() |
6b45f5a01c | ||
![]() |
e7e21fa9d5 | ||
![]() |
2a0e9655a6 | ||
![]() |
50541234b4 | ||
![]() |
98d937ebc1 | ||
![]() |
d10fc00786 | ||
![]() |
6ca0ab50dd | ||
![]() |
84d368918e | ||
![]() |
6b3e38de77 | ||
![]() |
a046b5a19f | ||
![]() |
570ea2ebd2 | ||
![]() |
0eac970aa1 | ||
![]() |
debe7a7553 | ||
![]() |
ad3dd538dc | ||
![]() |
24fd71c4ad | ||
![]() |
99cbb56491 | ||
![]() |
6f9edd9bbe | ||
![]() |
8ec9b514b0 | ||
![]() |
1738893d05 | ||
![]() |
f1b641a4ad | ||
![]() |
35a36b1885 | ||
![]() |
9e597a7af9 | ||
![]() |
8e7606692d | ||
![]() |
033b353128 | ||
![]() |
c49d5f49c2 | ||
![]() |
91c98308e2 | ||
![]() |
1a1f3bb932 | ||
![]() |
7d63ab5050 | ||
![]() |
8d36f3f03b | ||
![]() |
40d972d5ba | ||
![]() |
9f6f7a57ec | ||
![]() |
73e0267ae4 | ||
![]() |
cc8d6d7427 | ||
![]() |
ea7b0eac5d | ||
![]() |
2d7a53d75f | ||
![]() |
894d5342a1 | ||
![]() |
bf7d686e88 | ||
![]() |
10b81077e3 | ||
![]() |
4109bf5b66 | ||
![]() |
096bbdf401 | ||
![]() |
acdb6e5c72 | ||
![]() |
00eb8c38dc | ||
![]() |
e539c83d58 | ||
![]() |
ea88f92464 | ||
![]() |
d861ec4157 | ||
![]() |
d0dd07d8f4 | ||
![]() |
9fac0a0ea1 | ||
![]() |
e9651a2869 | ||
![]() |
a204c0def7 | ||
![]() |
0774378190 | ||
![]() |
c46562d54b | ||
![]() |
1ff4bb5e92 | ||
![]() |
44db57bd6d | ||
![]() |
17b0f88dcb | ||
![]() |
594215e5e5 | ||
![]() |
8e620c269d | ||
![]() |
585f84276a | ||
![]() |
a7e9a858dd | ||
![]() |
986f1a7068 | ||
![]() |
63472635ff | ||
![]() |
ee210d1963 | ||
![]() |
c62d54d831 | ||
![]() |
68fbd06375 | ||
![]() |
2b385581b9 | ||
![]() |
0c8c272bf4 | ||
![]() |
ac9b5dbb61 | ||
![]() |
8c053770a2 | ||
![]() |
266ab2fe42 | ||
![]() |
5b6d9b1ad9 | ||
![]() |
2791ab4850 | ||
![]() |
ec64beffbd | ||
![]() |
66b2e4548e | ||
![]() |
364b9834db | ||
![]() |
8a76010988 | ||
![]() |
a7aba7feae | ||
![]() |
de18776fac | ||
![]() |
4ebb95cc2f | ||
![]() |
7706270720 | ||
![]() |
e7ea04e532 | ||
![]() |
de687695cf | ||
![]() |
37ae484338 | ||
![]() |
5bb733455b | ||
![]() |
988cf9f905 | ||
![]() |
31e0f2ee07 | ||
![]() |
0ec23dc90a | ||
![]() |
6ca5285d10 | ||
![]() |
f631036063 | ||
![]() |
79e2efdc0c | ||
![]() |
c03688cfd4 | ||
![]() |
9ad62755b7 | ||
![]() |
4130bb71d0 | ||
![]() |
f32d31a806 | ||
![]() |
887a05a765 | ||
![]() |
f3bb5339f7 | ||
![]() |
308aa7aaa8 | ||
![]() |
1f375c0a75 | ||
![]() |
33eb72e071 | ||
![]() |
5747dcbd0d | ||
![]() |
9f9139a8d3 | ||
![]() |
40d0739ade | ||
![]() |
8ac3549abf | ||
![]() |
da680e0503 | ||
![]() |
e2f8011f69 | ||
![]() |
53b03ef6c5 | ||
![]() |
7c26d8e68d | ||
![]() |
e2b1da4d80 | ||
![]() |
7e10620b7f | ||
![]() |
e66e417ce0 | ||
![]() |
d30d14dff4 | ||
![]() |
1b1c2a0cea | ||
![]() |
bf4364af0e | ||
![]() |
350cb955b2 | ||
![]() |
004dfff8bd | ||
![]() |
df46a2c7dd | ||
![]() |
5a28a7398a | ||
![]() |
c443c34ad0 | ||
![]() |
6f37ad03f7 | ||
![]() |
71f330aad2 | ||
![]() |
3adff173cd | ||
![]() |
7b059d9395 | ||
![]() |
16732899d5 | ||
![]() |
7bb4fc8547 | ||
![]() |
cf7082ad1b | ||
![]() |
7d940da23a | ||
![]() |
4ab2b1a363 | ||
![]() |
adcea034a5 | ||
![]() |
c70fb0feb1 | ||
![]() |
d22d0a9345 | ||
![]() |
b30f553dd0 | ||
![]() |
7a71787670 | ||
![]() |
426258a7f7 | ||
![]() |
653f126065 | ||
![]() |
5b5bdb1bd1 | ||
![]() |
2fed2f4241 | ||
![]() |
a6831d177c | ||
![]() |
5c0a6ceda6 | ||
![]() |
85261971db | ||
![]() |
cd8fa3a26a | ||
![]() |
57f139799c | ||
![]() |
c71637d9ca | ||
![]() |
1a6bdc38a9 | ||
![]() |
b085943d4d | ||
![]() |
624dc1c1b3 | ||
![]() |
44d2606039 | ||
![]() |
0eed263bba | ||
![]() |
b275d5715b | ||
![]() |
e5edb0fa28 | ||
![]() |
54473e5487 | ||
![]() |
1f52ac344d | ||
![]() |
386a700673 | ||
![]() |
9abad5bbaf | ||
![]() |
b175fdbca5 | ||
![]() |
0f4ee280d2 | ||
![]() |
ed3045ab6a | ||
![]() |
02b68eb1ae | ||
![]() |
a2d2df17f9 | ||
![]() |
c998b5d035 | ||
![]() |
341f10b057 | ||
![]() |
11cd337d36 | ||
![]() |
4caa875489 | ||
![]() |
82affd3f77 | ||
![]() |
6d25d6d335 | ||
![]() |
20a1a610da | ||
![]() |
ce6fce07a1 | ||
![]() |
9ee96105f6 | ||
![]() |
8e031b1080 | ||
![]() |
36f82b8bb8 | ||
![]() |
02ff590b5a | ||
![]() |
c5fa04e845 | ||
![]() |
aa98a0796b | ||
![]() |
6822f89c4c | ||
![]() |
403c277bf8 | ||
![]() |
d28e3bf1da | ||
![]() |
992b23040c | ||
![]() |
da57493368 | ||
![]() |
f39571f542 | ||
![]() |
fa41041abf | ||
![]() |
dcd1ccf939 | ||
![]() |
d9552e95dc | ||
![]() |
8ac08bad4e | ||
![]() |
b40d605660 | ||
![]() |
a8b20600cf | ||
![]() |
56317483fb | ||
![]() |
24bceda509 | ||
![]() |
9a08d26e03 | ||
![]() |
257f77a05d | ||
![]() |
6be71c218e | ||
![]() |
131d3380ac | ||
![]() |
83c496bcdb | ||
![]() |
64d918a719 | ||
![]() |
5a17bfd631 | ||
![]() |
71788b4a66 | ||
![]() |
0ae00d4fdc | ||
![]() |
bb1ca9e63a | ||
![]() |
8d274afd13 | ||
![]() |
100f72c193 | ||
![]() |
b7ab3f9a54 | ||
![]() |
5df4902c4e | ||
![]() |
8b84747df3 | ||
![]() |
d195917ec1 | ||
![]() |
a1830973c7 | ||
![]() |
80e6bcfd34 | ||
![]() |
cd05cc45ff | ||
![]() |
28fee06006 | ||
![]() |
1b80b69e73 | ||
![]() |
3c4c2a6c04 | ||
![]() |
05e886c9fa | ||
![]() |
f8c73bdbd6 | ||
![]() |
73b76cad57 | ||
![]() |
b3f8a99426 | ||
![]() |
e3017fa304 | ||
![]() |
db11dd9bbc | ||
![]() |
91f01e8280 | ||
![]() |
5f10c8ee74 | ||
![]() |
2177ad8619 | ||
![]() |
41a9549187 | ||
![]() |
de38b29ed4 | ||
![]() |
83cdef027a | ||
![]() |
cbb00e413d | ||
![]() |
75d62ef1e3 | ||
![]() |
adeffd27ea | ||
![]() |
eb1d6013cf | ||
![]() |
8533f4d706 | ||
![]() |
ba6c48caac | ||
![]() |
4ca16228da | ||
![]() |
0f3afec935 | ||
![]() |
9887432e1d | ||
![]() |
0d47cd1503 | ||
![]() |
7a8c9c78e7 | ||
![]() |
5cf80d1690 | ||
![]() |
31dfb6a92e | ||
![]() |
6bd1ef0de6 | ||
![]() |
c58179ef32 | ||
![]() |
36f36fcea9 | ||
![]() |
b4cbe825e7 | ||
![]() |
fd3d64aa16 | ||
![]() |
d42cabd734 | ||
![]() |
117738ee5e | ||
![]() |
2cf9242785 | ||
![]() |
e82e9ce975 | ||
![]() |
6218327628 | ||
![]() |
23c9e4b6da | ||
![]() |
850a6bf5e7 | ||
![]() |
28f97ad822 |
21
.github/workflows/build.yaml
vendored
Normal file
21
.github/workflows/build.yaml
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
name: Build libctru
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Test build
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: 'devkitpro/devkitarm'
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: build
|
||||
run: make -C libctru
|
40
.github/workflows/doxygen.yaml
vendored
Normal file
40
.github/workflows/doxygen.yaml
vendored
Normal file
@ -0,0 +1,40 @@
|
||||
name: Build documentation
|
||||
|
||||
on:
|
||||
push:
|
||||
tags: [ v* ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build documentation
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Get current tag
|
||||
id: vars
|
||||
run: echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//}
|
||||
|
||||
- name: Set up Doxygen
|
||||
run: sudo apt-get install -y doxygen
|
||||
|
||||
- name: Display Doxygen version
|
||||
run: echo "Doxygen version $(doxygen -v)"
|
||||
|
||||
- name: Build documentation
|
||||
run: |
|
||||
git clone --branch=master --single-branch --depth 1 https://github.com/devkitPro/3ds-examples examples
|
||||
cd libctru
|
||||
CTRU_VERSION=${{ steps.vars.outputs.tag }} doxygen Doxyfile
|
||||
|
||||
- name: Deploy 🚀
|
||||
uses: JamesIves/github-pages-deploy-action@3.7.1
|
||||
with:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
BRANCH: gh-pages
|
||||
FOLDER: libctru/docs/html
|
||||
CLEAN: true
|
||||
SINGLE_COMMIT: true
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -5,3 +5,7 @@
|
||||
Thumbs.db
|
||||
build/
|
||||
lib/
|
||||
docs/
|
||||
examples/
|
||||
internal_docs
|
||||
build.sh
|
||||
|
481
Changelog.md
Normal file
481
Changelog.md
Normal file
@ -0,0 +1,481 @@
|
||||
# Changelog
|
||||
|
||||
## Version 2.4.0
|
||||
|
||||
- **Added full support of all QTM services**, with extensive documentation and technical details in `qtm.h` and `qtmc.h`** (breaking change); examples have been updated for this
|
||||
- Added MCUHWC_SetInfoLedPattern
|
||||
- Added ndspChnGetFormat
|
||||
- Fixed PTMSYSM_CheckNew3DS
|
||||
- Fixed NDMU_QueryStatus
|
||||
- Fixed a few service commands improperly deserializing boolean output
|
||||
- Fixed documentation of ACU_GetWifiStatus and ACU_SetAllowApType
|
||||
- Fixed shaderInstanceInit to initialize all fields
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 2.3.0
|
||||
|
||||
- Fix typo in docs by @DeltaF1 in https://github.com/devkitPro/libctru/pull/525
|
||||
- Add GPU_DOT3_RGBA texture combiner function by @oreo639 in https://github.com/devkitPro/libctru/pull/528
|
||||
- FSUSER_GetLegacyBannerData: Fix documentation typo by @Tekito-256 in https://github.com/devkitPro/libctru/pull/526
|
||||
- Add CTR_ prefix to ALIGN,PACKED,DEPRECATED macros by @glebm in https://github.com/devkitPro/libctru/pull/532
|
||||
- Buffer console control sequences by @piepie62 in https://github.com/devkitPro/libctru/pull/522
|
||||
- Prevent CPU from postponing threadOnException memory writes
|
||||
- Add SSID-related ac:i functions
|
||||
- ACI_LoadNetworkSetting, ACI_GetNetworkWirelessEssidSecuritySsid and acGetSessionHandle.
|
||||
- Prevent double call of destructors on exit.
|
||||
- Added experimental support for standard threading APIs (pthread, C threads, C++ std::thread)
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## New Contributors
|
||||
- @DeltaF1 made their first contribution in https://github.com/devkitPro/libctru/pull/525
|
||||
- @Tekito-256 made their first contribution in https://github.com/devkitPro/libctru/pull/526
|
||||
- @glebm made their first contribution in https://github.com/devkitPro/libctru/pull/532
|
||||
|
||||
## Version 2.2.2
|
||||
|
||||
- archive_dev: Ensure path separator for local path
|
||||
- adjust struct hostent for compatibilty
|
||||
|
||||
## Version 2.2.1
|
||||
|
||||
- add `_SOCKLEN_T_DECLARED`
|
||||
|
||||
## Version 2.2.0
|
||||
|
||||
- apt: add deliver arg support to chainloader
|
||||
|
||||
## Version 2.1.2
|
||||
|
||||
- Added cdc:CHK service wrappers
|
||||
- Added support for `clock_gettime` (#495)
|
||||
- svc: Fixed svcGetDmaState writing out-of-bounds data
|
||||
- svc: Changed svcCreateCodeSet address parameters to pointer-sized integers, improve documentation
|
||||
- fspxi: Fixed FSPXI_CreateFile and FSPXI_WriteFile (#496)
|
||||
- ndsp: Added various ndspGet\* and ndspChnGet\* methods (#505, #506, #507)
|
||||
- ir: Added IRU_GetSend/RecvFinishedEvent (#513)
|
||||
- errf: Added ERRF_SetUserString and clarify documentation
|
||||
- mcuhwc: Added mcuHwcGetSessionHandle
|
||||
- apt: Fixed dirty homebrew chainload bug (used when Home Menu hasn't been started)
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 2.1.1
|
||||
|
||||
- FPSCR is now initialized with a predictable value in all threads (including the main thread).
|
||||
- Added gspGetSessionHandle and gspLcdGetSessionHandle.
|
||||
- Fixed bugs related to uninitialized data in srv/errf service wrappers.
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 2.1.0
|
||||
|
||||
**The #define for the 3DS platform has been changed to `__3DS__` (previously it was `_3DS`) - please update your Makefiles and your code**
|
||||
|
||||
### graphics
|
||||
|
||||
- Refactored VRAM allocators:
|
||||
- Added proper handling for VRAM banks (A and B, 3 MiB each)
|
||||
- Allocations no longer cross VRAM bank boundaries
|
||||
- Added vramAllocAt, vramMemAlignAt
|
||||
- Add gspIsPresentPending.
|
||||
- Add return value to gspPresentBuffer.
|
||||
- libctru console now supports SGR 38 and 48 escape sequences (needed by fmtlib).
|
||||
- Fixed GPU_TEXFACE enum.
|
||||
|
||||
### filesystem
|
||||
|
||||
- Changed rename to replace existing files, for better compatibility with POSIX (#483)
|
||||
- Added SDMMC speed info types, and more clock rates (#480).
|
||||
|
||||
### miscellaneous
|
||||
|
||||
- Added support for 3dslink stdio redirection (#488).
|
||||
- Added ptm:gets, ptm:sets and more ptm service commands.
|
||||
- Added AM_ContentInfo, AM_ContentInfoFlags structs.
|
||||
- Added AMAPP_GetDLCContentInfoCount, AMAPP_ListDLCContentInfos.
|
||||
- Fixed bug in Huffman decoder.
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 2.0.1
|
||||
|
||||
- Added CFG_SystemModel enum.
|
||||
- Fixed bug in condvar code.
|
||||
- Fixed bug in srvpm code.
|
||||
- Fixed const correctness issues in gspgpu code.
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 2.0.0
|
||||
|
||||
**This is a major release. Many essential components have been overhauled, although breaking changes are minimal and only affect rarely used functionality.**
|
||||
|
||||
### system
|
||||
|
||||
- Added support for userAppInit/userAppExit (backported from libnx).
|
||||
- Changed default heap allocation logic to be more robust:
|
||||
- Resource limit SVCs are now used to detect available memory.
|
||||
- The heap size calculation algorithm was tweaked so that 32MB of linear heap are available for normal apps running under the default appmemtype layout on Old 3DS, as it was the case prior to libctru 1.8.0.
|
||||
- SVC enhancements:
|
||||
- Added svcControlPerformanceCounter with corresponding enums.
|
||||
- Overhauled support for DMA related SVCs:
|
||||
- Added svcRestartDma.
|
||||
- Added enums and structures needed for DMA SVCs.
|
||||
- Added dmaDeviceConfigInitDefault, dmaConfigInitDefault.
|
||||
- Added svcArbitrateAddressNoTimeout (minor ABI optimization for the svcArbitrateAddress syscall when the timeout parameter is not used).
|
||||
- Changed process memory SVCs to use u32 parameters instead of void\* for foreign-process addresses.
|
||||
- Major refactor of OS related functions:
|
||||
- Added defines for Arm11 userland memory region addresses/sizes.
|
||||
- Added struct definitions for the kernel/system shared config pages: osKernelConfig_s, osSharedConfig_s.
|
||||
- Added macros to access the kernel/system shared config pages: OS_KernelConfig, OS_SharedConfig.
|
||||
- Fixed return type of osGetMemRegionUsed, osGetMemRegionFree (s64 -> u32).
|
||||
- Refactored osConvertVirtToPhys and added support for the missing linearly mapped memory regions.
|
||||
- Rewritten RTC time reading support to improve accuracy and match official logic more closely.
|
||||
- Time drift correction is now implemented.
|
||||
- Added osGetTimeRef function for reading the current reference timepoint published by the PTM sysmodule.
|
||||
- Fixed osStrError to actually work properly.
|
||||
- Cleaned up osGetSystemVersionData implementation.
|
||||
- Other miscellaneous internal cleanup.
|
||||
|
||||
### synchronization
|
||||
|
||||
- Improved safety of usermode synchronization primitives when used in intercore contexts.
|
||||
- Added CondVar synchronization primitive implementation.
|
||||
- Added syncArbitrateAddress, syncArbitrateAddressWithTimeout.
|
||||
- These functions replace \_\_sync\_get\_arbiter (which has been removed).
|
||||
- Added \_\_dmb (Data Memory Barrier) intrinsic.
|
||||
- Added LightEvent_WaitTimeout.
|
||||
- Added LightSemaphore_TryAcquire.
|
||||
- Changed LightLock to support 0 as a valid initial (unlocked) state.
|
||||
- This effectively adds support for trivially initialized/zerofilled locks.
|
||||
- Fixed bug in LightSemaphore_Acquire.
|
||||
|
||||
### graphics
|
||||
|
||||
- Major refactor of the GSP service wrapper. It should now be possible to use GSP directly without the gfx API, if the user so desires.
|
||||
- Major internal refactor of the gfx wrapper API that increases maintainability.
|
||||
- Added support for 800px wide mode with non-square pixels on the top screen - usable on every 3DS model except for Old 2DS (but *including* New 2DS XL).
|
||||
- Added support for 800px wide mode to the libctru console.
|
||||
- Transferred most of the GSP initialization duties to gspInit/gspExit (previously done by the gfx wrapper).
|
||||
- Added defines for screen IDs and screen dimensions.
|
||||
- Added gspPresentBuffer for pushing a framebuffer to the internal GSP swap queue (previously this was an internal function in the gfx wrapper).
|
||||
- Added gspGetBytesPerPixel, gspHasGpuRight.
|
||||
- Added gfxScreenSwapBuffers, with support for duplicating left->right eye content during stereoscopic 3D mode.
|
||||
- Fixed LCD configuration mode when using framebuffers on VRAM with the gfx wrapper.
|
||||
- Changed gfxExit to set LCD force-black status to true.
|
||||
- Changed the gfx wrapper to always use gspPresentBuffer during swap. This means the immediate parameter of gfxConfigScreen no longer has any effect, and gfxSwapBuffers/gfxSwapBuffersGpu now do the same thing - that is, present the rendered content during the next VBlank.
|
||||
- Renamed GSPGPU_FramebufferFormats enum to GSPGPU_FramebufferFormat.
|
||||
- Deprecated gfxConfigScreen (use gfxScreenSwapBuffers instead).
|
||||
- Removed gspInitEventHandler, gspExitEventHandler (now handled automatically inside gspInit/gspExit).
|
||||
- Removed sharedGspCmdBuf param from gspSubmitGxCommand (now uses the proper GSP shared memory address automatically).
|
||||
- Removed GSPGPU_REBASE_REG define (leftover from early 3DS homebrew).
|
||||
- Removed numerous internal fields that were previously publicly accessible.
|
||||
|
||||
### audio
|
||||
|
||||
- DSP access rights are now managed using a hook mechanism, similar to the APT hook.
|
||||
- This fixes audio playback during libapplet invocations, as they no longer relinquish DSP rights.
|
||||
- Changed NDSP to use the DSP hook instead of the APT hook.
|
||||
- Added dspIsComponentLoaded, dspHook, dspUnhook.
|
||||
- Fixed and improved robustness of wavebuf handling in NDSP code.
|
||||
- Fixed and refactored NDSP sleep/wakeup code to improve accuracy compared to official logic.
|
||||
|
||||
### filesystem
|
||||
|
||||
- Reduced TLS footprint of the archive/romfs devices by sharing buffers.
|
||||
- Reduced the maximum number of concurrently registered archive devices from 32 to 8 in order to save memory.
|
||||
- Backported multi-mount romfs system from libnx, with additional optimizations (breaking API change).
|
||||
- Added romfsMountFromTitle.
|
||||
- Fixed stat for romfs device to return -1 for non-existent files/directories.
|
||||
|
||||
### applet
|
||||
|
||||
- Major internal refactor of the APT service wrapper that should improve accuracy compared to official logic.
|
||||
- Fixed sleep handling when the app is inactive (i.e. app is suspended).
|
||||
- Added support for screen capture during libapplet transitions.
|
||||
- Added support for proper DSP access right management.
|
||||
- aptLaunchLibraryApplet no longer calls aptMainLoop internally. Library applet calls no longer return a bool value, users are advised to check APT state manually afterwards.
|
||||
- Added functions for checking APT state: aptIsActive, aptShouldClose, aptShouldJumpToHome, aptCheckHomePressRejected (replaces aptIsHomePressed).
|
||||
- Added functions for handling incoming requests: aptHandleSleep, aptHandleJumpToHome.
|
||||
- Added aptJumpToHomeMenu.
|
||||
- Changed aptMainLoop to use the new wrapper functions (this means aptMainLoop can now be replaced by custom logic if desired).
|
||||
- Changed APTHOOK_ONEXIT to be invoked during aptExit instead of during aptMainLoop.
|
||||
- Added aptClearChainloader, aptSetChainloaderToSelf.
|
||||
|
||||
### miscellaneous
|
||||
|
||||
- Fix decompress out-of-bounds access.
|
||||
- Added NDM_ prefix to NDM enum members in order to avoid name collisions.
|
||||
- Corrected parameter type in several CFGU functions.
|
||||
- Corrected return value of GSPLCD_GetBrightness.
|
||||
- Removed obsolete support for ninjhax 1.x's fake hb:HB service.
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 1.9.0
|
||||
|
||||
- hid: Added hidKeysDownRepeat, hidWaitForAnyEvent. Allow user override of irsst usage.
|
||||
- Add ptm rtc time commands
|
||||
- Add sleep state FSM handling service commands
|
||||
- Revamp mappableAlloc
|
||||
- Fixed stat on romfs for directories, implemented lstat via stat (FAT32 has no symlinks)
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 1.8.0
|
||||
|
||||
- Added support for environments where the home menu is not launched (such as running under SAFE_FIRM)
|
||||
- Added FSPXI service wrappers
|
||||
- Changed heap allocation logic to be more flexible; this fixes support for certain system memory layouts
|
||||
- Cleaned up and optimized light lock locking code
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 1.7.0
|
||||
|
||||
- fix FIONBIO ioctl
|
||||
- Fix CAMU_GetLatestVsyncTiming
|
||||
- Add archive STDIO device driver
|
||||
- Add AC commands that allow forcing a wifi connection
|
||||
- Fix dspInit() error handling in ndspInit()
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 1.6.0
|
||||
|
||||
- Major overhaul to font loading code in order to support loading external fonts.
|
||||
- Major overhaul to PM service wrappers, now with separate support for pm:app and pm:dbg.
|
||||
- Added Rosalina GDB host IO (gdbhio) support.
|
||||
- Added support for the fs:REG service.
|
||||
- Added support for the PxiPM service.
|
||||
- Added PM launch flag definitions.
|
||||
- Added SO_BROADCAST.
|
||||
- Added new APT helper functions: aptIsHomeAllowed, aptSetHomeAllowed, aptIsHomePressed.
|
||||
- Added support for the Mii selector libapplet, and other improvements to Mii support.
|
||||
- Renamed IPC_Desc_CurProcessHandle to IPC_Desc_CurProcessId.
|
||||
- Changed signature of LOADER_RegisterProgram to use FS_ProgramInfo structs.
|
||||
- Fixed IPC bugs in the Loader service.
|
||||
- Fixed svcCreateResourceLimit.
|
||||
- Fixed corner case bug in GPUCMD_Add.
|
||||
- Fixed bugs in select and herror.
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 1.5.1
|
||||
|
||||
- Added support for the FRD service.
|
||||
- Added gas-related GPU definitions.
|
||||
- Implemented nanosleep.
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 1.5.0
|
||||
|
||||
- Added new decompression API which supports LZSS/LZ10, LZ11, RLE & Huffman formats, and which can read compressed data from memory or from a file.
|
||||
- Added srvSetBlockingPolicy, which controls whether srvGetServiceHandle blocks when the service isn't yet registered (or returns an error otherwise).
|
||||
- Added ACU commands: ACU_GetStatus, ACU_GetSecurityMode, ACU_GetSSIDLength, ACU_GetSecurityMode, ACU_GetProxyEnable, ACU_GetProxyPort, ACU_GetProxyUserName, ACU_GetProxyPassword, ACU_GetLastErrorCode, ACU_GetLastDetailErrorCode.
|
||||
- Added CFGI commands: CFGI_SecureInfoGetSerialNumber, CFGU_IsNFCSupported, CFGI_GetLocalFriendCodeSeed, CFGI_GetLocalFriendCodeSeedData, CFGI_GetSecureInfoData, CFGI_GetSecureInfoSignature.
|
||||
- Added MCUHWC commands: MCUHWC_SetWifiLedState, MCUHWC_SetPowerLedState, MCUHWC_Get3dSliderLevel, MCUHWC_GetFwVerHigh, MCUHWC_GetFwVerLow.
|
||||
- Added NS commands: NS_TerminateTitle, NS_TerminateProcessTID (with timeout), NS_RebootSystem.
|
||||
- Added PM commands: PM_TerminateCurrentApplication, PM_TerminateProcess, PM_UnregisterProcess.
|
||||
- Overhauled NDMU service support and added many commands that were previously missing.
|
||||
- Fixed bugs in srv:pm implementation.
|
||||
- Fixed calculation of vertical texture coordinates in fontCalcGlyphPos.
|
||||
- Fixed shaderProgramSetGshInputPermutation.
|
||||
- Fixed and added clock speed constants (affects system clock and NDSP).
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 1.4.0
|
||||
|
||||
- Added LightSemaphore synchronization primitive.
|
||||
- Added exheader definitions.
|
||||
- Added support for the Loader service.
|
||||
- Added support for the mcu::HWC service.
|
||||
- Added support for the Mii selector applet.
|
||||
- Added ResourceLimitType.
|
||||
- Added AM commands: AM_DeleteAllTemporaryTitles, AM_DeleteAllExpiredTitles, AM_DeleteAllTwlTitles.
|
||||
- Added CFGI commands: CFGI_RestoreLocalFriendCodeSeed, CFGI_RestoreSecureInfo, CFGI_DeleteConfigSavefile, CFGI_FormatConfig, CFGI_ClearParentalControls, CFGI_VerifySigLocalFriendCodeSeed, CFGI_VerifySigSecureInfo.
|
||||
- Added GSPGPU commands: GSPGPU_SetLedForceOff.
|
||||
- Added GSPLCD commands: GSPLCD_SetBrightness, GSPLCD_SetBrightnessRaw, GSPLCD_PowerOnAllBacklights, GSPLCD_PowerOffAllBacklights, GSPLCD_SetLedForceOff.
|
||||
- Fixed srv:pm handling in pre-7.x system versions.
|
||||
- Fixed GPU_LIGHTPERM macro definition.
|
||||
- Removed the remaining deprecated GPUCMD commands.
|
||||
- Further improvements to overall system stability and other minor adjustments have been made to enhance the user experience.
|
||||
|
||||
## Version 1.3.0
|
||||
|
||||
- Implement more svc calls
|
||||
- svcCreateResourceLimit
|
||||
- svcSetResourceLimitValues
|
||||
- svcSetProcessResourceLimits
|
||||
- svcCreateSession
|
||||
- svcCreateSessionToPort
|
||||
- svcSetGpuProt
|
||||
- svcSetWifiEnabled
|
||||
- Additional functions
|
||||
- implement httpcAddPostDataBinary
|
||||
- implement PTMU_GetAdapterState
|
||||
- implement GSPLCD_GetBrightness
|
||||
- add threadDetach
|
||||
- srv fixes
|
||||
- Fix srvPublishToSubscriber documentation
|
||||
- Fix handling of service/named port names of length 8
|
||||
- Fix srvRegisterPort
|
||||
- debugging support
|
||||
- Add support for user-specified exception handlers
|
||||
- Rename debugDevice_3DMOO to debugDevice_SVC
|
||||
- created debug version of library
|
||||
- Implement error applet
|
||||
- GPU updates
|
||||
- Add GX command queue system for batching GX commands
|
||||
- Correct GPU_PROCTEX_LUTID definition
|
||||
- Add GPU_FOGMODE, GPU_GASMODE and GPU_GASLUTINPUT
|
||||
- Other improvements and minor adjustments for overall system stability to enhance the user experience
|
||||
|
||||
## Version 1.2.1
|
||||
|
||||
- Added NFC support
|
||||
- Update and renamed NFC_AmiiboConfig members
|
||||
- Added TickCounter for measuring performance
|
||||
- Added (linear/vram/mappable)GetSize for retrieving allocated buffer size
|
||||
- Added nim:s client implementation.
|
||||
- Correct bus clock used for time calulations
|
||||
- Default to file write without internal copy buffer
|
||||
- GPUCMD_Add: allow NULL for adding zerofilled parameter data
|
||||
- Clarify threadFree usage in documentation
|
||||
- Add GPU_TEXFACE enumeration
|
||||
|
||||
## Version 1.2.0
|
||||
|
||||
* New features:
|
||||
- Added support for the nfc:m/nfc:u service.
|
||||
- Added support for the ssl:C service.
|
||||
- Added support for the nwm::UDS service (Local wireless).
|
||||
- Added support for the boss:P/boss:U service (SpotPass).
|
||||
- Added support for using the err:f global port.
|
||||
- Added support for using and parsing the shared system font.
|
||||
- Added support for using the 3DS' built-in software keyboard applet.
|
||||
- Added support for using Light Events, a lightweight alternative to normal events that doesn't consume handles.
|
||||
- Added NDSP commands for setting up per-channel monopole & biquad filters.
|
||||
|
||||
* Major breaking changes:
|
||||
- Major revamp of the APT code; some old deprecated functions were completely removed, homebrew code abiding by recent standards shouldn't be affected though.
|
||||
- Major revamp of the HTTPC code, including both additions and bugfixes.
|
||||
- Major revamp of the AM code, with some enhancements.
|
||||
- Major revamp of FSUSER code, archive handle handling has been refactored. fs(End)UseSession replaced with fsExemptFromSession.
|
||||
- Major revamp of MVD code to support video processing.
|
||||
- Major revamp of the GPU shader code to fully support geometry shaders.
|
||||
- The old deprecated GPU wrapper commands have been removed. Use direct GPU register writes or a separate GPU wrapper library (such as citro3d) instead.
|
||||
- Major revamp and update of the SVC debugger API.
|
||||
- Heap size management has been simplified and made more flexible. All applications now default to 32MB of linear heap and all remaining APPLICATION memory is allocated as the application heap, regardless of entrypoint or application format.
|
||||
|
||||
* Miscellaneous additions:
|
||||
- Several enhancements to SOC:u support:
|
||||
- Added getaddrinfo, getnameinfo, gethostname, gai_strerror.
|
||||
- Added SOCU_ShutdownSockets, SOCU_CloseSockets, SOCU_GetIPInfo, SOCU_GetNetworkOpt, SOCU_AddGlobalSocket.
|
||||
- Added several missing flags.
|
||||
- Minor am:net corrections and additions.
|
||||
- Added sdmcWriteSafe to disable copying data to temporary RW buffers before calling FSFILE_Write.
|
||||
- Added sdmc_getmtime to retrieve the modification time for a file.
|
||||
- Added opendir/readdir/rewinddir/closedir/stat support to romfs.
|
||||
- Added support for multiple RomFS mounts.
|
||||
- Added macros for console color codes (ANSI escape sequences).
|
||||
- Added support for specifying a fallback RomFS path for when argv isn't available.
|
||||
- Added aptIsSleepAllowed/aptSetSleepAllowed.
|
||||
- Added ResetType enum for use with svcCreateEvent and svcCreateTimer.
|
||||
- Added psInitHandle and psGetSessionHandle.
|
||||
- Added AM commands: AM_ExportTwlBackup, AM_ImportTwlBackup, AM_ReadTwlBackupInfo, AM_DeleteAllDemoLaunchInfos, AM_FinishCiaInstallWithoutCommit, AM_CommitImportPrograms.
|
||||
- Added AMPXI commands: AMPXI_WriteTWLSavedata, AMPXI_InstallTitlesFinish.
|
||||
- Added APT commands: APT_ReceiveDeliverArg.
|
||||
- Added CFG commands: CFG_GetConfigInfoBlk4, CFG_GetConfigInfoBlk8, CFG_SetConfigInfoBlk4, CFG_SetConfigInfoBlk8, CFG_UpdateConfigNANDSavegame.
|
||||
- Added GSPLCD commands: GSPLCD_GetVendors
|
||||
- Added FSUSER commands: FSUSER_UpdateSha256Context.
|
||||
- Added NEWS commands: NEWS_GetTotalNotifications, NEWS_SetNotificationHeader, NEWS_GetNotificationHeader, NEWS_GetNotificationMessage, NEWS_GetNotificationImage, NEWS_SetNotificationMessage, NEWS_SetNotificationImage.
|
||||
- Added NS commands: NS_TerminateProcessTID, NS_LaunchFIRM, NS_LaunchApplicationFIRM.
|
||||
- Added PS commands: PS_SignRsaSha256, PS_VerifyRsaSha256.
|
||||
- Added PTMSYSM commands: PTMSYSM_CheckNew3DS, PTMSYSM_ShutdownAsync, PTMSYSM_RebootAsync.
|
||||
- Added PXIDEV commands: PXIDEV_SPIMultiWriteRead, PXIDEV_SPIWriteRead.
|
||||
- Added system calls: svcCreateCodeSet, svcCreateProcess, svcGetResourceLimit, svcGetResourceLimitValues, svcGetResourceLimitCurrentValues, svcSetProcessAffinityMask, svcSetProcessIdealProcessor, svcRun, svcBindInterrupt, svcUnbindInterrupt, svcGetHandleInfo, svcBreakRO, svcGetThreadList.
|
||||
- Added result module codes.
|
||||
- Added GPU A4 texture format enum.
|
||||
|
||||
* Miscellaneous changes and bug fixes:
|
||||
- Optimized sdmc's readdir to batch directory entries.
|
||||
- APT, GSPGPU and NDSP code was tuned to take advantage of Light Events.
|
||||
- Moved am:app init to a separate function.
|
||||
- Several issues concerning IPC static buffer saving/restoring were fixed.
|
||||
- Several issues concerning sdmc/RomFS devoptabs were fixed.
|
||||
- Several issues concerning SOC:u were fixed.
|
||||
- An issue concerning cam:u was fixed.
|
||||
- An issue concerning HID was fixed.
|
||||
- An issue concerning news:u was fixed.
|
||||
- The GPU ETC1 texture format enums were fixed.
|
||||
- usleep was fixed.
|
||||
- Fixed incorrect bool return values from services.
|
||||
- Fixed buffer overflow after gfxSetScreenFormat.
|
||||
- Fixed home menu display of suspended 2D applications.
|
||||
- Fixed buffer overrun in console code.
|
||||
- Fixed PS_EncryptDecryptAes and PS_EncryptSignDecryptVerifyAesCcm.
|
||||
- Fixed the implementation of svcGetProcessList.
|
||||
- Corrected svcKernelSetState function signature.
|
||||
|
||||
## Version 1.1.0
|
||||
|
||||
* Additions:
|
||||
- GSPGPU/GX code was revised and enhanced:
|
||||
- Screens can be buffer-swapped independently using the new gfxConfigScreen function.
|
||||
- Added gspSetEventCallback for running event code directly on the GSP thread.
|
||||
- Added gspWaitForAnyEvent for waiting for any GSP event.
|
||||
- Added gfxIs3D for retrieving 3D-enable status.
|
||||
- Added AM_InstallFirm.
|
||||
- Added __sync_get_arbiter.
|
||||
- Added support for usleep.
|
||||
|
||||
* Changes:
|
||||
- NDSP thread priority has been increased, therefore mitigating potential sound issues due to high CPU usage on the main thread.
|
||||
- RomFS initialization no longer makes romfs:/ the default device.
|
||||
|
||||
* Bug fixes:
|
||||
- Fixed the timeout parameter in svcArbitrateAddress.
|
||||
- Fixed svcSetTimer.
|
||||
|
||||
## Version 1.0.0
|
||||
|
||||
* New features:
|
||||
- libctru documentation is now available at http://smealum.github.io/ctrulib/
|
||||
- Added the NDSP API, which allows the use of the DSP (audio).
|
||||
- Added Inter Process Communication helpers.
|
||||
- Added Result code helpers.
|
||||
- Added support for lightweight synchronization primitives.
|
||||
- Added support for making the C/C++ standard libraries thread safe.
|
||||
- Added support for thread-local objects, with the use of standard C and C++ constructs (or GCC extensions).
|
||||
- Added a new threading API that properly manages internal state. Direct usage of svcCreateThread is deprecated.
|
||||
- Added a mappable address space allocator. Services which need to map shared memory blocks now use this allocator.
|
||||
- Added support for embedded RomFS, embedded SMDH and GPU shader building in the template Makefiles.
|
||||
|
||||
* Changes and additions to the GPU code:
|
||||
- Stateless wrapper functions (GPU_*) that merely masked GPU register usage were deprecated, in favour of external GPU wrapper libraries such as citro3d. A future release of libctru may remove them.
|
||||
- The API set has therefore been simplified down to command list management.
|
||||
- Synchronized register names with the 3dbrew Wiki.
|
||||
- Added fragment lighting registers and enums.
|
||||
- Added procedural texture registers and enums.
|
||||
- Added shaderProgramSetGshInputPermutation, for configuring the wiring between the vertex shader and the geometry shader.
|
||||
- Added shaderProgramSetGshMode, for configuring the geometry shader operation mode.
|
||||
- Added shaderProgramConfigure, intended to be used by GPU wrapper libraries.
|
||||
- SHBIN/shaderProgram code now correctly computes and sets the values of the GPUREG_SH_OUTATTR_MODE/CLOCK registers.
|
||||
- GX function naming has been improved, and the initial GX command buffer parameter has been removed.
|
||||
|
||||
* Major changes and miscellaneous additions:
|
||||
- Sweeping changes to make function/structure/enum naming more consistent across the whole library. This affects a lot of code.
|
||||
- Compiler/linker flags have been tweaked to increase performance and reduce code size, through the garbage collection of unused functions.
|
||||
- Service initialization is now reference counted in order to properly manage dependencies.
|
||||
- Initial service handle parameters have been removed, since they were nearly always set to NULL.
|
||||
- Completed coverage of srv and FSUSER service calls.
|
||||
- Added fsUseSession and fsEndUseSession for overriding the FSUSER session used in commands in the current thread.
|
||||
- Added osGet3DSliderState, osSetSpeedupEnable, osGetSystemVersionData and osGetSystemVersionDataString.
|
||||
- Refactored the MICU service.
|
||||
- NCCH versions of applications now detect the maximum amount of available memory on startup.
|
||||
|
||||
* Miscellaneous changes and bug fixes:
|
||||
- Commits and pull requests are now built on travis to check that the library compiles, and to generate the documentation.
|
||||
- General changes and improvements to overall code quality.
|
||||
- Added the missing struct and functions for Y2R.
|
||||
- Added srvGetServiceHandleDirect for bypassing the handle override mechanism.
|
||||
- Usage of the CSND service in new applications is not recommended, however it is not deprecated. The usage of NDSP instead is advised.
|
||||
- Usage of the HB service in new applications is not recommended due to its necessary removal in hax 2.x, however it is not deprecated.
|
||||
- Several bugs affecting APT were fixed.
|
||||
- Several bugs affecting C++ were fixed.
|
||||
|
||||
## Version 0 through 0.6.0
|
||||
|
||||
No changelog available.
|
29
README.md
29
README.md
@ -1,24 +1,27 @@
|
||||
ctrulib
|
||||
=======
|
||||
# libctru - CTR User Library
|
||||
|
||||
CTR User Library
|
||||

|
||||
|
||||
library for writing user mode arm11 code for the 3DS (CTR)
|
||||
Library for writing user mode ARM11 code for the 3DS (CTR)
|
||||
|
||||
the goal with this is to create a very straightforward interface with the 3DS's OS.
|
||||
it is not meant to provide higher level functions; to put things in perspective, the purpose of ctrulib would be to sit between the OS and a possible port of SDL rather than replace it.
|
||||
This library aims to provide the foundations necessary to write 3DS Homebrew, and straightforwardly access the different functionalities provided by the 3DS operating system.
|
||||
It is not meant to provide higher level functions; to put things in perspective, the purpose of libctru would be to sit between the OS and a possible port of SDL rather than replace it.
|
||||
|
||||
setup
|
||||
=======
|
||||
*(Originally located at github.com/smealum/ctrulib)*
|
||||
|
||||
ctrulib is just a library and needs a toolchain to function. we built ctrulib to be used in conjunction with devkitARM. you may find instructions on how to install devkitARM here : http://devkitpro.org/wiki/Getting_Started
|
||||
# Setup
|
||||
|
||||
The most recent devkitARM (r43) includes 3DS support and a prebuilt libctru.
|
||||
libctru is just a library and needs a toolchain to function. devkitARM (created by [devkitPro](http://devkitpro.org)) is the officially supported ARM cross compiling toolchain, which provides the framework necessary to supply a usable POSIX-like environment, with working C and C++ standard libraries; as well as the tools required to compile homebrew in the 3DSX format, and assemble GPU shaders. The use of other ARM toolchains is severely discouraged.
|
||||
|
||||
To keep up to date with the most recent changes you'll want to checkout ctrulib, build it and install it.
|
||||
The most recent version of devkitARM is always recommended. The [installers/setup scripts](https://devkitpro.org/wiki/devkitPro_pacman) supplied by devkitPro install a prebuilt copy of the latest stable version of libctru, which is recommended for general use. Please note that devkitPro has a policy of keeping legacy code to a minimum, so a library upgrade may result in older code failing to compile or behave properly. Developers are encouraged to keep their code working with the latest versions of the tools and libraries.
|
||||
|
||||
license
|
||||
=======
|
||||
You may find instructions on how to install devkitARM on [the devkitPro Wiki](http://devkitpro.org/wiki/Getting_Started).
|
||||
|
||||
# Documentation
|
||||
|
||||
The documentation is automatically built upon release and can be found at the following url: https://devkitpro.github.io/libctru/
|
||||
|
||||
# License
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any
|
||||
|
3
examples/.gitignore
vendored
3
examples/.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
build/
|
||||
*.3dsx
|
||||
*.elf
|
@ -1,26 +0,0 @@
|
||||
SUBDIRS:= $(shell ls | egrep -v '^(CVS)$$')
|
||||
|
||||
DATESTRING := $(shell date +%Y)$(shell date +%m)$(shell date +%d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: examples
|
||||
#---------------------------------------------------------------------------------
|
||||
@rm -fr bin
|
||||
@mkdir -p bin
|
||||
@find . -name "*.3dsx" -exec cp -fv {} bin \;
|
||||
|
||||
examples:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
#---------------------------------------------------------------------------------
|
||||
@rm -fr bin
|
||||
@rm -f *.bz2
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
dist: clean
|
||||
#---------------------------------------------------------------------------------
|
||||
@rm -fr bin
|
||||
@tar --exclude=.svn --exclude=*CVS* -cvjf 3ds-examples-$(DATESTRING).tar.bz2 *
|
@ -1,170 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
.PHONY: all
|
||||
all : $(OUTPUT).3dsx $(OUTPUT).smdh
|
||||
endif
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
# WARNING: This is not the right way to do this! TODO: Do it right!
|
||||
#---------------------------------------------------------------------------------
|
||||
%.vsh.o : %.vsh
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@rm ../$(notdir $<).shbin
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1,9 +0,0 @@
|
||||
app_launch
|
||||
=======
|
||||
|
||||
Example for launching other apps/applets with ctrulib. Press the A button to launch the app or applet specified in the source.
|
||||
|
||||
|
||||
Note: The title ID of the EUR Nintendo 3DS Camera app is hardcoded and you need to change it if your 3DS is not an european one. See here for title IDs: http://3dbrew.org/wiki/Title_list#00040010_-_System_Applications
|
||||
This example only works if launched as regular app by the home menu. It will not work with the homebrew menu.
|
||||
|
@ -1,49 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <3ds.h>
|
||||
|
||||
|
||||
|
||||
int main()
|
||||
{
|
||||
gfxInitDefault(); // Init graphic stuff
|
||||
|
||||
|
||||
// We need these 2 buffers for APT_DoAppJump() later. They can be smaller too
|
||||
u8 buf0[0x300];
|
||||
u8 buf1[0x20];
|
||||
|
||||
|
||||
// Loop as long as the status is not exit
|
||||
while(aptMainLoop())
|
||||
{
|
||||
// Scan hid shared memory for input events
|
||||
hidScanInput();
|
||||
|
||||
if(hidKeysDown() & KEY_A) // If the A button got pressed, start the app launch
|
||||
{
|
||||
// Clear both buffers
|
||||
memset(buf0, 0, 0x300);
|
||||
memset(buf1, 0, 0x20);
|
||||
|
||||
// Open an APT session so we can talk to the APT service
|
||||
aptOpenSession();
|
||||
// Prepare for the app launch
|
||||
APT_PrepareToDoAppJump(NULL, 0, 0x0004001000022400LL, 0); // *EUR* camera app title ID
|
||||
// Tell APT to trigger the app launch and set the status of this app to exit
|
||||
APT_DoAppJump(NULL, 0x300 /* size of buf0 */, 0x20 /* size of buf1 */, buf0, buf1);
|
||||
// Close the APT session because we don't need APT anymore
|
||||
aptCloseSession();
|
||||
}
|
||||
|
||||
// Flush + swap framebuffers and wait for VBlank. Not really needed in this example
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
gspWaitForVBlank();
|
||||
}
|
||||
|
||||
|
||||
gfxExit();
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
.PHONY: all
|
||||
all : $(OUTPUT).3dsx $(OUTPUT).smdh
|
||||
endif
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
# WARNING: This is not the right way to do this! TODO: Do it right!
|
||||
#---------------------------------------------------------------------------------
|
||||
%.vsh.o : %.vsh
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@rm ../$(notdir $<).shbin
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1,5 +0,0 @@
|
||||
mic
|
||||
=======
|
||||
|
||||
Example for using the microphone with ctrulib. Hold down the A button to record, the app will then play the recorded audio once the A button is released. Roughly 32 seconds of audio can be recorded with the default audiobuf size in this app.
|
||||
|
@ -1,88 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <3ds.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
u8 *framebuf;
|
||||
u32 *sharedmem = NULL, sharedmem_size = 0x30000;
|
||||
u8 *audiobuf;
|
||||
u32 audiobuf_size = 0x100000, audiobuf_pos = 0;
|
||||
u8 control=0x40;
|
||||
u32 audio_initialized = 0;
|
||||
|
||||
gfxInitDefault();
|
||||
|
||||
if(CSND_initialize(NULL)==0)audio_initialized = 1;
|
||||
|
||||
sharedmem = (u32*)memalign(0x1000, sharedmem_size);
|
||||
audiobuf = linearAlloc(audiobuf_size);
|
||||
|
||||
MIC_Initialize(sharedmem, sharedmem_size, control, 0, 3, 1, 1);//See mic.h.
|
||||
|
||||
while(aptMainLoop())
|
||||
{
|
||||
hidScanInput();
|
||||
gspWaitForVBlank();
|
||||
|
||||
u32 kDown = hidKeysDown();
|
||||
if (kDown & KEY_START)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if(audio_initialized)
|
||||
{
|
||||
framebuf = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
|
||||
if(kDown & KEY_A)
|
||||
{
|
||||
audiobuf_pos = 0;
|
||||
|
||||
CSND_setchannel_playbackstate(0x8, 0);//Stop audio playback.
|
||||
CSND_sharedmemtype0_cmdupdatestate(0);
|
||||
|
||||
MIC_SetRecording(1);
|
||||
|
||||
memset(framebuf, 0x20, 0x46500);
|
||||
}
|
||||
|
||||
if((hidKeysHeld() & KEY_A) && audiobuf_pos < audiobuf_size)
|
||||
{
|
||||
audiobuf_pos+= MIC_ReadAudioData(&audiobuf[audiobuf_pos], audiobuf_size-audiobuf_pos, 1);
|
||||
if(audiobuf_pos > audiobuf_size)audiobuf_pos = audiobuf_size;
|
||||
|
||||
memset(framebuf, 0x60, 0x46500);
|
||||
}
|
||||
|
||||
if(hidKeysUp() & KEY_A)
|
||||
{
|
||||
MIC_SetRecording(0);
|
||||
GSPGPU_FlushDataCache(NULL, audiobuf, audiobuf_pos);
|
||||
CSND_playsound(0x8, CSND_LOOP_DISABLE, CSND_ENCODING_PCM16, 16000, (u32*)audiobuf, NULL, audiobuf_pos, 2, 0);
|
||||
|
||||
memset(framebuf, 0xe0, 0x46500);
|
||||
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
|
||||
framebuf = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
memset(framebuf, 0xe0, 0x46500);
|
||||
}
|
||||
}
|
||||
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
}
|
||||
|
||||
MIC_Shutdown();
|
||||
|
||||
if(audio_initialized)CSND_shutdown();
|
||||
|
||||
free(sharedmem);
|
||||
linearFree(audiobuf);
|
||||
|
||||
gfxExit();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,175 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
|
||||
else
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
endif
|
||||
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
# WARNING: This is not the right way to do this! TODO: Do it right!
|
||||
#---------------------------------------------------------------------------------
|
||||
%.vsh.o : %.vsh
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@rm ../$(notdir $<).shbin
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1,4 +0,0 @@
|
||||
get_system_language
|
||||
=======
|
||||
|
||||
This is an example on how to get the system language on the 3DS.
|
@ -1,46 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <3ds.h>
|
||||
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
// Initialize services
|
||||
gfxInitDefault();
|
||||
initCfgu();
|
||||
|
||||
|
||||
u8 language = 0;
|
||||
Result res;
|
||||
|
||||
// Init console for text output
|
||||
consoleInit(GFX_BOTTOM, NULL);
|
||||
|
||||
// Read the language field from the config savegame.
|
||||
res = CFGU_GetSystemLanguage(&language);
|
||||
|
||||
// Print return value and language code
|
||||
printf(" Result: 0x%x\n", (int)res);
|
||||
printf("Language code: %d", (int)language);
|
||||
|
||||
|
||||
// Main loop
|
||||
while (aptMainLoop())
|
||||
{
|
||||
hidScanInput();
|
||||
|
||||
u32 kDown = hidKeysDown();
|
||||
if (kDown & KEY_START)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
// Flush and swap framebuffers
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
gspWaitForVBlank();
|
||||
}
|
||||
|
||||
// Exit services
|
||||
exitCfgu();
|
||||
gfxExit();
|
||||
return 0;
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
.PHONY: all
|
||||
all : $(OUTPUT).3dsx $(OUTPUT).smdh
|
||||
endif
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
# WARNING: This is not the right way to do this! TODO: Do it right!
|
||||
#---------------------------------------------------------------------------------
|
||||
%.vsh.o : %.vsh
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@rm ../$(notdir $<).shbin
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1,11 +0,0 @@
|
||||
gpu
|
||||
=======
|
||||
|
||||
example of how to use the GPU with libctru
|
||||
|
||||
before trying to compile, make sure to download aemstro
|
||||
( https://github.com/smealum/aemstro reflog: 55bf5056d199e0e9ec3d136dc830ac45a49da074 )
|
||||
and update Makefile's AEMSTROPATH definition with the proper path
|
||||
|
||||
You'll also need to install Python 3 and have that in your path.
|
||||
|
@ -1,56 +0,0 @@
|
||||
; make sure you update aemstro_as for this (15/11/14)
|
||||
|
||||
; setup constants
|
||||
.const 20, 1.0, 0.0, 0.5, 1.0
|
||||
|
||||
; setup outmap
|
||||
.out o0, result.position
|
||||
.out o1, result.color
|
||||
.out o2, result.texcoord0
|
||||
.out o3, result.texcoord1
|
||||
.out o4, result.texcoord2
|
||||
|
||||
; setup uniform map (required to use SHDR_GetUniformRegister)
|
||||
.uniform 0, 3, projection ; c0-c3 = projection matrix
|
||||
.uniform 4, 7, modelview ; c4-c7 = modelview matrix
|
||||
.uniform 8, 8, lightDirection ; c8 = light direction vector
|
||||
.uniform 9, 9, lightAmbient ; c9 = light ambient color
|
||||
|
||||
;code
|
||||
main:
|
||||
mov r1, v0 (0x6)
|
||||
mov r1, c20 (0x3)
|
||||
; tempreg = mdlvMtx * in.pos
|
||||
dp4 r0, c4, r1 (0x0)
|
||||
dp4 r0, c5, r1 (0x1)
|
||||
dp4 r0, c6, r1 (0x2)
|
||||
mov r0, c20 (0x3)
|
||||
; result.pos = projMtx * tempreg
|
||||
dp4 o0, c0, r0 (0x0)
|
||||
dp4 o0, c1, r0 (0x1)
|
||||
dp4 o0, c2, r0 (0x2)
|
||||
dp4 o0, c3, r0 (0x3)
|
||||
; result.texcoord = in.texcoord
|
||||
mov o2, v1 (0x5)
|
||||
mov o3, c20 (0x7)
|
||||
mov o4, c20 (0x7)
|
||||
; result.color = crappy lighting
|
||||
dp3 r0, c8, v2 (0x6)
|
||||
max r0, c20, r0 (0x4)
|
||||
mul r0, c9, r0 (0x8)
|
||||
add o1, c9, r0 (0x6)
|
||||
mov o1, c20 (0x3)
|
||||
flush
|
||||
end
|
||||
endmain:
|
||||
|
||||
;operand descriptors
|
||||
.opdesc x___, xyzw, xyzw ; 0x0
|
||||
.opdesc _y__, xyzw, xyzw ; 0x1
|
||||
.opdesc __z_, xyzw, xyzw ; 0x2
|
||||
.opdesc ___w, xyzw, xyzw ; 0x3
|
||||
.opdesc xyz_, yyyy, xyzw ; 0x4
|
||||
.opdesc xyzw, xyzw, xyzw ; 0x5
|
||||
.opdesc xyz_, xyzw, xyzw ; 0x6
|
||||
.opdesc xyzw, yyyw, xyzw ; 0x7
|
||||
.opdesc xyz_, wwww, xyzw ; 0x8
|
Binary file not shown.
@ -1,16 +0,0 @@
|
||||
.section ".text"
|
||||
.arm
|
||||
.align 4
|
||||
.global _vboMemcpy50
|
||||
|
||||
# r0 : dst
|
||||
# r1 : src
|
||||
# fixed size 0x50
|
||||
_vboMemcpy50:
|
||||
push {r4-r11}
|
||||
ldmia r1!, {r2-r12}
|
||||
stmia r0!, {r2-r12}
|
||||
ldmia r1!, {r2-r12}
|
||||
stmia r0!, {r2-r12}
|
||||
pop {r4-r11}
|
||||
bx lr
|
@ -1,431 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <malloc.h>
|
||||
#include <3ds.h>
|
||||
|
||||
#include "gs.h"
|
||||
#include "math.h"
|
||||
|
||||
#define BUFFERMATRIXLIST_SIZE (GS_MATRIXSTACK_SIZE*4)
|
||||
|
||||
static void gsInitMatrixStack();
|
||||
|
||||
Handle linearAllocMutex;
|
||||
|
||||
static u32 gsMatrixStackRegisters[GS_MATRIXTYPES];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u32 offset;
|
||||
mtx44 data;
|
||||
}bufferMatrix_s;
|
||||
|
||||
bufferMatrix_s bufferMatrixList[BUFFERMATRIXLIST_SIZE];
|
||||
int bufferMatrixListLength;
|
||||
|
||||
//----------------------
|
||||
// GS SYSTEM STUFF
|
||||
//----------------------
|
||||
|
||||
void initBufferMatrixList()
|
||||
{
|
||||
bufferMatrixListLength=0;
|
||||
}
|
||||
|
||||
void gsInit(DVLB_s* shader)
|
||||
{
|
||||
gsInitMatrixStack();
|
||||
initBufferMatrixList();
|
||||
svcCreateMutex(&linearAllocMutex, false);
|
||||
if(shader)
|
||||
{
|
||||
gsMatrixStackRegisters[0]=SHDR_GetUniformRegister(shader, "projection", 0);
|
||||
gsMatrixStackRegisters[1]=SHDR_GetUniformRegister(shader, "modelview", 0);
|
||||
}
|
||||
}
|
||||
|
||||
void gsExit(void)
|
||||
{
|
||||
svcCloseHandle(linearAllocMutex);
|
||||
}
|
||||
|
||||
void gsStartFrame(void)
|
||||
{
|
||||
GPUCMD_SetBufferOffset(0);
|
||||
initBufferMatrixList();
|
||||
}
|
||||
|
||||
void* gsLinearAlloc(size_t size)
|
||||
{
|
||||
void* ret=NULL;
|
||||
|
||||
svcWaitSynchronization(linearAllocMutex, U64_MAX);
|
||||
ret=linearAlloc(size);
|
||||
svcReleaseMutex(linearAllocMutex);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void gsLinearFree(void* mem)
|
||||
{
|
||||
svcWaitSynchronization(linearAllocMutex, U64_MAX);
|
||||
linearFree(mem);
|
||||
svcReleaseMutex(linearAllocMutex);
|
||||
}
|
||||
|
||||
//----------------------
|
||||
// MATRIX STACK STUFF
|
||||
//----------------------
|
||||
|
||||
static mtx44 gsMatrixStacks[GS_MATRIXTYPES][GS_MATRIXSTACK_SIZE];
|
||||
static u32 gsMatrixStackRegisters[GS_MATRIXTYPES]={0x00, 0x04};
|
||||
static u8 gsMatrixStackOffsets[GS_MATRIXTYPES];
|
||||
static bool gsMatrixStackUpdated[GS_MATRIXTYPES];
|
||||
static GS_MATRIX gsCurrentMatrixType;
|
||||
|
||||
static void gsInitMatrixStack()
|
||||
{
|
||||
int i;
|
||||
for(i=0; i<GS_MATRIXTYPES; i++)
|
||||
{
|
||||
gsMatrixStackOffsets[i]=0;
|
||||
gsMatrixStackUpdated[i]=true;
|
||||
loadIdentity44((float*)gsMatrixStacks[i][0]);
|
||||
}
|
||||
gsCurrentMatrixType=GS_PROJECTION;
|
||||
}
|
||||
|
||||
float* gsGetMatrix(GS_MATRIX m)
|
||||
{
|
||||
if(m<0 || m>=GS_MATRIXTYPES)return NULL;
|
||||
|
||||
return (float*)gsMatrixStacks[m][gsMatrixStackOffsets[m]];
|
||||
}
|
||||
|
||||
int gsLoadMatrix(GS_MATRIX m, float* data)
|
||||
{
|
||||
if(m<0 || m>=GS_MATRIXTYPES || !data)return -1;
|
||||
|
||||
memcpy(gsGetMatrix(m), data, sizeof(mtx44));
|
||||
|
||||
gsMatrixStackUpdated[m]=true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gsPushMatrix()
|
||||
{
|
||||
const GS_MATRIX m=gsCurrentMatrixType;
|
||||
if(m<0 || m>=GS_MATRIXTYPES)return -1;
|
||||
if(gsMatrixStackOffsets[m]<0 || gsMatrixStackOffsets[m]>=GS_MATRIXSTACK_SIZE-1)return -1;
|
||||
|
||||
float* cur=gsGetMatrix(m);
|
||||
gsMatrixStackOffsets[m]++;
|
||||
memcpy(gsGetMatrix(m), cur, sizeof(mtx44));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gsPopMatrix()
|
||||
{
|
||||
const GS_MATRIX m=gsCurrentMatrixType;
|
||||
if(m<0 || m>=GS_MATRIXTYPES)return -1;
|
||||
if(gsMatrixStackOffsets[m]<1 || gsMatrixStackOffsets[m]>=GS_MATRIXSTACK_SIZE)return -1;
|
||||
|
||||
gsMatrixStackOffsets[m]--;
|
||||
|
||||
gsMatrixStackUpdated[m]=true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gsMatrixMode(GS_MATRIX m)
|
||||
{
|
||||
if(m<0 || m>=GS_MATRIXTYPES)return -1;
|
||||
|
||||
gsCurrentMatrixType=m;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//------------------------
|
||||
// MATRIX TRANSFORM STUFF
|
||||
//------------------------
|
||||
|
||||
int gsMultMatrix(float* data)
|
||||
{
|
||||
if(!data)return -1;
|
||||
|
||||
mtx44 tmp;
|
||||
multMatrix44(gsGetMatrix(gsCurrentMatrixType), data, (float*)tmp);
|
||||
memcpy(gsGetMatrix(gsCurrentMatrixType), (float*)tmp, sizeof(mtx44));
|
||||
|
||||
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gsLoadIdentity()
|
||||
{
|
||||
loadIdentity44(gsGetMatrix(gsCurrentMatrixType));
|
||||
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
|
||||
}
|
||||
|
||||
void gsProjectionMatrix(float fovy, float aspect, float near, float far)
|
||||
{
|
||||
initProjectionMatrix(gsGetMatrix(gsCurrentMatrixType), fovy, aspect, near, far);
|
||||
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
|
||||
}
|
||||
|
||||
void gsRotateX(float x)
|
||||
{
|
||||
rotateMatrixX(gsGetMatrix(gsCurrentMatrixType), x, false);
|
||||
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
|
||||
}
|
||||
|
||||
void gsRotateY(float y)
|
||||
{
|
||||
rotateMatrixY(gsGetMatrix(gsCurrentMatrixType), y, false);
|
||||
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
|
||||
}
|
||||
|
||||
void gsRotateZ(float z)
|
||||
{
|
||||
rotateMatrixZ(gsGetMatrix(gsCurrentMatrixType), z, false);
|
||||
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
|
||||
}
|
||||
|
||||
void gsScale(float x, float y, float z)
|
||||
{
|
||||
scaleMatrix(gsGetMatrix(gsCurrentMatrixType), x, y, z);
|
||||
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
|
||||
}
|
||||
|
||||
void gsTranslate(float x, float y, float z)
|
||||
{
|
||||
translateMatrix(gsGetMatrix(gsCurrentMatrixType), x, y, z);
|
||||
gsMatrixStackUpdated[gsCurrentMatrixType]=true;
|
||||
}
|
||||
|
||||
//----------------------
|
||||
// MATRIX RENDER STUFF
|
||||
//----------------------
|
||||
|
||||
static void gsSetUniformMatrix(u32 startreg, float* m)
|
||||
{
|
||||
float param[16];
|
||||
|
||||
param[0x0]=m[3]; //w
|
||||
param[0x1]=m[2]; //z
|
||||
param[0x2]=m[1]; //y
|
||||
param[0x3]=m[0]; //x
|
||||
|
||||
param[0x4]=m[7];
|
||||
param[0x5]=m[6];
|
||||
param[0x6]=m[5];
|
||||
param[0x7]=m[4];
|
||||
|
||||
param[0x8]=m[11];
|
||||
param[0x9]=m[10];
|
||||
param[0xa]=m[9];
|
||||
param[0xb]=m[8];
|
||||
|
||||
param[0xc]=m[15];
|
||||
param[0xd]=m[14];
|
||||
param[0xe]=m[13];
|
||||
param[0xf]=m[12];
|
||||
|
||||
GPU_SetUniform(startreg, (u32*)param, 4);
|
||||
}
|
||||
|
||||
static int gsUpdateTransformation()
|
||||
{
|
||||
GS_MATRIX m;
|
||||
for(m=0; m<GS_MATRIXTYPES; m++)
|
||||
{
|
||||
if(gsMatrixStackUpdated[m])
|
||||
{
|
||||
if(m==GS_PROJECTION && bufferMatrixListLength<BUFFERMATRIXLIST_SIZE)
|
||||
{
|
||||
GPUCMD_GetBuffer(NULL, NULL, &bufferMatrixList[bufferMatrixListLength].offset);
|
||||
memcpy(bufferMatrixList[bufferMatrixListLength].data, gsGetMatrix(m), sizeof(mtx44));
|
||||
bufferMatrixListLength++;
|
||||
}
|
||||
gsSetUniformMatrix(gsMatrixStackRegisters[m], gsGetMatrix(m));
|
||||
gsMatrixStackUpdated[m]=false;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void gsAdjustBufferMatrices(mtx44 transformation)
|
||||
{
|
||||
int i;
|
||||
u32* buffer;
|
||||
u32 offset;
|
||||
GPUCMD_GetBuffer(&buffer, NULL, &offset);
|
||||
for(i=0; i<bufferMatrixListLength; i++)
|
||||
{
|
||||
u32 o=bufferMatrixList[i].offset;
|
||||
if(o+2<offset) //TODO : better check, need to account for param size
|
||||
{
|
||||
mtx44 newMatrix;
|
||||
GPUCMD_SetBufferOffset(o);
|
||||
multMatrix44((float*)bufferMatrixList[i].data, (float*)transformation, (float*)newMatrix);
|
||||
gsSetUniformMatrix(gsMatrixStackRegisters[GS_PROJECTION], (float*)newMatrix);
|
||||
}
|
||||
}
|
||||
GPUCMD_SetBufferOffset(offset);
|
||||
}
|
||||
|
||||
//----------------------
|
||||
// VBO STUFF
|
||||
//----------------------
|
||||
|
||||
int gsVboInit(gsVbo_s* vbo)
|
||||
{
|
||||
if(!vbo)return -1;
|
||||
|
||||
vbo->data=NULL;
|
||||
vbo->currentSize=0;
|
||||
vbo->maxSize=0;
|
||||
vbo->commands=NULL;
|
||||
vbo->commandsSize=0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gsVboCreate(gsVbo_s* vbo, u32 size)
|
||||
{
|
||||
if(!vbo)return -1;
|
||||
|
||||
vbo->data=gsLinearAlloc(size);
|
||||
vbo->numVertices=0;
|
||||
vbo->currentSize=0;
|
||||
vbo->maxSize=size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void* gsVboGetOffset(gsVbo_s* vbo)
|
||||
{
|
||||
if(!vbo)return NULL;
|
||||
|
||||
return (void*)(&((u8*)vbo->data)[vbo->currentSize]);
|
||||
}
|
||||
|
||||
int gsVboAddData(gsVbo_s* vbo, void* data, u32 size, u32 units)
|
||||
{
|
||||
if(!vbo || !data || !size)return -1;
|
||||
if(((s32)vbo->maxSize)-((s32)vbo->currentSize) < size)return -1;
|
||||
|
||||
memcpy(gsVboGetOffset(vbo), data, size);
|
||||
vbo->currentSize+=size;
|
||||
vbo->numVertices+=units;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gsVboFlushData(gsVbo_s* vbo)
|
||||
{
|
||||
if(!vbo)return -1;
|
||||
|
||||
//unnecessary if we use flushAndRun
|
||||
// GSPGPU_FlushDataCache(NULL, vbo->data, vbo->currentSize);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gsVboDestroy(gsVbo_s* vbo)
|
||||
{
|
||||
if(!vbo)return -1;
|
||||
|
||||
if(vbo->commands)free(vbo->commands);
|
||||
if(vbo->data)gsLinearFree(vbo->data);
|
||||
gsVboInit(vbo);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern u32 debugValue[];
|
||||
|
||||
void GPU_DrawArrayDirectly(GPU_Primitive_t primitive, u8* data, u32 n)
|
||||
{
|
||||
//set attribute buffer address
|
||||
GPUCMD_AddSingleParam(0x000F0200, (osConvertVirtToPhys((u32)data))>>3);
|
||||
//set primitive type
|
||||
GPUCMD_AddSingleParam(0x0002025E, primitive);
|
||||
GPUCMD_AddSingleParam(0x0002025F, 0x00000001);
|
||||
//index buffer not used for drawArrays but 0x000F0227 still required
|
||||
GPUCMD_AddSingleParam(0x000F0227, 0x80000000);
|
||||
//pass number of vertices
|
||||
GPUCMD_AddSingleParam(0x000F0228, n);
|
||||
|
||||
GPUCMD_AddSingleParam(0x00010253, 0x00000001);
|
||||
|
||||
GPUCMD_AddSingleParam(0x00010245, 0x00000000);
|
||||
GPUCMD_AddSingleParam(0x000F022E, 0x00000001);
|
||||
GPUCMD_AddSingleParam(0x00010245, 0x00000001);
|
||||
GPUCMD_AddSingleParam(0x000F0231, 0x00000001);
|
||||
|
||||
// GPUCMD_AddSingleParam(0x000F0111, 0x00000001); //breaks stuff
|
||||
}
|
||||
|
||||
//not thread safe
|
||||
int gsVboPrecomputeCommands(gsVbo_s* vbo)
|
||||
{
|
||||
if(!vbo || vbo->commands)return -1;
|
||||
|
||||
static u32 tmpBuffer[128];
|
||||
|
||||
u32* savedAdr; u32 savedSize, savedOffset;
|
||||
GPUCMD_GetBuffer(&savedAdr, &savedSize, &savedOffset);
|
||||
GPUCMD_SetBuffer(tmpBuffer, 128, 0);
|
||||
|
||||
GPU_DrawArrayDirectly(GPU_TRIANGLES, vbo->data, vbo->numVertices);
|
||||
|
||||
GPUCMD_GetBuffer(NULL, NULL, &vbo->commandsSize);
|
||||
vbo->commands=memalign(0x4, vbo->commandsSize*4);
|
||||
if(!vbo->commands)return -1;
|
||||
memcpy(vbo->commands, tmpBuffer, vbo->commandsSize*4);
|
||||
|
||||
GPUCMD_SetBuffer(savedAdr, savedSize, savedOffset);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern u32* gpuCmdBuf;
|
||||
extern u32 gpuCmdBufSize;
|
||||
extern u32 gpuCmdBufOffset;
|
||||
|
||||
void _vboMemcpy50(u32* dst, u32* src);
|
||||
|
||||
void _GPUCMD_AddRawCommands(u32* cmd, u32 size)
|
||||
{
|
||||
if(!cmd || !size)return;
|
||||
|
||||
if(size*4==0x50)_vboMemcpy50(&gpuCmdBuf[gpuCmdBufOffset], cmd);
|
||||
else memcpy(&gpuCmdBuf[gpuCmdBufOffset], cmd, size*4);
|
||||
gpuCmdBufOffset+=size;
|
||||
}
|
||||
|
||||
int gsVboDraw(gsVbo_s* vbo)
|
||||
{
|
||||
if(!vbo || !vbo->data || !vbo->currentSize || !vbo->maxSize)return -1;
|
||||
|
||||
gsUpdateTransformation();
|
||||
|
||||
gsVboPrecomputeCommands(vbo);
|
||||
|
||||
// u64 val=svcGetSystemTick();
|
||||
if(vbo->commands)
|
||||
{
|
||||
_GPUCMD_AddRawCommands(vbo->commands, vbo->commandsSize);
|
||||
}else{
|
||||
GPU_DrawArrayDirectly(GPU_TRIANGLES, vbo->data, vbo->numVertices);
|
||||
}
|
||||
// debugValue[5]+=(u32)(svcGetSystemTick()-val);
|
||||
// debugValue[6]++;
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
#ifndef GS_H
|
||||
#define GS_H
|
||||
|
||||
#include <3ds.h>
|
||||
#include "math.h"
|
||||
|
||||
#define GS_MATRIXSTACK_SIZE (8)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GS_PROJECTION = 0,
|
||||
GS_MODELVIEW = 1,
|
||||
GS_MATRIXTYPES
|
||||
}GS_MATRIX;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8* data;
|
||||
u32 currentSize; // in bytes
|
||||
u32 maxSize; // in bytes
|
||||
u32 numVertices;
|
||||
u32* commands;
|
||||
u32 commandsSize;
|
||||
}gsVbo_s;
|
||||
|
||||
|
||||
void gsInit(DVLB_s* shader);
|
||||
void gsExit(void);
|
||||
|
||||
void gsStartFrame(void);
|
||||
void gsAdjustBufferMatrices(mtx44 transformation);
|
||||
|
||||
void* gsLinearAlloc(size_t size);
|
||||
void gsLinearFree(void* mem);
|
||||
|
||||
float* gsGetMatrix(GS_MATRIX m);
|
||||
int gsLoadMatrix(GS_MATRIX m, float* data);
|
||||
int gsPushMatrix();
|
||||
int gsPopMatrix();
|
||||
int gsMatrixMode(GS_MATRIX m);
|
||||
|
||||
void gsLoadIdentity();
|
||||
void gsProjectionMatrix(float fovy, float aspect, float near, float far);
|
||||
void gsRotateX(float x);
|
||||
void gsRotateY(float y);
|
||||
void gsRotateZ(float z);
|
||||
void gsScale(float x, float y, float z);
|
||||
void gsTranslate(float x, float y, float z);
|
||||
int gsMultMatrix(float* data);
|
||||
|
||||
int gsVboInit(gsVbo_s* vbo);
|
||||
int gsVboCreate(gsVbo_s* vbo, u32 size);
|
||||
int gsVboFlushData(gsVbo_s* vbo);
|
||||
int gsVboDestroy(gsVbo_s* vbo);
|
||||
int gsVboDraw(gsVbo_s* vbo);
|
||||
void* gsVboGetOffset(gsVbo_s* vbo);
|
||||
int gsVboAddData(gsVbo_s* vbo, void* data, u32 size, u32 units);
|
||||
|
||||
#endif
|
@ -1,323 +0,0 @@
|
||||
///////////////////////////////////////
|
||||
// GPU example //
|
||||
///////////////////////////////////////
|
||||
|
||||
//this example is meant to show how to use the GPU to render a 3D object
|
||||
//it also shows how to do stereoscopic 3D
|
||||
//it uses GS which is a WIP GPU abstraction layer that's currently part of 3DScraft
|
||||
//keep in mind GPU reverse engineering is an ongoing effort and our understanding of it is still fairly limited.
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <3ds.h>
|
||||
|
||||
#include "math.h"
|
||||
#include "gs.h"
|
||||
|
||||
#include "test_vsh_shbin.h"
|
||||
#include "texture_bin.h"
|
||||
|
||||
//will be moved into ctrulib at some point
|
||||
#define CONFIG_3D_SLIDERSTATE (*(float*)0x1FF81080)
|
||||
|
||||
#define RGBA8(r,g,b,a) ((((r)&0xFF)<<24) | (((g)&0xFF)<<16) | (((b)&0xFF)<<8) | (((a)&0xFF)<<0))
|
||||
|
||||
//shader structure
|
||||
DVLB_s* shader;
|
||||
//texture data pointer
|
||||
u32* texData;
|
||||
//vbo structure
|
||||
gsVbo_s vbo;
|
||||
|
||||
//GPU framebuffer address
|
||||
u32* gpuOut=(u32*)0x1F119400;
|
||||
//GPU depth buffer address
|
||||
u32* gpuDOut=(u32*)0x1F370800;
|
||||
|
||||
//angle for the vertex lighting (cf test.vsh)
|
||||
float lightAngle;
|
||||
//object position and rotation angle
|
||||
vect3Df_s position, angle;
|
||||
|
||||
//vertex structure
|
||||
typedef struct
|
||||
{
|
||||
vect3Df_s position;
|
||||
float texcoord[2];
|
||||
vect3Df_s normal;
|
||||
}vertex_s;
|
||||
|
||||
//object data (cube)
|
||||
//obviously this doesn't have to be defined manually, but we will here for the purposes of the example
|
||||
//each line is a vertex : {position.x, position.y, position.z}, {texcoord.t, texcoord.s}, {normal.x, normal.y, normal.z}
|
||||
//we're drawing triangles so three lines = one triangle
|
||||
const vertex_s modelVboData[]=
|
||||
{
|
||||
//first face (PZ)
|
||||
//first triangle
|
||||
{(vect3Df_s){-0.5f, -0.5f, +0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
|
||||
{(vect3Df_s){+0.5f, -0.5f, +0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
|
||||
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
|
||||
//second triangle
|
||||
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
|
||||
{(vect3Df_s){-0.5f, +0.5f, +0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
|
||||
{(vect3Df_s){-0.5f, -0.5f, +0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, +1.0f}},
|
||||
//second face (MZ)
|
||||
//first triangle
|
||||
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
|
||||
{(vect3Df_s){-0.5f, +0.5f, -0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
|
||||
{(vect3Df_s){+0.5f, +0.5f, -0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
|
||||
//second triangle
|
||||
{(vect3Df_s){+0.5f, +0.5f, -0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
|
||||
{(vect3Df_s){+0.5f, -0.5f, -0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
|
||||
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, 0.0f, -1.0f}},
|
||||
//third face (PX)
|
||||
//first triangle
|
||||
{(vect3Df_s){+0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
|
||||
{(vect3Df_s){+0.5f, +0.5f, -0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
|
||||
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
|
||||
//second triangle
|
||||
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
|
||||
{(vect3Df_s){+0.5f, -0.5f, +0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
|
||||
{(vect3Df_s){+0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){+1.0f, 0.0f, 0.0f}},
|
||||
//fourth face (MX)
|
||||
//first triangle
|
||||
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
|
||||
{(vect3Df_s){-0.5f, -0.5f, +0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
|
||||
{(vect3Df_s){-0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
|
||||
//second triangle
|
||||
{(vect3Df_s){-0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
|
||||
{(vect3Df_s){-0.5f, +0.5f, -0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
|
||||
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){-1.0f, 0.0f, 0.0f}},
|
||||
//fifth face (PY)
|
||||
//first triangle
|
||||
{(vect3Df_s){-0.5f, +0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
|
||||
{(vect3Df_s){-0.5f, +0.5f, +0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
|
||||
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
|
||||
//second triangle
|
||||
{(vect3Df_s){+0.5f, +0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
|
||||
{(vect3Df_s){+0.5f, +0.5f, -0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
|
||||
{(vect3Df_s){-0.5f, +0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, +1.0f, 0.0f}},
|
||||
//sixth face (MY)
|
||||
//first triangle
|
||||
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
|
||||
{(vect3Df_s){+0.5f, -0.5f, -0.5f}, (float[]){1.0f, 1.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
|
||||
{(vect3Df_s){+0.5f, -0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
|
||||
//second triangle
|
||||
{(vect3Df_s){+0.5f, -0.5f, +0.5f}, (float[]){1.0f, 0.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
|
||||
{(vect3Df_s){-0.5f, -0.5f, +0.5f}, (float[]){0.0f, 0.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
|
||||
{(vect3Df_s){-0.5f, -0.5f, -0.5f}, (float[]){0.0f, 1.0f}, (vect3Df_s){0.0f, -1.0f, 0.0f}},
|
||||
};
|
||||
|
||||
//stolen from staplebutt
|
||||
void GPU_SetDummyTexEnv(u8 num)
|
||||
{
|
||||
GPU_SetTexEnv(num,
|
||||
GPU_TEVSOURCES(GPU_PREVIOUS, 0, 0),
|
||||
GPU_TEVSOURCES(GPU_PREVIOUS, 0, 0),
|
||||
GPU_TEVOPERANDS(0,0,0),
|
||||
GPU_TEVOPERANDS(0,0,0),
|
||||
GPU_REPLACE,
|
||||
GPU_REPLACE,
|
||||
0xFFFFFFFF);
|
||||
}
|
||||
|
||||
// topscreen
|
||||
void renderFrame()
|
||||
{
|
||||
GPU_SetViewport((u32*)osConvertVirtToPhys((u32)gpuDOut),(u32*)osConvertVirtToPhys((u32)gpuOut),0,0,240*2,400);
|
||||
|
||||
GPU_DepthRange(-1.0f, 0.0f);
|
||||
GPU_SetFaceCulling(GPU_CULL_BACK_CCW);
|
||||
GPU_SetStencilTest(false, GPU_ALWAYS, 0x00, 0xFF, 0x00);
|
||||
GPU_SetStencilOp(GPU_KEEP, GPU_KEEP, GPU_KEEP);
|
||||
GPU_SetBlendingColor(0,0,0,0);
|
||||
GPU_SetDepthTestAndWriteMask(true, GPU_GREATER, GPU_WRITE_ALL);
|
||||
|
||||
GPUCMD_AddSingleParam(0x00010062, 0);
|
||||
GPUCMD_AddSingleParam(0x000F0118, 0);
|
||||
|
||||
//setup shader
|
||||
SHDR_UseProgram(shader, 0);
|
||||
|
||||
GPU_SetAlphaBlending(GPU_BLEND_ADD, GPU_BLEND_ADD, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA);
|
||||
GPU_SetAlphaTest(false, GPU_ALWAYS, 0x00);
|
||||
|
||||
GPU_SetTextureEnable(GPU_TEXUNIT0);
|
||||
|
||||
GPU_SetTexEnv(0,
|
||||
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR),
|
||||
GPU_TEVSOURCES(GPU_TEXTURE0, GPU_PRIMARY_COLOR, GPU_PRIMARY_COLOR),
|
||||
GPU_TEVOPERANDS(0,0,0),
|
||||
GPU_TEVOPERANDS(0,0,0),
|
||||
GPU_MODULATE, GPU_MODULATE,
|
||||
0xFFFFFFFF);
|
||||
GPU_SetDummyTexEnv(1);
|
||||
GPU_SetDummyTexEnv(2);
|
||||
GPU_SetDummyTexEnv(3);
|
||||
GPU_SetDummyTexEnv(4);
|
||||
GPU_SetDummyTexEnv(5);
|
||||
|
||||
//texturing stuff
|
||||
GPU_SetTexture(GPU_TEXUNIT0, (u32*)osConvertVirtToPhys((u32)texData),128,128,GPU_TEXTURE_MAG_FILTER(GPU_NEAREST)|GPU_TEXTURE_MIN_FILTER(GPU_NEAREST),GPU_RGBA8);
|
||||
GPU_SetAttributeBuffers(3, (u32*)osConvertVirtToPhys((u32)texData),
|
||||
GPU_ATTRIBFMT(0, 3, GPU_FLOAT)|GPU_ATTRIBFMT(1, 2, GPU_FLOAT)|GPU_ATTRIBFMT(2, 3, GPU_FLOAT),
|
||||
0xFFC, 0x210, 1, (u32[]){0x00000000}, (u64[]){0x210}, (u8[]){3});
|
||||
|
||||
//setup lighting (this is specific to our shader)
|
||||
vect3Df_s lightDir=vnormf(vect3Df(cos(lightAngle), -1.0f, sin(lightAngle)));
|
||||
GPU_SetUniform(SHDR_GetUniformRegister(shader, "lightDirection", 0), (u32*)(float[]){0.0f, -lightDir.z, -lightDir.y, -lightDir.x}, 1);
|
||||
GPU_SetUniform(SHDR_GetUniformRegister(shader, "lightAmbient", 0), (u32*)(float[]){0.7f, 0.4f, 0.4f, 0.4f}, 1);
|
||||
|
||||
//initialize projection matrix to standard perspective stuff
|
||||
gsMatrixMode(GS_PROJECTION);
|
||||
gsProjectionMatrix(80.0f*M_PI/180.0f, 240.0f/400.0f, 0.01f, 100.0f);
|
||||
gsRotateZ(M_PI/2); //because framebuffer is sideways...
|
||||
|
||||
//draw object
|
||||
gsMatrixMode(GS_MODELVIEW);
|
||||
gsPushMatrix();
|
||||
gsTranslate(position.x, position.y, position.z);
|
||||
gsRotateX(angle.x);
|
||||
gsRotateY(angle.y);
|
||||
gsVboDraw(&vbo);
|
||||
gsPopMatrix();
|
||||
GPU_FinishDrawing();
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
gfxInitDefault();
|
||||
|
||||
//initialize GPU
|
||||
GPU_Init(NULL);
|
||||
|
||||
//let GFX know we're ok with doing stereoscopic 3D rendering
|
||||
gfxSet3D(true);
|
||||
|
||||
//load our vertex shader binary
|
||||
shader=SHDR_ParseSHBIN((u32*)test_vsh_shbin, test_vsh_shbin_size);
|
||||
|
||||
//initialize GS
|
||||
gsInit(shader);
|
||||
|
||||
//allocate our GPU command buffers
|
||||
//they *have* to be on the linear heap
|
||||
u32 gpuCmdSize=0x40000;
|
||||
u32* gpuCmd=(u32*)linearAlloc(gpuCmdSize*4);
|
||||
u32* gpuCmdRight=(u32*)linearAlloc(gpuCmdSize*4);
|
||||
|
||||
//actually reset the GPU
|
||||
GPU_Reset(NULL, gpuCmd, gpuCmdSize);
|
||||
|
||||
//create texture
|
||||
texData=(u32*)linearMemAlign(texture_bin_size, 0x80); //textures need to be 0x80-byte aligned
|
||||
memcpy(texData, texture_bin, texture_bin_size);
|
||||
|
||||
//create VBO
|
||||
gsVboInit(&vbo);
|
||||
gsVboCreate(&vbo, sizeof(modelVboData));
|
||||
gsVboAddData(&vbo, (void*)modelVboData, sizeof(modelVboData), sizeof(modelVboData)/sizeof(vertex_s));
|
||||
gsVboFlushData(&vbo);
|
||||
|
||||
//initialize object position and angle
|
||||
position=vect3Df(0.0f, 0.0f, -2.0f);
|
||||
angle=vect3Df(M_PI/4, M_PI/4, 0.0f);
|
||||
|
||||
//background color (blue)
|
||||
u32 backgroundColor=RGBA8(0x68, 0xB0, 0xD8, 0xFF);
|
||||
|
||||
while(aptMainLoop())
|
||||
{
|
||||
//get current 3D slider state
|
||||
float slider=CONFIG_3D_SLIDERSTATE;
|
||||
|
||||
//controls
|
||||
hidScanInput();
|
||||
//START to exit to hbmenu
|
||||
if(keysDown()&KEY_START)break;
|
||||
|
||||
//A/B to change vertex lighting angle
|
||||
if(keysHeld()&KEY_A)lightAngle+=0.1f;
|
||||
if(keysHeld()&KEY_B)lightAngle-=0.1f;
|
||||
|
||||
//D-PAD to rotate object
|
||||
if(keysHeld()&KEY_RIGHT)angle.x+=0.05f;
|
||||
if(keysHeld()&KEY_LEFT)angle.x-=0.05f;
|
||||
if(keysHeld()&KEY_UP)angle.y+=0.05f;
|
||||
if(keysHeld()&KEY_DOWN)angle.y-=0.05f;
|
||||
|
||||
//R/L to bring object closer to or move it further from the camera
|
||||
if(keysHeld()&KEY_R)position.z+=0.1f;
|
||||
if(keysHeld()&KEY_L)position.z-=0.1f;
|
||||
|
||||
//generate our GPU command buffer for this frame
|
||||
gsStartFrame();
|
||||
renderFrame();
|
||||
GPUCMD_Finalize();
|
||||
|
||||
if(slider>0.0f)
|
||||
{
|
||||
//new and exciting 3D !
|
||||
//make a copy of left gpu buffer
|
||||
u32 offset; GPUCMD_GetBuffer(NULL, NULL, &offset);
|
||||
memcpy(gpuCmdRight, gpuCmd, offset*4);
|
||||
|
||||
//setup interaxial
|
||||
float interaxial=slider*0.12f;
|
||||
|
||||
//adjust left gpu buffer fo 3D !
|
||||
{mtx44 m; loadIdentity44((float*)m); translateMatrix((float*)m, -interaxial*0.5f, 0.0f, 0.0f); gsAdjustBufferMatrices(m);}
|
||||
|
||||
//draw left framebuffer
|
||||
GPUCMD_FlushAndRun(NULL);
|
||||
|
||||
//while GPU starts drawing the left buffer, adjust right one for 3D !
|
||||
GPUCMD_SetBuffer(gpuCmdRight, gpuCmdSize, offset);
|
||||
{mtx44 m; loadIdentity44((float*)m); translateMatrix((float*)m, interaxial*0.5f, 0.0f, 0.0f); gsAdjustBufferMatrices(m);}
|
||||
|
||||
//we wait for the left buffer to finish drawing
|
||||
gspWaitForP3D();
|
||||
GX_SetDisplayTransfer(NULL, (u32*)gpuOut, 0x019001E0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019001E0, 0x01001000);
|
||||
gspWaitForPPF();
|
||||
|
||||
//we draw the right buffer, wait for it to finish and then switch back to left one
|
||||
//clear the screen
|
||||
GX_SetMemoryFill(NULL, (u32*)gpuOut, backgroundColor, (u32*)&gpuOut[0x2EE00], 0x201, (u32*)gpuDOut, 0x00000000, (u32*)&gpuDOut[0x2EE00], 0x201);
|
||||
gspWaitForPSC0();
|
||||
|
||||
//draw the right framebuffer
|
||||
GPUCMD_FlushAndRun(NULL);
|
||||
gspWaitForP3D();
|
||||
|
||||
//transfer from GPU output buffer to actual framebuffer
|
||||
GX_SetDisplayTransfer(NULL, (u32*)gpuOut, 0x019001E0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_RIGHT, NULL, NULL), 0x019001E0, 0x01001000);
|
||||
gspWaitForPPF();
|
||||
GPUCMD_SetBuffer(gpuCmd, gpuCmdSize, 0);
|
||||
}else{
|
||||
//boring old 2D !
|
||||
|
||||
//draw the frame
|
||||
GPUCMD_FlushAndRun(NULL);
|
||||
gspWaitForP3D();
|
||||
|
||||
//clear the screen
|
||||
GX_SetDisplayTransfer(NULL, (u32*)gpuOut, 0x019001E0, (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL), 0x019001E0, 0x01001000);
|
||||
gspWaitForPPF();
|
||||
}
|
||||
|
||||
//clear the screen
|
||||
GX_SetMemoryFill(NULL, (u32*)gpuOut, backgroundColor, (u32*)&gpuOut[0x2EE00], 0x201, (u32*)gpuDOut, 0x00000000, (u32*)&gpuDOut[0x2EE00], 0x201);
|
||||
gspWaitForPSC0();
|
||||
gfxSwapBuffersGpu();
|
||||
|
||||
gspWaitForEvent(GSPEVENT_VBlank0, true);
|
||||
}
|
||||
|
||||
gsExit();
|
||||
gfxExit();
|
||||
return 0;
|
||||
}
|
@ -1,148 +0,0 @@
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "math.h"
|
||||
|
||||
void loadIdentity44(float* m)
|
||||
{
|
||||
if(!m)return;
|
||||
|
||||
memset(m, 0x00, 16*4);
|
||||
m[0]=m[5]=m[10]=m[15]=1.0f;
|
||||
}
|
||||
|
||||
void multMatrix44(float* m1, float* m2, float* m) //4x4
|
||||
{
|
||||
int i, j;
|
||||
for(i=0;i<4;i++)for(j=0;j<4;j++)m[i+j*4]=(m1[0+j*4]*m2[i+0*4])+(m1[1+j*4]*m2[i+1*4])+(m1[2+j*4]*m2[i+2*4])+(m1[3+j*4]*m2[i+3*4]);
|
||||
|
||||
}
|
||||
|
||||
void translateMatrix(float* tm, float x, float y, float z)
|
||||
{
|
||||
float rm[16], m[16];
|
||||
|
||||
loadIdentity44(rm);
|
||||
rm[3]=x;
|
||||
rm[7]=y;
|
||||
rm[11]=z;
|
||||
|
||||
multMatrix44(tm,rm,m);
|
||||
memcpy(tm,m,16*sizeof(float));
|
||||
}
|
||||
|
||||
// 00 01 02 03
|
||||
// 04 05 06 07
|
||||
// 08 09 10 11
|
||||
// 12 13 14 15
|
||||
|
||||
void rotateMatrixX(float* tm, float x, bool r)
|
||||
{
|
||||
float rm[16], m[16];
|
||||
memset(rm, 0x00, 16*4);
|
||||
rm[0]=1.0f;
|
||||
rm[5]=cos(x);
|
||||
rm[6]=sin(x);
|
||||
rm[9]=-sin(x);
|
||||
rm[10]=cos(x);
|
||||
rm[15]=1.0f;
|
||||
if(!r)multMatrix44(tm,rm,m);
|
||||
else multMatrix44(rm,tm,m);
|
||||
memcpy(tm,m,16*sizeof(float));
|
||||
}
|
||||
|
||||
void rotateMatrixY(float* tm, float x, bool r)
|
||||
{
|
||||
float rm[16], m[16];
|
||||
memset(rm, 0x00, 16*4);
|
||||
rm[0]=cos(x);
|
||||
rm[2]=sin(x);
|
||||
rm[5]=1.0f;
|
||||
rm[8]=-sin(x);
|
||||
rm[10]=cos(x);
|
||||
rm[15]=1.0f;
|
||||
if(!r)multMatrix44(tm,rm,m);
|
||||
else multMatrix44(rm,tm,m);
|
||||
memcpy(tm,m,16*sizeof(float));
|
||||
}
|
||||
|
||||
void rotateMatrixZ(float* tm, float x, bool r)
|
||||
{
|
||||
float rm[16], m[16];
|
||||
memset(rm, 0x00, 16*4);
|
||||
rm[0]=cos(x);
|
||||
rm[1]=sin(x);
|
||||
rm[4]=-sin(x);
|
||||
rm[5]=cos(x);
|
||||
rm[10]=1.0f;
|
||||
rm[15]=1.0f;
|
||||
if(!r)multMatrix44(tm,rm,m);
|
||||
else multMatrix44(rm,tm,m);
|
||||
memcpy(tm,m,16*sizeof(float));
|
||||
}
|
||||
|
||||
void scaleMatrix(float* tm, float x, float y, float z)
|
||||
{
|
||||
tm[0]*=x; tm[4]*=x; tm[8]*=x; tm[12]*=x;
|
||||
tm[1]*=y; tm[5]*=y; tm[9]*=y; tm[13]*=y;
|
||||
tm[2]*=z; tm[6]*=z; tm[10]*=z; tm[14]*=z;
|
||||
}
|
||||
|
||||
void initProjectionMatrix(float* m, float fovy, float aspect, float near, float far)
|
||||
{
|
||||
float top = near*tan(fovy/2);
|
||||
float right = (top*aspect);
|
||||
|
||||
float mp[4*4];
|
||||
|
||||
mp[0x0] = near/right;
|
||||
mp[0x1] = 0.0f;
|
||||
mp[0x2] = 0.0f;
|
||||
mp[0x3] = 0.0f;
|
||||
|
||||
mp[0x4] = 0.0f;
|
||||
mp[0x5] = near/top;
|
||||
mp[0x6] = 0.0f;
|
||||
mp[0x7] = 0.0f;
|
||||
|
||||
mp[0x8] = 0.0f;
|
||||
mp[0x9] = 0.0f;
|
||||
mp[0xA] = -(far+near)/(far-near);
|
||||
mp[0xB] = -2.0f*(far*near)/(far-near);
|
||||
|
||||
mp[0xC] = 0.0f;
|
||||
mp[0xD] = 0.0f;
|
||||
mp[0xE] = -1.0f;
|
||||
mp[0xF] = 0.0f;
|
||||
|
||||
float mp2[4*4];
|
||||
loadIdentity44(mp2);
|
||||
mp2[0xA]=0.5;
|
||||
mp2[0xB]=-0.5;
|
||||
|
||||
multMatrix44(mp2, mp, m);
|
||||
}
|
||||
|
||||
vect3Df_s getMatrixColumn(float* m, u8 i)
|
||||
{
|
||||
if(!m || i>=4)return vect3Df(0,0,0);
|
||||
return vect3Df(m[0+i*4],m[1+i*4],m[2+i*4]);
|
||||
}
|
||||
|
||||
vect3Df_s getMatrixRow(float* m, u8 i)
|
||||
{
|
||||
if(!m || i>=4)return vect3Df(0,0,0);
|
||||
return vect3Df(m[i+0*4],m[i+1*4],m[i+2*4]);
|
||||
}
|
||||
|
||||
vect4Df_s getMatrixColumn4(float* m, u8 i)
|
||||
{
|
||||
if(!m || i>=4)return vect4Df(0,0,0,0);
|
||||
return vect4Df(m[0+i*4],m[1+i*4],m[2+i*4],m[3+i*4]);
|
||||
}
|
||||
|
||||
vect4Df_s getMatrixRow4(float* m, u8 i)
|
||||
{
|
||||
if(!m || i>=4)return vect4Df(0,0,0,0);
|
||||
return vect4Df(m[i+0*4],m[i+1*4],m[i+2*4],m[i+3*4]);
|
||||
}
|
@ -1,144 +0,0 @@
|
||||
#ifndef MATH_H
|
||||
#define MATH_H
|
||||
|
||||
#include <3ds/types.h>
|
||||
#include <math.h>
|
||||
|
||||
typedef float mtx44[4][4];
|
||||
typedef float mtx33[3][3];
|
||||
|
||||
typedef struct
|
||||
{
|
||||
s32 x, y, z;
|
||||
}vect3Di_s;
|
||||
|
||||
static inline vect3Di_s vect3Di(s32 x, s32 y, s32 z)
|
||||
{
|
||||
return (vect3Di_s){x,y,z};
|
||||
}
|
||||
|
||||
static inline vect3Di_s vaddi(vect3Di_s u, vect3Di_s v)
|
||||
{
|
||||
return (vect3Di_s){u.x+v.x,u.y+v.y,u.z+v.z};
|
||||
}
|
||||
|
||||
static inline vect3Di_s vsubi(vect3Di_s u, vect3Di_s v)
|
||||
{
|
||||
return (vect3Di_s){u.x-v.x,u.y-v.y,u.z-v.z};
|
||||
}
|
||||
|
||||
static inline vect3Di_s vmuli(vect3Di_s v, s32 f)
|
||||
{
|
||||
return (vect3Di_s){v.x*f,v.y*f,v.z*f};
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x, y, z;
|
||||
}vect3Df_s;
|
||||
|
||||
static inline vect3Df_s vect3Df(float x, float y, float z)
|
||||
{
|
||||
return (vect3Df_s){x,y,z};
|
||||
}
|
||||
|
||||
static inline vect3Df_s vaddf(vect3Df_s u, vect3Df_s v)
|
||||
{
|
||||
return (vect3Df_s){u.x+v.x,u.y+v.y,u.z+v.z};
|
||||
}
|
||||
|
||||
static inline vect3Df_s vsubf(vect3Df_s u, vect3Df_s v)
|
||||
{
|
||||
return (vect3Df_s){u.x-v.x,u.y-v.y,u.z-v.z};
|
||||
}
|
||||
|
||||
static inline vect3Df_s vmulf(vect3Df_s v, float f)
|
||||
{
|
||||
return (vect3Df_s){v.x*f,v.y*f,v.z*f};
|
||||
}
|
||||
|
||||
static inline vect3Df_s vscalef(vect3Df_s v1, vect3Df_s v2)
|
||||
{
|
||||
return (vect3Df_s){v1.x*v2.x,v1.y*v2.y,v1.z*v2.z};
|
||||
}
|
||||
|
||||
static inline float vmagf(vect3Df_s v)
|
||||
{
|
||||
return sqrtf(v.x*v.x+v.y*v.y+v.z*v.z);
|
||||
}
|
||||
|
||||
static inline float vdistf(vect3Df_s v1, vect3Df_s v2)
|
||||
{
|
||||
return sqrtf((v1.x-v2.x)*(v1.x-v2.x)+(v1.y-v2.y)*(v1.y-v2.y)+(v1.z-v2.z)*(v1.z-v2.z));
|
||||
}
|
||||
|
||||
static inline vect3Df_s vnormf(vect3Df_s v)
|
||||
{
|
||||
const float l=sqrtf(v.x*v.x+v.y*v.y+v.z*v.z);
|
||||
return (vect3Df_s){v.x/l,v.y/l,v.z/l};
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
float x, y, z, w;
|
||||
}vect4Df_s;
|
||||
|
||||
static inline vect4Df_s vect4Df(float x, float y, float z, float w)
|
||||
{
|
||||
return (vect4Df_s){x,y,z,w};
|
||||
}
|
||||
|
||||
static inline vect4Df_s vaddf4(vect4Df_s u, vect4Df_s v)
|
||||
{
|
||||
return (vect4Df_s){u.x+v.x,u.y+v.y,u.z+v.z,u.w+v.w};
|
||||
}
|
||||
|
||||
static inline vect4Df_s vsubf4(vect4Df_s u, vect4Df_s v)
|
||||
{
|
||||
return (vect4Df_s){u.x-v.x,u.y-v.y,u.z-v.z,u.w-v.w};
|
||||
}
|
||||
|
||||
static inline vect4Df_s vmulf4(vect4Df_s v, float f)
|
||||
{
|
||||
return (vect4Df_s){v.x*f,v.y*f,v.z*f,v.w*f};
|
||||
}
|
||||
|
||||
static inline float vdotf4(vect4Df_s v1, vect4Df_s v2)
|
||||
{
|
||||
return v1.x*v2.x+v1.y*v2.y+v1.z*v2.z+v1.w*v2.w;
|
||||
}
|
||||
|
||||
static inline vect4Df_s vnormf4(vect4Df_s v)
|
||||
{
|
||||
const float l=sqrtf(v.x*v.x+v.y*v.y+v.z*v.z+v.w*v.w);
|
||||
return (vect4Df_s){v.x/l,v.y/l,v.z/l,v.w/l};
|
||||
}
|
||||
|
||||
//interstuff
|
||||
static inline vect3Di_s vf2i(vect3Df_s v)
|
||||
{
|
||||
return (vect3Di_s){floorf(v.x),floorf(v.y),floorf(v.z)};
|
||||
}
|
||||
|
||||
static inline vect3Df_s vi2f(vect3Di_s v)
|
||||
{
|
||||
return (vect3Df_s){(float)v.x,(float)v.y,(float)v.z};
|
||||
}
|
||||
|
||||
void loadIdentity44(float* m);
|
||||
void multMatrix44(float* m1, float* m2, float* m);
|
||||
|
||||
void translateMatrix(float* tm, float x, float y, float z);
|
||||
void rotateMatrixX(float* tm, float x, bool r);
|
||||
void rotateMatrixY(float* tm, float x, bool r);
|
||||
void rotateMatrixZ(float* tm, float x, bool r);
|
||||
void scaleMatrix(float* tm, float x, float y, float z);
|
||||
|
||||
void initProjectionMatrix(float* m, float fovy, float aspect, float near, float far);
|
||||
|
||||
vect3Df_s getMatrixColumn(float* m, u8 i);
|
||||
vect3Df_s getMatrixRow(float* m, u8 i);
|
||||
vect4Df_s getMatrixColumn4(float* m, u8 i);
|
||||
vect4Df_s getMatrixRow4(float* m, u8 i);
|
||||
|
||||
#endif
|
@ -1,7 +0,0 @@
|
||||
SUBDIRS:= `ls | egrep -v '^(CVS)$$'`
|
||||
all:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
||||
clean:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
||||
install:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done;
|
@ -1,7 +0,0 @@
|
||||
SUBDIRS:= `ls | egrep -v '^(CVS)$$'`
|
||||
all:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
||||
clean:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
||||
install:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done;
|
@ -1,170 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
.PHONY: all
|
||||
all : $(OUTPUT).3dsx $(OUTPUT).smdh
|
||||
endif
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
# WARNING: This is not the right way to do this! TODO: Do it right!
|
||||
#---------------------------------------------------------------------------------
|
||||
%.vsh.o : %.vsh
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@rm ../$(notdir $<).shbin
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
Hello World example made by Aurelio Mannara for ctrulib
|
||||
This code was modified for the last time on: 12/12/2014 21:00 UTC+1
|
||||
|
||||
This wouldn't be possible without the amazing work done by:
|
||||
-Smealum
|
||||
-fincs
|
||||
-WinterMute
|
||||
-yellows8
|
||||
-plutoo
|
||||
-mtheall
|
||||
-Many others who worked on 3DS and I'm surely forgetting about
|
||||
*/
|
||||
|
||||
#include <3ds.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
gfxInitDefault();
|
||||
|
||||
//Initialize console on top screen. Using NULL as the second argument tells the console library to use the internal console structure as current one
|
||||
consoleInit(GFX_TOP, NULL);
|
||||
|
||||
//Move the cursor to row 15 and column 19 and then prints "Hello World!"
|
||||
//To move the cursor you have tu print "\x1b[r;cH", where r and c are respectively
|
||||
//the row and column where you want your cursor to move
|
||||
//The top screen has 30 rows and 50 columns
|
||||
//The bottom screen has 30 rows and 40 columns
|
||||
printf("\x1b[15;19HHello World!");
|
||||
|
||||
printf("\x1b[29;15HPress Start to exit.");
|
||||
|
||||
// Main loop
|
||||
while (aptMainLoop())
|
||||
{
|
||||
//Scan all the inputs. This should be done once for each frame
|
||||
hidScanInput();
|
||||
|
||||
//hidKeysDown returns information about which buttons have been just pressed (and they weren't in the previous frame)
|
||||
u32 kDown = hidKeysDown();
|
||||
|
||||
if (kDown & KEY_START) break; // break in order to return to hbmenu
|
||||
|
||||
// Flush and swap framebuffers
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
|
||||
//Wait for VBlank
|
||||
gspWaitForVBlank();
|
||||
}
|
||||
|
||||
gfxExit();
|
||||
return 0;
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
.PHONY: all
|
||||
all : $(OUTPUT).3dsx $(OUTPUT).smdh
|
||||
endif
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
# WARNING: This is not the right way to do this! TODO: Do it right!
|
||||
#---------------------------------------------------------------------------------
|
||||
%.vsh.o : %.vsh
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@rm ../$(notdir $<).shbin
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1,4 +0,0 @@
|
||||
# http
|
||||
|
||||
This is an example for using HTTPC. This downloads a raw image for displaying on the top-screen. The URL used here is a LAN-only one, hence this URL must be changed before building+running this example.
|
||||
|
@ -1,113 +0,0 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
Result http_download(httpcContext *context)//This error handling needs updated with proper text printing once ctrulib itself supports that.
|
||||
{
|
||||
Result ret=0;
|
||||
u8* framebuf_top;
|
||||
u32 statuscode=0;
|
||||
u32 size=0, contentsize=0;
|
||||
u8 *buf;
|
||||
|
||||
ret = httpcBeginRequest(context);
|
||||
if(ret!=0)return ret;
|
||||
|
||||
ret = httpcGetResponseStatusCode(context, &statuscode, 0);
|
||||
if(ret!=0)return ret;
|
||||
|
||||
if(statuscode!=200)return -2;
|
||||
|
||||
ret=httpcGetDownloadSizeState(context, NULL, &contentsize);
|
||||
if(ret!=0)return ret;
|
||||
|
||||
printf("size: %"PRId32"\n",contentsize);
|
||||
gfxFlushBuffers();
|
||||
|
||||
buf = (u8*)malloc(contentsize);
|
||||
if(buf==NULL)return -1;
|
||||
memset(buf, 0, contentsize);
|
||||
|
||||
|
||||
ret = httpcDownloadData(context, buf, contentsize, NULL);
|
||||
if(ret!=0)
|
||||
{
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
size = contentsize;
|
||||
if(size>(240*400*3*2))size = 240*400*3*2;
|
||||
|
||||
framebuf_top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
memcpy(framebuf_top, buf, size);
|
||||
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
|
||||
framebuf_top = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
memcpy(framebuf_top, buf, size);
|
||||
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
gspWaitForVBlank();
|
||||
|
||||
free(buf);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
Result ret=0;
|
||||
httpcContext context;
|
||||
|
||||
gfxInitDefault();
|
||||
httpcInit();
|
||||
|
||||
consoleInit(GFX_BOTTOM,NULL);
|
||||
|
||||
//Change this to your own URL.
|
||||
char *url = "http://devkitpro.org/misc/httpexample_rawimg.rgb";
|
||||
|
||||
printf("Downloading %s\n",url);
|
||||
gfxFlushBuffers();
|
||||
|
||||
ret = httpcOpenContext(&context, url , 0);
|
||||
printf("return from httpcOpenContext: %"PRId32"\n",ret);
|
||||
gfxFlushBuffers();
|
||||
|
||||
if(ret==0)
|
||||
{
|
||||
ret=http_download(&context);
|
||||
printf("return from http_download: %"PRId32"\n",ret);
|
||||
gfxFlushBuffers();
|
||||
httpcCloseContext(&context);
|
||||
}
|
||||
|
||||
// Main loop
|
||||
while (aptMainLoop())
|
||||
{
|
||||
gspWaitForVBlank();
|
||||
hidScanInput();
|
||||
|
||||
// Your code goes here
|
||||
|
||||
u32 kDown = hidKeysDown();
|
||||
if (kDown & KEY_START)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
// Flush and swap framebuffers
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
}
|
||||
|
||||
// Exit services
|
||||
httpcExit();
|
||||
gfxExit();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,170 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
.PHONY: all
|
||||
all : $(OUTPUT).3dsx $(OUTPUT).smdh
|
||||
endif
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
# WARNING: This is not the right way to do this! TODO: Do it right!
|
||||
#---------------------------------------------------------------------------------
|
||||
%.vsh.o : %.vsh
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@rm ../$(notdir $<).shbin
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1,7 +0,0 @@
|
||||
libapplet_launch
|
||||
=======
|
||||
|
||||
Example for launching library applets. This launches the extrapad library applet(Circle Pad Pro calibration applet) when the B button is pressed.
|
||||
|
||||
This is not usable from the homebrew launcher.
|
||||
|
@ -1,43 +0,0 @@
|
||||
#include <3ds.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
u32 val, i;
|
||||
|
||||
gfxInitDefault();
|
||||
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
||||
|
||||
val = 0x22447899;
|
||||
|
||||
// Main loop
|
||||
while (aptMainLoop())
|
||||
{
|
||||
gspWaitForVBlank();
|
||||
hidScanInput();
|
||||
|
||||
// Your code goes here
|
||||
|
||||
u32 kDown = hidKeysDown();
|
||||
if (kDown & KEY_START)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if (kDown & KEY_B)APT_LaunchLibraryApplet(0x408, 0, NULL, 0);//Launch the extrapad library applet when button B is pressed.
|
||||
|
||||
// Example rendering code that displays a white pixel
|
||||
// Please note that the 3DS screens are sideways (thus 240x400 and 240x320)
|
||||
u32* fb = (u32*)gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
|
||||
for(i=0; i<(0x46500>>2); i++)fb[i] = val;
|
||||
|
||||
val+= 0x44;
|
||||
|
||||
// Flush and swap framebuffers
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
}
|
||||
|
||||
// Exit services
|
||||
gfxExit();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,170 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
.PHONY: all
|
||||
all : $(OUTPUT).3dsx $(OUTPUT).smdh
|
||||
endif
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
# WARNING: This is not the right way to do this! TODO: Do it right!
|
||||
#---------------------------------------------------------------------------------
|
||||
%.vsh.o : %.vsh
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@rm ../$(notdir $<).shbin
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1 +0,0 @@
|
||||
This example is for using New3DS MVD, for hardware color-format conversion + video processing(the latter is not supported by ctrulib/this example yet).
|
@ -1,6 +0,0 @@
|
||||
#ifndef COSTABLE_H
|
||||
#define COSTABLE_H
|
||||
|
||||
s32 costable[] = {4096, 4095, 4094, 4093, 4091, 4088, 4084, 4080, 4076, 4071, 4065, 4058, 4051, 4044, 4035, 4026, 4017, 4007, 3996, 3985, 3973, 3960, 3947, 3934, 3919, 3904, 3889, 3873, 3856, 3839, 3821, 3803, 3784, 3765, 3744, 3724, 3703, 3681, 3659, 3636, 3612, 3588, 3564, 3539, 3513, 3487, 3461, 3434, 3406, 3378, 3349, 3320, 3290, 3260, 3229, 3198, 3167, 3135, 3102, 3069, 3035, 3002, 2967, 2932, 2897, 2861, 2825, 2788, 2751, 2714, 2676, 2638, 2599, 2560, 2521, 2481, 2441, 2401, 2360, 2318, 2277, 2235, 2193, 2150, 2107, 2064, 2020, 1976, 1932, 1888, 1843, 1798, 1753, 1707, 1662, 1616, 1569, 1523, 1476, 1429, 1382, 1334, 1287, 1239, 1191, 1143, 1095, 1046, 997, 949, 900, 851, 801, 752, 703, 653, 603, 554, 504, 454, 404, 354, 304, 254, 204, 153, 103, 53, 3, -46, -97, -147, -197, -247, -297, -347, -398, -448, -497, -547, -597, -647, -696, -746, -795, -844, -893, -942, -991, -1040, -1088, -1137, -1185, -1233, -1281, -1328, -1376, -1423, -1470, -1517, -1563, -1610, -1656, -1701, -1747, -1792, -1837, -1882, -1927, -1971, -2015, -2058, -2102, -2144, -2187, -2229, -2271, -2313, -2354, -2395, -2436, -2476, -2516, -2555, -2594, -2633, -2671, -2709, -2747, -2784, -2820, -2857, -2892, -2928, -2963, -2997, -3031, -3065, -3098, -3130, -3163, -3194, -3225, -3256, -3286, -3316, -3345, -3374, -3402, -3430, -3457, -3484, -3510, -3536, -3561, -3585, -3609, -3633, -3656, -3678, -3700, -3721, -3742, -3762, -3782, -3801, -3819, -3837, -3854, -3871, -3887, -3902, -3917, -3932, -3946, -3959, -3971, -3983, -3995, -4005, -4016, -4025, -4034, -4042, -4050, -4057, -4064, -4070, -4075, -4080, -4084, -4087, -4090, -4092, -4094, -4095, -4095, -4095, -4094, -4093, -4091, -4088, -4085, -4081, -4076, -4071, -4066, -4059, -4052, -4045, -4036, -4028, -4018, -4008, -3997, -3986, -3974, -3962, -3949, -3935, -3921, -3906, -3891, -3875, -3858, -3841, -3824, -3805, -3787, -3767, -3747, -3727, -3705, -3684, -3662, -3639, -3615, -3592, -3567, -3542, -3517, -3491, -3464, -3437, -3409, -3381, -3353, -3324, -3294, -3264, -3233, -3202, -3171, -3139, -3106, -3073, -3040, -3006, -2972, -2937, -2902, -2866, -2830, -2793, -2756, -2719, -2681, -2643, -2604, -2565, -2526, -2486, -2446, -2406, -2365, -2324, -2282, -2240, -2198, -2156, -2113, -2069, -2026, -1982, -1938, -1894, -1849, -1804, -1759, -1713, -1668, -1622, -1575, -1529, -1482, -1435, -1388, -1341, -1293, -1245, -1197, -1149, -1101, -1052, -1004, -955, -906, -857, -808, -758, -709, -660, -610, -560, -510, -460, -411, -360, -310, -260, -210, -160, -110, -60, -9, 40, 90, 140, 191, 241, 291, 341, 391, 441, 491, 541, 591, 640, 690, 739, 789, 838, 887, 936, 985, 1033, 1082, 1130, 1179, 1227, 1274, 1322, 1370, 1417, 1464, 1511, 1557, 1604, 1650, 1695, 1741, 1786, 1831, 1876, 1921, 1965, 2009, 2053, 2096, 2139, 2182, 2224, 2266, 2308, 2349, 2390, 2431, 2471, 2511, 2550, 2589, 2628, 2666, 2704, 2742, 2779, 2816, 2852, 2888, 2923, 2958, 2993, 3027, 3060, 3093, 3126, 3158, 3190, 3221, 3252, 3282, 3312, 3342, 3370, 3399, 3426, 3454, 3480, 3507, 3532, 3557, 3582, 3606, 3630, 3653, 3675, 3697, 3718, 3739, 3759, 3779, 3798, 3817, 3835, 3852, 3869, 3885, 3900, 3915, 3930, 3944, 3957, 3970, 3982, 3993, 4004, 4014, 4024, 4033, 4041, 4049, 4056, 4063, 4069, 4074, 4079, 4083, 4087, 4090, 4092, 4094, 4095};
|
||||
|
||||
#endif
|
@ -1,143 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
#include "costable.h"
|
||||
|
||||
u8* inaddr;
|
||||
u8* outaddr;
|
||||
|
||||
char logstring[256];
|
||||
|
||||
s32 pcCos(u16 v)
|
||||
{
|
||||
return costable[v&0x1FF];
|
||||
}
|
||||
|
||||
void printstring(char *str)//Placeholder until ctrulib itself has proper text drawing.
|
||||
{
|
||||
strncat(logstring, str, sizeof(logstring)-1);
|
||||
}
|
||||
|
||||
void draw_startup()
|
||||
{
|
||||
Result ret;
|
||||
|
||||
FILE *f = NULL;
|
||||
|
||||
u8* bufAdr = gfxGetFramebuffer(GFX_BOTTOM, GFX_LEFT, NULL, NULL);
|
||||
u8* gfxtopadr = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
|
||||
mvdstdConfig config;
|
||||
|
||||
char str[256];
|
||||
|
||||
int i, j;
|
||||
u32 cnt=0;
|
||||
for(i=0;i<320;i++)
|
||||
{
|
||||
for(j=0;j<240;j++)
|
||||
{
|
||||
u32 v=(j+i*240)*3;
|
||||
bufAdr[v]=(pcCos(i+cnt)+4096)/32;
|
||||
bufAdr[v+1]=(pcCos(j-256+cnt)+4096)/64;
|
||||
bufAdr[v+2]=(pcCos(i+128-cnt)+4096)/32;
|
||||
}
|
||||
}
|
||||
|
||||
f = fopen("sdmc:/mvd_indata.bin", "r");
|
||||
if(f)
|
||||
{
|
||||
fread(inaddr, 1, 0x46500, f);
|
||||
fclose(f);
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(inaddr, bufAdr, 320*240*3);
|
||||
}
|
||||
|
||||
memset(gfxtopadr, 0, 0x46500);
|
||||
GSPGPU_FlushDataCache(NULL, inaddr, 0x46500);
|
||||
|
||||
printstring("mvd example\n");
|
||||
|
||||
ret = mvdstdInit(MVDMODE_COLORFORMATCONV, MVDTYPEIN_YUYV422, MVDTYPEOUT_RGB565, 0);
|
||||
memset(str, 0, 256);
|
||||
snprintf(str, sizeof(str)-1, "mvdstdInit(): 0x%08x\n", (unsigned int)ret);
|
||||
printstring(str);
|
||||
|
||||
if(ret>=0)
|
||||
{
|
||||
mvdstdGenerateDefaultConfig(&config, 320, 240, 320, 240, (u32*)inaddr, (u32*)outaddr, (u32*)&outaddr[0x12c00]);
|
||||
|
||||
ret = mvdstdProcessFrame(&config, NULL, 0, 0);
|
||||
memset(str, 0, 256);
|
||||
snprintf(str, sizeof(str)-1, "mvdstdProcessFrame(): 0x%08x\n", (unsigned int)ret);
|
||||
printstring(str);
|
||||
}
|
||||
|
||||
svcSleepThread(1000000000);//Not sure how to determine when frame processing finishes.
|
||||
|
||||
GSPGPU_InvalidateDataCache(NULL, outaddr, 0x100000);
|
||||
|
||||
f = fopen("sdmc:/mvd_outdata.bin", "w");
|
||||
if(f)
|
||||
{
|
||||
fwrite(outaddr, 1, 0x100000, f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
f = fopen("sdmc:/mvd_log", "w");
|
||||
if(f)
|
||||
{
|
||||
fwrite(logstring, 1, strlen(logstring), f);
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
memcpy(gfxtopadr, outaddr, 0x46500);
|
||||
|
||||
mvdstdShutdown();
|
||||
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
gspWaitForVBlank();
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
gfxInitDefault();
|
||||
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
||||
|
||||
memset(logstring, 0, 256);
|
||||
|
||||
inaddr = linearAlloc(0x100000);
|
||||
outaddr = linearAlloc(0x100000);
|
||||
|
||||
if(inaddr && outaddr)
|
||||
{
|
||||
memset(inaddr, 0, 0x100000);
|
||||
memset(outaddr, 0, 0x100000);
|
||||
draw_startup();
|
||||
}
|
||||
|
||||
// Main loop
|
||||
while (aptMainLoop())
|
||||
{
|
||||
gspWaitForVBlank();
|
||||
hidScanInput();
|
||||
|
||||
// Your code goes here
|
||||
|
||||
u32 kDown = hidKeysDown();
|
||||
if (kDown & KEY_START)
|
||||
break; // break in order to return to hbmenu
|
||||
}
|
||||
|
||||
if(inaddr)linearFree(inaddr);
|
||||
if(outaddr)linearFree(outaddr);
|
||||
|
||||
gfxExit();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,175 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
|
||||
else
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
endif
|
||||
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
# WARNING: This is not the right way to do this! TODO: Do it right!
|
||||
#---------------------------------------------------------------------------------
|
||||
%.vsh.o : %.vsh
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@rm ../$(notdir $<).shbin
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1,6 +0,0 @@
|
||||
# qtm
|
||||
|
||||
This is an example for using New3DS QTM for head-tracking.
|
||||
|
||||
This is currently not usable from the homebrew launcher.
|
||||
|
@ -1,85 +0,0 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <3ds.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
u32 pos;
|
||||
u32 x, y;
|
||||
Result ret;
|
||||
bool qtm_usable;
|
||||
qtmHeadtrackingInfo qtminfo;
|
||||
u32 colors[4] = {0x0000FF, 0x00FF00, 0xFF0000, 0xFFFFFF};
|
||||
|
||||
gfxInitDefault();
|
||||
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
||||
|
||||
qtmInit();
|
||||
|
||||
consoleInit(GFX_BOTTOM, NULL);
|
||||
|
||||
printf("qtm example\n");
|
||||
|
||||
qtm_usable = qtmCheckInitialized();
|
||||
if(!qtm_usable)printf("QTM is not usable, therefore this example won't do anything with QTM.\n");
|
||||
|
||||
// Main loop
|
||||
while (aptMainLoop())
|
||||
{
|
||||
gspWaitForVBlank();
|
||||
hidScanInput();
|
||||
|
||||
u32 kDown = hidKeysDown();
|
||||
if (kDown & KEY_START)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
if(qtm_usable)
|
||||
{
|
||||
u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
memset(fb, 0, 400*240*3);
|
||||
|
||||
ret = qtmGetHeadtrackingInfo(0, &qtminfo);
|
||||
if(ret==0)
|
||||
{
|
||||
consoleClear();
|
||||
|
||||
for(pos=0; pos<5; pos++)
|
||||
{
|
||||
printf("flags[%x]=0x%x", (unsigned int)pos, qtminfo.flags[pos]);
|
||||
if(pos<4)printf(", ");
|
||||
}
|
||||
|
||||
printf("\nfloatdata_x08: %f\n", qtminfo.floatdata_x08);
|
||||
|
||||
printf("coords0: ");
|
||||
for(pos=0; pos<4; pos++)
|
||||
{
|
||||
printf("[%x].x=%f, y=%f", (unsigned int)pos, qtminfo.coords0[pos].x, qtminfo.coords0[pos].y);
|
||||
if(pos<3)printf(", ");
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
if(qtmCheckHeadFullyDetected(&qtminfo))
|
||||
{
|
||||
for(pos=0; pos<4; pos++)
|
||||
{
|
||||
ret = qtmConvertCoordToScreen(&qtminfo.coords0[pos], NULL, NULL, &x, &y);
|
||||
|
||||
if(ret==0)memcpy(&fb[(x*240 + y) * 3], &colors[pos], 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Flush and swap framebuffers
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
}
|
||||
|
||||
// Exit services
|
||||
qtmExit();
|
||||
gfxExit();
|
||||
return 0;
|
||||
}
|
||||
|
@ -1,170 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
.PHONY: all
|
||||
all : $(OUTPUT).3dsx $(OUTPUT).smdh
|
||||
endif
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
# WARNING: This is not the right way to do this! TODO: Do it right!
|
||||
#---------------------------------------------------------------------------------
|
||||
%.vsh.o : %.vsh
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@rm ../$(notdir $<).shbin
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1,5 +0,0 @@
|
||||
sdmc
|
||||
=======
|
||||
|
||||
very simple example of how to access SD files with libctru;
|
||||
|
@ -1,50 +0,0 @@
|
||||
#include <3ds/types.h>
|
||||
|
||||
s32 costable[] = { 4096, 4095, 4094, 4093, 4091, 4088, 4084, 4080, 4076, 4071, 4065,
|
||||
4058, 4051, 4044, 4035, 4026, 4017, 4007, 3996, 3985, 3973, 3960,
|
||||
3947, 3934, 3919, 3904, 3889, 3873, 3856, 3839, 3821, 3803, 3784,
|
||||
3765, 3744, 3724, 3703, 3681, 3659, 3636, 3612, 3588, 3564, 3539,
|
||||
3513, 3487, 3461, 3434, 3406, 3378, 3349, 3320, 3290, 3260, 3229,
|
||||
3198, 3167, 3135, 3102, 3069, 3035, 3002, 2967, 2932, 2897, 2861,
|
||||
2825, 2788, 2751, 2714, 2676, 2638, 2599, 2560, 2521, 2481, 2441,
|
||||
2401, 2360, 2318, 2277, 2235, 2193, 2150, 2107, 2064, 2020, 1976,
|
||||
1932, 1888, 1843, 1798, 1753, 1707, 1662, 1616, 1569, 1523, 1476,
|
||||
1429, 1382, 1334, 1287, 1239, 1191, 1143, 1095, 1046, 997, 949,
|
||||
900, 851, 801, 752, 703, 653, 603, 554, 504, 454, 404, 354, 304,
|
||||
254, 204, 153, 103, 53, 3, -46, -97, -147, -197, -247, -297, -347,
|
||||
-398, -448, -497, -547, -597, -647, -696, -746, -795, -844, -893,
|
||||
-942, -991, -1040, -1088, -1137, -1185, -1233, -1281, -1328, -1376,
|
||||
-1423, -1470, -1517, -1563, -1610, -1656, -1701, -1747, -1792, -1837,
|
||||
-1882, -1927, -1971, -2015, -2058, -2102, -2144, -2187, -2229, -2271,
|
||||
-2313, -2354, -2395, -2436, -2476, -2516, -2555, -2594, -2633, -2671,
|
||||
-2709, -2747, -2784, -2820, -2857, -2892, -2928, -2963, -2997, -3031,
|
||||
-3065, -3098, -3130, -3163, -3194, -3225, -3256, -3286, -3316, -3345,
|
||||
-3374, -3402, -3430, -3457, -3484, -3510, -3536, -3561, -3585, -3609,
|
||||
-3633, -3656, -3678, -3700, -3721, -3742, -3762, -3782, -3801, -3819,
|
||||
-3837, -3854, -3871, -3887, -3902, -3917, -3932, -3946, -3959, -3971,
|
||||
-3983, -3995, -4005, -4016, -4025, -4034, -4042, -4050, -4057, -4064,
|
||||
-4070, -4075, -4080, -4084, -4087, -4090, -4092, -4094, -4095, -4095,
|
||||
-4095, -4094, -4093, -4091, -4088, -4085, -4081, -4076, -4071, -4066,
|
||||
-4059, -4052, -4045, -4036, -4028, -4018, -4008, -3997, -3986, -3974,
|
||||
-3962, -3949, -3935, -3921, -3906, -3891, -3875, -3858, -3841, -3824,
|
||||
-3805, -3787, -3767, -3747, -3727, -3705, -3684, -3662, -3639, -3615,
|
||||
-3592, -3567, -3542, -3517, -3491, -3464, -3437, -3409, -3381, -3353,
|
||||
-3324, -3294, -3264, -3233, -3202, -3171, -3139, -3106, -3073, -3040,
|
||||
-3006, -2972, -2937, -2902, -2866, -2830, -2793, -2756, -2719, -2681,
|
||||
-2643, -2604, -2565, -2526, -2486, -2446, -2406, -2365, -2324, -2282,
|
||||
-2240, -2198, -2156, -2113, -2069, -2026, -1982, -1938, -1894, -1849,
|
||||
-1804, -1759, -1713, -1668, -1622, -1575, -1529, -1482, -1435, -1388,
|
||||
-1341, -1293, -1245, -1197, -1149, -1101, -1052, -1004, -955, -906,
|
||||
-857, -808, -758, -709, -660, -610, -560, -510, -460, -411, -360,
|
||||
-310, -260, -210, -160, -110, -60, -9, 40, 90, 140, 191, 241, 291,
|
||||
341, 391, 441, 491, 541, 591, 640, 690, 739, 789, 838, 887, 936,
|
||||
985, 1033, 1082, 1130, 1179, 1227, 1274, 1322, 1370, 1417, 1464,
|
||||
1511, 1557, 1604, 1650, 1695, 1741, 1786, 1831, 1876, 1921, 1965,
|
||||
2009, 2053, 2096, 2139, 2182, 2224, 2266, 2308, 2349, 2390, 2431,
|
||||
2471, 2511, 2550, 2589, 2628, 2666, 2704, 2742, 2779, 2816, 2852,
|
||||
2888, 2923, 2958, 2993, 3027, 3060, 3093, 3126, 3158, 3190, 3221,
|
||||
3252, 3282, 3312, 3342, 3370, 3399, 3426, 3454, 3480, 3507, 3532,
|
||||
3557, 3582, 3606, 3630, 3653, 3675, 3697, 3718, 3739, 3759, 3779,
|
||||
3798, 3817, 3835, 3852, 3869, 3885, 3900, 3915, 3930, 3944, 3957,
|
||||
3970, 3982, 3993, 4004, 4014, 4024, 4033, 4041, 4049, 4056, 4063,
|
||||
4069, 4074, 4079, 4083, 4087, 4090, 4092, 4094, 4095};
|
@ -1,6 +0,0 @@
|
||||
#ifndef COSTABLE_H
|
||||
#define COSTABLE_H
|
||||
|
||||
extern s32 costable[];
|
||||
|
||||
#endif
|
@ -1,98 +0,0 @@
|
||||
///////////////////////////////////////
|
||||
// SDMC example //
|
||||
///////////////////////////////////////
|
||||
|
||||
//this example shows you how to load a binary image file from the SD card and display it on the lower screen
|
||||
//for this to work you should copy test.bin to same folder as your .3dsx
|
||||
//this file was generated with GIMP by saving a 240x320 image to raw RGB
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <3ds.h>
|
||||
#include "costable.h"
|
||||
|
||||
//this will contain the data read from SDMC
|
||||
u8* buffer;
|
||||
|
||||
//3DS has VFPs so we could just use cos
|
||||
//but we're old school so LUT4life
|
||||
s32 pcCos(u16 v)
|
||||
{
|
||||
return costable[v&0x1FF];
|
||||
}
|
||||
|
||||
void renderEffect()
|
||||
{
|
||||
static int cnt;
|
||||
u8* bufAdr=gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
|
||||
int i, j;
|
||||
for(i=1;i<400;i++)
|
||||
{
|
||||
for(j=1;j<240;j++)
|
||||
{
|
||||
u32 v=(j+i*240)*3;
|
||||
bufAdr[v]=(pcCos(i+cnt)+4096)/32;
|
||||
bufAdr[v+1]=(pcCos(j-256+cnt)+4096)/64;
|
||||
bufAdr[v+2]=(pcCos(i+128-cnt)+4096)/32;
|
||||
}
|
||||
}
|
||||
|
||||
cnt++;
|
||||
}
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
|
||||
gfxInitDefault(); //makes displaying to screen easier
|
||||
|
||||
FILE *file = fopen("test.bin","rb");
|
||||
if (file == NULL) goto exit;
|
||||
|
||||
// seek to end of file
|
||||
fseek(file,0,SEEK_END);
|
||||
|
||||
// file pointer tells us the size
|
||||
off_t size = ftell(file);
|
||||
|
||||
// seek back to start
|
||||
fseek(file,0,SEEK_SET);
|
||||
|
||||
//allocate a buffer
|
||||
buffer=malloc(size);
|
||||
if(!buffer)goto exit;
|
||||
|
||||
//read contents !
|
||||
off_t bytesRead = fread(buffer,1,size,file);
|
||||
|
||||
//close the file because we like being nice and tidy
|
||||
fclose(file);
|
||||
|
||||
if(size!=bytesRead)goto exit;
|
||||
|
||||
while(aptMainLoop())
|
||||
{
|
||||
//exit when user hits B
|
||||
hidScanInput();
|
||||
if(keysHeld()&KEY_B)break;
|
||||
|
||||
//render rainbow
|
||||
renderEffect();
|
||||
|
||||
//copy buffer to lower screen (don't have to do it every frame)
|
||||
memcpy(gfxGetFramebuffer(GFX_BOTTOM, GFX_BOTTOM, NULL, NULL), buffer, size);
|
||||
|
||||
//wait & swap
|
||||
gfxSwapBuffersGpu();
|
||||
gspWaitForEvent(GSPEVENT_VBlank0, false);
|
||||
}
|
||||
|
||||
//cleanup and return
|
||||
//returning from main() returns to hbmenu when run under ninjhax
|
||||
exit:
|
||||
|
||||
//closing all services even more so
|
||||
gfxExit();
|
||||
return 0;
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -1,7 +0,0 @@
|
||||
SUBDIRS:= `ls | egrep -v '^(CVS)$$'`
|
||||
all:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i || { exit 1;} fi; done;
|
||||
clean:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i clean || { exit 1;} fi; done;
|
||||
install:
|
||||
@for i in $(SUBDIRS); do if test -e $$i/Makefile ; then $(MAKE) -C $$i install || { exit 1;} fi; done;
|
@ -1,175 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
TOPDIR ?= $(CURDIR)
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#
|
||||
# NO_SMDH: if set to anything, no SMDH file is generated.
|
||||
# APP_TITLE is the name of the app stored in the SMDH file (Optional)
|
||||
# APP_DESCRIPTION is the description of the app stored in the SMDH file (Optional)
|
||||
# APP_AUTHOR is the author of the app stored in the SMDH file (Optional)
|
||||
# ICON is the filename of the icon (.png), relative to the project folder.
|
||||
# If not set, it attempts to use one of the following (in this order):
|
||||
# - <Project name>.png
|
||||
# - icon.png
|
||||
# - <libctru folder>/default_icon.png
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(notdir $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
LDFLAGS = -specs=3dsx.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
|
||||
|
||||
LIBS := -lctru -lm
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/$(TARGET)
|
||||
export TOPDIR := $(CURDIR)
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
|
||||
|
||||
ifeq ($(strip $(ICON)),)
|
||||
icons := $(wildcard *.png)
|
||||
ifneq (,$(findstring $(TARGET).png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/$(TARGET).png
|
||||
else
|
||||
ifneq (,$(findstring icon.png,$(icons)))
|
||||
export APP_ICON := $(TOPDIR)/icon.png
|
||||
endif
|
||||
endif
|
||||
else
|
||||
export APP_ICON := $(TOPDIR)/$(ICON)
|
||||
endif
|
||||
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
export _3DSXFLAGS += --smdh=$(CURDIR)/$(TARGET).smdh
|
||||
endif
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
$(BUILD):
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) $(TARGET).3dsx $(OUTPUT).smdh $(TARGET).elf
|
||||
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(NO_SMDH)),)
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf $(OUTPUT).smdh
|
||||
else
|
||||
$(OUTPUT).3dsx : $(OUTPUT).elf
|
||||
endif
|
||||
|
||||
$(OUTPUT).elf : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# you need a rule like this for each extension you use as binary data
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
# WARNING: This is not the right way to do this! TODO: Do it right!
|
||||
#---------------------------------------------------------------------------------
|
||||
%.vsh.o : %.vsh
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@python $(AEMSTRO)/aemstro_as.py $< ../$(notdir $<).shbin
|
||||
@bin2s ../$(notdir $<).shbin | $(PREFIX)as -o $@
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
|
||||
@rm ../$(notdir $<).shbin
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1,3 +0,0 @@
|
||||
# template
|
||||
|
||||
This is a template for starting new 3DS libctru projects.
|
@ -1,37 +0,0 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <3ds.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
gfxInitDefault();
|
||||
//gfxSet3D(true); // uncomment if using stereoscopic 3D
|
||||
|
||||
// Main loop
|
||||
while (aptMainLoop())
|
||||
{
|
||||
gspWaitForVBlank();
|
||||
hidScanInput();
|
||||
|
||||
// Your code goes here
|
||||
|
||||
u32 kDown = hidKeysDown();
|
||||
if (kDown & KEY_START)
|
||||
break; // break in order to return to hbmenu
|
||||
|
||||
// Example rendering code that displays a white pixel
|
||||
// Please note that the 3DS screens are sideways (thus 240x400 and 240x320)
|
||||
u8* fb = gfxGetFramebuffer(GFX_TOP, GFX_LEFT, NULL, NULL);
|
||||
memset(fb, 0, 240*400*3);
|
||||
fb[3*(10+10*240)] = 0xFF;
|
||||
fb[3*(10+10*240)+1] = 0xFF;
|
||||
fb[3*(10+10*240)+2] = 0xFF;
|
||||
|
||||
// Flush and swap framebuffers
|
||||
gfxFlushBuffers();
|
||||
gfxSwapBuffers();
|
||||
}
|
||||
|
||||
gfxExit();
|
||||
return 0;
|
||||
}
|
@ -1,121 +0,0 @@
|
||||
#---------------------------------------------------------------------------------
|
||||
.SUFFIXES:
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
ifeq ($(strip $(DEVKITARM)),)
|
||||
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
|
||||
endif
|
||||
|
||||
include $(DEVKITARM)/3ds_rules
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# TARGET is the name of the output
|
||||
# BUILD is the directory where object files & intermediate files will be placed
|
||||
# SOURCES is a list of directories containing source code
|
||||
# DATA is a list of directories containing data files
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := $(shell basename $(CURDIR))
|
||||
BUILD := build
|
||||
SOURCES := source
|
||||
DATA := data
|
||||
INCLUDES := include
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
|
||||
CFLAGS := -g -Wall -O2\
|
||||
$(ARCH)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
# include and lib
|
||||
#---------------------------------------------------------------------------------
|
||||
LIBDIRS := $(CTRULIB)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# no real need to edit anything past this point unless you need to add additional
|
||||
# rules for different file extensions
|
||||
#---------------------------------------------------------------------------------
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# use CXX for linking C++ projects, CC for standard C
|
||||
#---------------------------------------------------------------------------------
|
||||
ifeq ($(strip $(CPPFILES)),)
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CC)
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
#---------------------------------------------------------------------------------
|
||||
export LD := $(CXX)
|
||||
#---------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
|
||||
lib:
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
|
||||
$(BUILD): lib
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) lib
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
|
||||
DEPENDS := $(OFILES:.o=.d)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# main targets
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT) : $(OFILES)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
||||
|
||||
-include $(DEPENDS)
|
||||
|
||||
#---------------------------------------------------------------------------------------
|
||||
endif
|
||||
#---------------------------------------------------------------------------------------
|
@ -1,3 +0,0 @@
|
||||
# template
|
||||
|
||||
This is a template for starting new 3DS library projects.
|
@ -1,6 +0,0 @@
|
||||
#ifndef _templatelib_h_
|
||||
#define _templatelib_h_
|
||||
|
||||
int myLibFunction();
|
||||
|
||||
#endif // _templatelib_h_
|
@ -1,6 +0,0 @@
|
||||
int myLibFunction() {
|
||||
|
||||
|
||||
return 42;
|
||||
|
||||
}
|
7
libctru/.gitignore
vendored
7
libctru/.gitignore
vendored
@ -1,5 +1,10 @@
|
||||
debug
|
||||
release
|
||||
deps
|
||||
build
|
||||
lib
|
||||
docs
|
||||
internal_docs
|
||||
*.bz2
|
||||
*.bz2
|
||||
.*/
|
||||
*.tag
|
||||
|
422
libctru/Doxyfile
422
libctru/Doxyfile
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@ endif
|
||||
|
||||
include $(DEVKITARM)/base_rules
|
||||
|
||||
export LIBCTRU_MAJOR := 0
|
||||
export LIBCTRU_MAJOR := 2
|
||||
export LIBCTRU_MINOR := 4
|
||||
export LIBCTRU_PATCH := 0
|
||||
|
||||
@ -23,12 +23,15 @@ VERSION := $(LIBCTRU_MAJOR).$(LIBCTRU_MINOR).$(LIBCTRU_PATCH)
|
||||
# INCLUDES is a list of directories containing header files
|
||||
#---------------------------------------------------------------------------------
|
||||
TARGET := ctru
|
||||
BUILD := build
|
||||
#BUILD := build
|
||||
SOURCES := source \
|
||||
source/allocator \
|
||||
source/gpu \
|
||||
source/ndsp \
|
||||
source/services \
|
||||
source/services/soc \
|
||||
source/applets \
|
||||
source/util/decompress \
|
||||
source/util/rbtree \
|
||||
source/util/utf \
|
||||
source/system
|
||||
@ -39,17 +42,19 @@ INCLUDES := include
|
||||
#---------------------------------------------------------------------------------
|
||||
# options for code generation
|
||||
#---------------------------------------------------------------------------------
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard
|
||||
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -mtp=soft
|
||||
|
||||
CFLAGS := -g -Wall -O2 -mword-relocations \
|
||||
-fomit-frame-pointer -ffast-math \
|
||||
$(ARCH)
|
||||
CFLAGS := -g -Wall -Werror -mword-relocations \
|
||||
-ffunction-sections \
|
||||
-fdata-sections \
|
||||
$(ARCH) \
|
||||
$(BUILD_CFLAGS)
|
||||
|
||||
CFLAGS += $(INCLUDE) -DARM11 -D_3DS
|
||||
CFLAGS += $(INCLUDE) -D__3DS__
|
||||
|
||||
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
|
||||
|
||||
ASFLAGS := -g $(ARCH)
|
||||
ASFLAGS := -g $(ARCH) $(INCLUDE)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
# list of directories containing libraries, this must be the top level containing
|
||||
@ -64,13 +69,9 @@ LIBDIRS :=
|
||||
ifneq ($(BUILD),$(notdir $(CURDIR)))
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OUTPUT := $(CURDIR)/lib/lib$(TARGET).a
|
||||
|
||||
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
|
||||
|
||||
export DEPSDIR := $(CURDIR)/$(BUILD)
|
||||
|
||||
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
|
||||
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
|
||||
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
|
||||
@ -90,45 +91,61 @@ else
|
||||
endif
|
||||
#---------------------------------------------------------------------------------
|
||||
|
||||
export OFILES := $(addsuffix .o,$(BINFILES)) \
|
||||
$(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
export OFILES_BIN := $(addsuffix .o,$(BINFILES))
|
||||
export OFILES_SRC := $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) $(SFILES:.s=.o)
|
||||
|
||||
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
|
||||
|
||||
export OFILES := $(OFILES_BIN) $(OFILES_SRC)
|
||||
|
||||
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
|
||||
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
|
||||
-I$(CURDIR)/$(BUILD)
|
||||
-I.
|
||||
|
||||
.PHONY: $(BUILD) clean all
|
||||
.PHONY: clean all
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
all: $(BUILD)
|
||||
all: lib/libctru.a lib/libctrud.a
|
||||
|
||||
dist-bin: all
|
||||
@tar -cjf libctru-$(VERSION).tar.bz2 include lib default_icon.png
|
||||
@tar --exclude=*~ -cjf libctru-$(VERSION).tar.bz2 include lib default_icon.png
|
||||
|
||||
dist-src:
|
||||
@tar -cjf libctru-src-$(VERSION).tar.bz2 include source Makefile Doxyfile Doxyfile.internal default_icon.png
|
||||
@tar --exclude=*~ -cjf libctru-src-$(VERSION).tar.bz2 include source data Makefile Doxyfile default_icon.png
|
||||
|
||||
dist: dist-src dist-bin
|
||||
|
||||
install: dist-bin
|
||||
mkdir -p $(DEVKITPRO)/libctru
|
||||
bzip2 -cd libctru-$(VERSION).tar.bz2 | tar -x -C $(DEVKITPRO)/libctru
|
||||
|
||||
dox:
|
||||
@doxygen Doxyfile
|
||||
@doxygen Doxyfile.internal
|
||||
mkdir -p $(DESTDIR)$(DEVKITPRO)/libctru
|
||||
bzip2 -cd libctru-$(VERSION).tar.bz2 | tar -xf - -C $(DESTDIR)$(DEVKITPRO)/libctru
|
||||
|
||||
lib:
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
|
||||
$(BUILD): lib
|
||||
release:
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
@$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
|
||||
|
||||
debug:
|
||||
@[ -d $@ ] || mkdir -p $@
|
||||
|
||||
lib/libctru.a : lib release $(SOURCES) $(INCLUDES)
|
||||
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
|
||||
BUILD_CFLAGS="-DNDEBUG=1 -O2 -fomit-frame-pointer" \
|
||||
DEPSDIR=$(CURDIR)/release \
|
||||
--no-print-directory -C release \
|
||||
-f $(CURDIR)/Makefile
|
||||
|
||||
lib/libctrud.a : lib debug $(SOURCES) $(INCLUDES)
|
||||
@$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
|
||||
BUILD_CFLAGS="-DDEBUG=1 -Og" \
|
||||
DEPSDIR=$(CURDIR)/debug \
|
||||
--no-print-directory -C debug \
|
||||
-f $(CURDIR)/Makefile
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
clean:
|
||||
@echo clean ...
|
||||
@rm -fr $(BUILD) lib docs internal_docs
|
||||
@rm -fr release debug lib docs libctru.tag
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
else
|
||||
@ -140,8 +157,10 @@ DEPENDS := $(OFILES:.o=.d)
|
||||
#---------------------------------------------------------------------------------
|
||||
$(OUTPUT) : $(OFILES)
|
||||
|
||||
$(OFILES_SRC) : $(HFILES_BIN)
|
||||
|
||||
#---------------------------------------------------------------------------------
|
||||
%.bin.o : %.bin
|
||||
%.bin.o %_bin.h : %.bin
|
||||
#---------------------------------------------------------------------------------
|
||||
@echo $(notdir $<)
|
||||
@$(bin2o)
|
||||
|
@ -1,43 +1,154 @@
|
||||
/**
|
||||
* @file 3ds.h
|
||||
* @brief Central 3DS header. Includes all others.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_3DS) && !defined(__3DS__)
|
||||
#warning "Please update your Makefile and replace -DARM11 -D_3DS with -D__3DS__"
|
||||
#define __3DS__
|
||||
#endif
|
||||
|
||||
//might be missing some
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/result.h>
|
||||
#include <3ds/ipc.h>
|
||||
#include <3ds/svc.h>
|
||||
#include <3ds/exheader.h>
|
||||
#include <3ds/srv.h>
|
||||
#include <3ds/linear.h>
|
||||
#include <3ds/vram.h>
|
||||
#include <3ds/errf.h>
|
||||
#include <3ds/os.h>
|
||||
#include <3ds/synchronization.h>
|
||||
#include <3ds/thread.h>
|
||||
#include <3ds/gfx.h>
|
||||
#include <3ds/console.h>
|
||||
#include <3ds/env.h>
|
||||
#include <3ds/util/decompress.h>
|
||||
#include <3ds/util/utf.h>
|
||||
|
||||
#include <3ds/allocator/linear.h>
|
||||
#include <3ds/allocator/mappable.h>
|
||||
#include <3ds/allocator/vram.h>
|
||||
|
||||
#include <3ds/services/ac.h>
|
||||
#include <3ds/services/am.h>
|
||||
#include <3ds/services/ampxi.h>
|
||||
#include <3ds/services/apt.h>
|
||||
#include <3ds/services/boss.h>
|
||||
#include <3ds/services/cam.h>
|
||||
#include <3ds/services/cfgnor.h>
|
||||
#include <3ds/services/cfgu.h>
|
||||
#include <3ds/services/csnd.h>
|
||||
#include <3ds/services/dsp.h>
|
||||
#include <3ds/services/fs.h>
|
||||
#include <3ds/services/gsp.h>
|
||||
#include <3ds/services/fspxi.h>
|
||||
#include <3ds/services/fsreg.h>
|
||||
#include <3ds/services/frd.h>
|
||||
#include <3ds/services/gspgpu.h>
|
||||
#include <3ds/services/gsplcd.h>
|
||||
#include <3ds/services/hid.h>
|
||||
#include <3ds/services/irrst.h>
|
||||
#include <3ds/services/sslc.h>
|
||||
#include <3ds/services/httpc.h>
|
||||
#include <3ds/services/uds.h>
|
||||
#include <3ds/services/ndm.h>
|
||||
#include <3ds/services/nim.h>
|
||||
#include <3ds/services/nwmext.h>
|
||||
#include <3ds/services/ir.h>
|
||||
#include <3ds/services/ptm.h>
|
||||
#include <3ds/services/ns.h>
|
||||
#include <3ds/services/pmapp.h>
|
||||
#include <3ds/services/pmdbg.h>
|
||||
#include <3ds/services/ps.h>
|
||||
#include <3ds/services/ptmu.h>
|
||||
#include <3ds/services/ptmsysm.h>
|
||||
#include <3ds/services/ptmgets.h>
|
||||
#include <3ds/services/ptmsets.h>
|
||||
#include <3ds/services/pxidev.h>
|
||||
#include <3ds/services/pxipm.h>
|
||||
#include <3ds/services/soc.h>
|
||||
#include <3ds/services/mic.h>
|
||||
#include <3ds/services/mvd.h>
|
||||
#include <3ds/services/nfc.h>
|
||||
#include <3ds/services/news.h>
|
||||
#include <3ds/services/qtm.h>
|
||||
#include <3ds/services/hb.h>
|
||||
#include <3ds/services/qtmc.h>
|
||||
#include <3ds/services/srvpm.h>
|
||||
#include <3ds/services/loader.h>
|
||||
#include <3ds/services/y2r.h>
|
||||
#include <3ds/services/mcuhwc.h>
|
||||
#include <3ds/services/cdcchk.h>
|
||||
|
||||
#include <3ds/gpu/gx.h>
|
||||
#include <3ds/gpu/gpu.h>
|
||||
#include <3ds/gpu/shdr.h>
|
||||
#include <3ds/gpu/shbin.h>
|
||||
#include <3ds/gpu/shaderProgram.h>
|
||||
|
||||
#include <3ds/sdmc.h>
|
||||
#include <3ds/ndsp/ndsp.h>
|
||||
#include <3ds/ndsp/channel.h>
|
||||
|
||||
#include <3ds/applets/swkbd.h>
|
||||
#include <3ds/applets/error.h>
|
||||
|
||||
#include <3ds/applets/miiselector.h>
|
||||
|
||||
#include <3ds/archive.h>
|
||||
#include <3ds/romfs.h>
|
||||
#include <3ds/font.h>
|
||||
#include <3ds/mii.h>
|
||||
|
||||
#include <3ds/gdbhio_dev.h>
|
||||
#include <3ds/3dslink.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
/**
|
||||
* @example app_launch/source/main.c
|
||||
* @example audio/filters/source/main.c
|
||||
* @example audio/mic/source/main.c
|
||||
* @example audio/streaming/source/main.c
|
||||
* @example camera/image/source/main.c
|
||||
* @example camera/video/source/main.c
|
||||
* @example get_system_language/source/main.c
|
||||
* @example graphics/bitmap/24bit-color/source/main.c
|
||||
* @example graphics/gpu/both_screens/source/main.c
|
||||
* @example graphics/gpu/fragment_light/source/main.c
|
||||
* @example graphics/gpu/geoshader/source/main.c
|
||||
* @example graphics/gpu/gpusprites/source/main.c
|
||||
* @example graphics/gpu/immediate/source/main.c
|
||||
* @example graphics/gpu/lenny/source/main.c
|
||||
* @example graphics/gpu/loop_subdivision/source/main.c
|
||||
* @example graphics/gpu/mipmap_fog/source/main.c
|
||||
* @example graphics/gpu/particles/source/main.c
|
||||
* @example graphics/gpu/proctex/source/main.c
|
||||
* @example graphics/gpu/simple_tri/source/main.c
|
||||
* @example graphics/gpu/textured_cube/source/main.c
|
||||
* @example graphics/gpu/toon_shading/source/main.c
|
||||
* @example graphics/printing/both-screen-text/source/main.c
|
||||
* @example graphics/printing/colored-text/source/main.c
|
||||
* @example graphics/printing/hello-world/source/main.c
|
||||
* @example graphics/printing/multiple-windows-text/source/main.c
|
||||
* @example graphics/printing/system-font/source/main.c
|
||||
* @example input/read-controls/source/main.c
|
||||
* @example input/software-keyboard/source/main.c
|
||||
* @example input/touch-screen/source/main.c
|
||||
* @example libapplet_launch/source/main.c
|
||||
* @example mvd/source/main.c
|
||||
* @example network/boss/source/main.c
|
||||
* @example network/http/source/main.c
|
||||
* @example network/http_post/source/main.c
|
||||
* @example network/sockets/source/sockets.c
|
||||
* @example network/sslc/source/ssl.c
|
||||
* @example network/uds/source/uds.c
|
||||
* @example nfc/source/main.c
|
||||
* @example qtm/source/main.c
|
||||
* @example romfs/source/main.c
|
||||
* @example sdmc/source/main.c
|
||||
* @example threads/event/source/main.c
|
||||
* @example threads/thread-basic/source/main.c
|
||||
* @example time/rtc/source/main.c
|
||||
*/
|
||||
|
34
libctru/include/3ds/3dslink.h
Normal file
34
libctru/include/3ds/3dslink.h
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
* @file 3dslink.h
|
||||
* @brief Netloader (3dslink) utilities
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct in_addr;
|
||||
|
||||
/// Address of the host connected through 3dslink
|
||||
extern struct in_addr __3dslink_host;
|
||||
|
||||
#define LINK3DS_COMM_PORT 17491 ///< 3dslink TCP server port
|
||||
|
||||
/**
|
||||
* @brief Connects to the 3dslink host, setting up an output stream.
|
||||
* @param[in] redirStdout Whether to redirect stdout to nxlink output.
|
||||
* @param[in] redirStderr Whether to redirect stderr to nxlink output.
|
||||
* @return Socket fd on success, negative number on failure.
|
||||
* @note The socket should be closed with close() during application cleanup.
|
||||
*/
|
||||
int link3dsConnectToHost(bool redirStdout, bool redirStderr);
|
||||
|
||||
/// Same as \ref link3dsConnectToHost but redirecting both stdout/stderr.
|
||||
static inline int link3dsStdio(void) {
|
||||
return link3dsConnectToHost(true, true);
|
||||
}
|
||||
|
||||
/// Same as \ref link3dsConnectToHost but redirecting only stderr.
|
||||
static inline int link3dsStdioForDebug(void) {
|
||||
return link3dsConnectToHost(false, true);
|
||||
}
|
49
libctru/include/3ds/allocator/linear.h
Normal file
49
libctru/include/3ds/allocator/linear.h
Normal file
@ -0,0 +1,49 @@
|
||||
/**
|
||||
* @file linear.h
|
||||
* @brief Linear memory allocator.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
/**
|
||||
* @brief Allocates a 0x80-byte aligned buffer.
|
||||
* @param size Size of the buffer to allocate.
|
||||
* @return The allocated buffer.
|
||||
*/
|
||||
void* linearAlloc(size_t size);
|
||||
|
||||
/**
|
||||
* @brief Allocates a buffer aligned to the given size.
|
||||
* @param size Size of the buffer to allocate.
|
||||
* @param alignment Alignment to use.
|
||||
* @return The allocated buffer.
|
||||
*/
|
||||
void* linearMemAlign(size_t size, size_t alignment);
|
||||
|
||||
/**
|
||||
* @brief Reallocates a buffer.
|
||||
* Note: Not implemented yet.
|
||||
* @param mem Buffer to reallocate.
|
||||
* @param size Size of the buffer to allocate.
|
||||
* @return The reallocated buffer.
|
||||
*/
|
||||
void* linearRealloc(void* mem, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the allocated size of a buffer.
|
||||
* @return The size of the buffer.
|
||||
*/
|
||||
size_t linearGetSize(void* mem);
|
||||
|
||||
/**
|
||||
* @brief Frees a buffer.
|
||||
* @param mem Buffer to free.
|
||||
*/
|
||||
void linearFree(void* mem);
|
||||
|
||||
/**
|
||||
* @brief Gets the current linear free space.
|
||||
* @return The current linear free space.
|
||||
*/
|
||||
u32 linearSpaceFree(void);
|
27
libctru/include/3ds/allocator/mappable.h
Normal file
27
libctru/include/3ds/allocator/mappable.h
Normal file
@ -0,0 +1,27 @@
|
||||
/**
|
||||
* @file mappable.h
|
||||
* @brief Mappable memory allocator.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
/**
|
||||
* @brief Initializes the mappable allocator.
|
||||
* @param addrMin Minimum address.
|
||||
* @param addrMax Maxium address.
|
||||
*/
|
||||
void mappableInit(u32 addrMin, u32 addrMax);
|
||||
|
||||
/**
|
||||
* @brief Finds a mappable memory area.
|
||||
* @param size Size of the area to find.
|
||||
* @return The mappable area.
|
||||
*/
|
||||
void* mappableAlloc(size_t size);
|
||||
|
||||
/**
|
||||
* @brief Frees a mappable area (stubbed).
|
||||
* @param mem Mappable area to free.
|
||||
*/
|
||||
void mappableFree(void* mem);
|
71
libctru/include/3ds/allocator/vram.h
Normal file
71
libctru/include/3ds/allocator/vram.h
Normal file
@ -0,0 +1,71 @@
|
||||
/**
|
||||
* @file vram.h
|
||||
* @brief VRAM allocator.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
typedef enum vramAllocPos
|
||||
{
|
||||
VRAM_ALLOC_A = BIT(0),
|
||||
VRAM_ALLOC_B = BIT(1),
|
||||
VRAM_ALLOC_ANY = VRAM_ALLOC_A | VRAM_ALLOC_B,
|
||||
} vramAllocPos;
|
||||
|
||||
/**
|
||||
* @brief Allocates a 0x80-byte aligned buffer.
|
||||
* @param size Size of the buffer to allocate.
|
||||
* @return The allocated buffer.
|
||||
*/
|
||||
void* vramAlloc(size_t size);
|
||||
|
||||
/**
|
||||
* @brief Allocates a 0x80-byte aligned buffer in the given VRAM bank.
|
||||
* @param size Size of the buffer to allocate.
|
||||
* @param pos VRAM bank to use (see \ref vramAllocPos).
|
||||
* @return The allocated buffer.
|
||||
*/
|
||||
void* vramAllocAt(size_t size, vramAllocPos pos);
|
||||
|
||||
/**
|
||||
* @brief Allocates a buffer aligned to the given size.
|
||||
* @param size Size of the buffer to allocate.
|
||||
* @param alignment Alignment to use.
|
||||
* @return The allocated buffer.
|
||||
*/
|
||||
void* vramMemAlign(size_t size, size_t alignment);
|
||||
|
||||
/**
|
||||
* @brief Allocates a buffer aligned to the given size in the given VRAM bank.
|
||||
* @param size Size of the buffer to allocate.
|
||||
* @param alignment Alignment to use.
|
||||
* @param pos VRAM bank to use (see \ref vramAllocPos).
|
||||
* @return The allocated buffer.
|
||||
*/
|
||||
void* vramMemAlignAt(size_t size, size_t alignment, vramAllocPos pos);
|
||||
|
||||
/**
|
||||
* @brief Reallocates a buffer.
|
||||
* Note: Not implemented yet.
|
||||
* @param mem Buffer to reallocate.
|
||||
* @param size Size of the buffer to allocate.
|
||||
* @return The reallocated buffer.
|
||||
*/
|
||||
void* vramRealloc(void* mem, size_t size);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the allocated size of a buffer.
|
||||
* @return The size of the buffer.
|
||||
*/
|
||||
size_t vramGetSize(void* mem);
|
||||
|
||||
/**
|
||||
* @brief Frees a buffer.
|
||||
* @param mem Buffer to free.
|
||||
*/
|
||||
void vramFree(void* mem);
|
||||
|
||||
/**
|
||||
* @brief Gets the current VRAM free space.
|
||||
* @return The current VRAM free space.
|
||||
*/
|
||||
u32 vramSpaceFree(void);
|
91
libctru/include/3ds/applets/error.h
Normal file
91
libctru/include/3ds/applets/error.h
Normal file
@ -0,0 +1,91 @@
|
||||
/**
|
||||
* @file error.h
|
||||
* @brief Error applet.
|
||||
*/
|
||||
#pragma once
|
||||
#include <3ds/types.h>
|
||||
|
||||
enum
|
||||
{
|
||||
ERROR_LANGUAGE_FLAG = 0x100, ///<??-Unknown flag
|
||||
ERROR_WORD_WRAP_FLAG = 0x200 ///<??-Unknown flag
|
||||
};
|
||||
|
||||
|
||||
///< Type of Error applet to be called
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ERROR_CODE = 0, ///< Displays the infrastructure communications-related error message corresponding to the error code.
|
||||
ERROR_TEXT, ///< Displays text passed to this applet.
|
||||
ERROR_EULA, ///< Displays the EULA
|
||||
ERROR_TYPE_EULA_FIRST_BOOT, ///< Use prohibited.
|
||||
ERROR_TYPE_EULA_DRAW_ONLY, ///< Use prohibited.
|
||||
ERROR_TYPE_AGREE, ///< Use prohibited.
|
||||
ERROR_CODE_LANGUAGE = ERROR_CODE | ERROR_LANGUAGE_FLAG, ///< Displays a network error message in a specified language.
|
||||
ERROR_TEXT_LANGUAGE = ERROR_TEXT | ERROR_LANGUAGE_FLAG, ///< Displays text passed to this applet in a specified language.
|
||||
ERROR_EULA_LANGUAGE = ERROR_EULA | ERROR_LANGUAGE_FLAG, ///< Displays EULA in a specified language.
|
||||
ERROR_TEXT_WORD_WRAP = ERROR_TEXT | ERROR_WORD_WRAP_FLAG,///< Displays the custom error message passed to this applet with automatic line wrapping
|
||||
ERROR_TEXT_LANGUAGE_WORD_WRAP = ERROR_TEXT | ERROR_LANGUAGE_FLAG | ERROR_WORD_WRAP_FLAG ///< Displays the custom error message with automatic line wrapping and in the specified language.
|
||||
}errorType;
|
||||
|
||||
///< Flags for the Upper Screen.Does nothing even if specified.
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ERROR_NORMAL = 0,
|
||||
ERROR_STEREO
|
||||
}errorScreenFlag;
|
||||
|
||||
///< Return code of the Error module.Use UNKNOWN for simple apps.
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ERROR_UNKNOWN = -1,
|
||||
ERROR_NONE = 0,
|
||||
ERROR_SUCCESS,
|
||||
ERROR_NOT_SUPPORTED,
|
||||
ERROR_HOME_BUTTON = 10,
|
||||
ERROR_SOFTWARE_RESET,
|
||||
ERROR_POWER_BUTTON
|
||||
}errorReturnCode;
|
||||
|
||||
///< Structure to be passed to the applet.Shouldn't be modified directly.
|
||||
|
||||
typedef struct
|
||||
{
|
||||
errorType type;
|
||||
int errorCode;
|
||||
errorScreenFlag upperScreenFlag;
|
||||
u16 useLanguage;
|
||||
u16 Text[1900];
|
||||
bool homeButton;
|
||||
bool softwareReset;
|
||||
bool appJump;
|
||||
errorReturnCode returnCode;
|
||||
u16 eulaVersion;
|
||||
}errorConf;
|
||||
/**
|
||||
* @brief Init the error applet.
|
||||
* @param err Pointer to errorConf.
|
||||
* @param type errorType Type of error.
|
||||
* @param lang CFG_Language Lang of error.
|
||||
*/
|
||||
void errorInit(errorConf* err, errorType type, CFG_Language lang);
|
||||
/**
|
||||
* @brief Sets error code to display.
|
||||
* @param err Pointer to errorConf.
|
||||
* @param error Error-code to display.
|
||||
*/
|
||||
void errorCode(errorConf* err, int error);
|
||||
/**
|
||||
* @brief Sets error text to display.
|
||||
* @param err Pointer to errorConf.
|
||||
* @param text Error-text to display.
|
||||
*/
|
||||
void errorText(errorConf* err, const char* text);
|
||||
/**
|
||||
* @brief Displays the error applet.
|
||||
* @param err Pointer to errorConf.
|
||||
*/
|
||||
void errorDisp(errorConf* err);
|
188
libctru/include/3ds/applets/miiselector.h
Normal file
188
libctru/include/3ds/applets/miiselector.h
Normal file
@ -0,0 +1,188 @@
|
||||
/**
|
||||
* @file miiselector.h
|
||||
* @brief Mii Selector Applet (appletEd).
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/mii.h>
|
||||
|
||||
/// Magic value needed to launch the applet.
|
||||
#define MIISELECTOR_MAGIC 0x13DE28CF
|
||||
|
||||
/// Maximum length of title to be displayed at the top of the Mii selector applet
|
||||
#define MIISELECTOR_TITLE_LEN 64
|
||||
|
||||
/// Number of Guest Miis available for selection
|
||||
#define MIISELECTOR_GUESTMII_SLOTS 6
|
||||
|
||||
/// Maximum number of user Miis available for selection
|
||||
#define MIISELECTOR_USERMII_SLOTS 100
|
||||
|
||||
/// Parameter structure passed to AppletEd
|
||||
typedef struct
|
||||
{
|
||||
u8 enable_cancel_button; ///< Enables canceling of selection if nonzero.
|
||||
u8 enable_selecting_guests; ///< Makes Guets Miis selectable if nonzero.
|
||||
u8 show_on_top_screen; ///< Shows applet on top screen if nonzero,
|
||||
///< otherwise show it on the bottom screen.
|
||||
u8 _unk0x3[5]; ///< @private
|
||||
u16 title[MIISELECTOR_TITLE_LEN]; ///< UTF16-LE string displayed at the top of the applet. If
|
||||
///< set to the empty string, a default title is displayed.
|
||||
u8 _unk0x88[4]; ///< @private
|
||||
u8 show_guest_page; ///< If nonzero, the applet shows a page with Guest
|
||||
///< Miis on launch.
|
||||
u8 _unk0x8D[3]; ///< @private
|
||||
u32 initial_index; ///< Index of the initially selected Mii. If
|
||||
///< @ref MiiSelectorConf.show_guest_page is
|
||||
///< set, this is the index of a Guest Mii,
|
||||
///< otherwise that of a user Mii.
|
||||
u8 mii_guest_whitelist[MIISELECTOR_GUESTMII_SLOTS]; ///< Each byte set to a nonzero value
|
||||
///< enables its corresponding Guest
|
||||
///< Mii to be enabled for selection.
|
||||
u8 mii_whitelist[MIISELECTOR_USERMII_SLOTS]; ///< Each byte set to a nonzero value enables
|
||||
///< its corresponding user Mii to be enabled
|
||||
///< for selection.
|
||||
u16 _unk0xFE; ///< @private
|
||||
u32 magic; ///< Will be set to @ref MIISELECTOR_MAGIC before launching the
|
||||
///< applet.
|
||||
} MiiSelectorConf;
|
||||
|
||||
/// Maximum length of the localized name of a Guest Mii
|
||||
#define MIISELECTOR_GUESTMII_NAME_LEN 12
|
||||
|
||||
/// Structure written by AppletEd
|
||||
typedef struct
|
||||
{
|
||||
u32 no_mii_selected; ///< 0 if a Mii was selected, 1 if the selection was
|
||||
///< canceled.
|
||||
u32 guest_mii_was_selected; ///< 1 if a Guest Mii was selected, 0 otherwise.
|
||||
u32 guest_mii_index; ///< Index of the selected Guest Mii,
|
||||
///< 0xFFFFFFFF if no guest was selected.
|
||||
MiiData mii; ///< Data of selected Mii.
|
||||
u16 _pad0x68; ///< @private
|
||||
u16 checksum; ///< Checksum of the returned Mii data.
|
||||
///< Stored as a big-endian value; use
|
||||
///< @ref miiSelectorChecksumIsValid to
|
||||
///< verify.
|
||||
u16 guest_mii_name[MIISELECTOR_GUESTMII_NAME_LEN]; ///< Localized name of a Guest Mii,
|
||||
///< if one was selected (UTF16-LE
|
||||
///< string). Zeroed otherwise.
|
||||
} MiiSelectorReturn;
|
||||
|
||||
/// AppletEd options
|
||||
enum
|
||||
{
|
||||
MIISELECTOR_CANCEL = BIT(0), ///< Show the cancel button
|
||||
MIISELECTOR_GUESTS = BIT(1), ///< Make Guets Miis selectable
|
||||
MIISELECTOR_TOP = BIT(2), ///< Show AppletEd on top screen
|
||||
MIISELECTOR_GUESTSTART = BIT(3), ///< Start on guest page
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Initialize Mii selector config
|
||||
* @param conf Pointer to Miiselector config.
|
||||
*/
|
||||
void miiSelectorInit(MiiSelectorConf *conf);
|
||||
|
||||
/**
|
||||
* @brief Launch the Mii selector library applet
|
||||
*
|
||||
* @param conf Configuration determining how the applet should behave
|
||||
*/
|
||||
void miiSelectorLaunch(const MiiSelectorConf *conf, MiiSelectorReturn* returnbuf);
|
||||
|
||||
/**
|
||||
* @brief Sets title of the Mii selector library applet
|
||||
*
|
||||
* @param conf Pointer to miiSelector configuration
|
||||
* @param text Title text of Mii selector
|
||||
*/
|
||||
void miiSelectorSetTitle(MiiSelectorConf *conf, const char* text);
|
||||
|
||||
/**
|
||||
* @brief Specifies which special options are enabled in the Mii selector
|
||||
*
|
||||
* @param conf Pointer to miiSelector configuration
|
||||
* @param options Options bitmask
|
||||
*/
|
||||
void miiSelectorSetOptions(MiiSelectorConf *conf, u32 options);
|
||||
|
||||
/**
|
||||
* @brief Specifies which guest Miis will be selectable
|
||||
*
|
||||
* @param conf Pointer to miiSelector configuration
|
||||
* @param index Index of the guest Miis that will be whitelisted.
|
||||
* @ref MIISELECTOR_GUESTMII_SLOTS can be used to whitelist all the guest Miis.
|
||||
*/
|
||||
void miiSelectorWhitelistGuestMii(MiiSelectorConf *conf, u32 index);
|
||||
|
||||
/**
|
||||
* @brief Specifies which guest Miis will be unselectable
|
||||
*
|
||||
* @param conf Pointer to miiSelector configuration
|
||||
* @param index Index of the guest Miis that will be blacklisted.
|
||||
* @ref MIISELECTOR_GUESTMII_SLOTS can be used to blacklist all the guest Miis.
|
||||
*/
|
||||
void miiSelectorBlacklistGuestMii(MiiSelectorConf *conf, u32 index);
|
||||
|
||||
/**
|
||||
* @brief Specifies which user Miis will be selectable
|
||||
*
|
||||
* @param conf Pointer to miiSelector configuration
|
||||
* @param index Index of the user Miis that will be whitelisted.
|
||||
* @ref MIISELECTOR_USERMII_SLOTS can be used to whitlist all the user Miis
|
||||
*/
|
||||
void miiSelectorWhitelistUserMii(MiiSelectorConf *conf, u32 index);
|
||||
|
||||
/**
|
||||
* @brief Specifies which user Miis will be selectable
|
||||
*
|
||||
* @param conf Pointer to miiSelector configuration
|
||||
* @param index Index of the user Miis that will be blacklisted.
|
||||
* @ref MIISELECTOR_USERMII_SLOTS can be used to blacklist all the user Miis
|
||||
*/
|
||||
void miiSelectorBlacklistUserMii(MiiSelectorConf *conf, u32 index);
|
||||
|
||||
/**
|
||||
* @brief Specifies which Mii the cursor should start from
|
||||
*
|
||||
* @param conf Pointer to miiSelector configuration
|
||||
* @param index Indexed number of the Mii that the cursor will start on.
|
||||
* If there is no mii with that index, the the cursor will start at the Mii
|
||||
* with the index 0 (the personal Mii).
|
||||
*/
|
||||
static inline void miiSelectorSetInitialIndex(MiiSelectorConf *conf, u32 index)
|
||||
{
|
||||
conf->initial_index = index;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Get Mii name
|
||||
*
|
||||
* @param returnbuf Pointer to miiSelector return
|
||||
* @param out String containing a Mii's name
|
||||
* @param max_size Size of string. Since UTF8 characters range in size from 1-3 bytes
|
||||
* (assuming that no non-BMP characters are used), this value should be 36 (or 30 if you are not
|
||||
* dealing with guest miis).
|
||||
*/
|
||||
void miiSelectorReturnGetName(const MiiSelectorReturn *returnbuf, char* out, size_t max_size);
|
||||
|
||||
/**
|
||||
* @brief Get Mii Author
|
||||
*
|
||||
* @param returnbuf Pointer to miiSelector return
|
||||
* @param out String containing a Mii's author
|
||||
* @param max_size Size of string. Since UTF8 characters range in size from 1-3 bytes
|
||||
* (assuming that no non-BMP characters are used), this value should be 30.
|
||||
*/
|
||||
void miiSelectorReturnGetAuthor(const MiiSelectorReturn *returnbuf, char* out, size_t max_size);
|
||||
|
||||
/**
|
||||
* @brief Verifies that the Mii data returned from the applet matches its
|
||||
* checksum
|
||||
*
|
||||
* @param returnbuf Buffer filled by Mii selector applet
|
||||
* @return `true` if `returnbuf->checksum` is the same as the one computed from `returnbuf`
|
||||
*/
|
||||
bool miiSelectorChecksumIsValid(const MiiSelectorReturn *returnbuf);
|
321
libctru/include/3ds/applets/swkbd.h
Normal file
321
libctru/include/3ds/applets/swkbd.h
Normal file
@ -0,0 +1,321 @@
|
||||
/**
|
||||
* @file swkbd.h
|
||||
* @brief Software keyboard applet.
|
||||
*/
|
||||
#pragma once
|
||||
#include <3ds/types.h>
|
||||
|
||||
/// Keyboard types.
|
||||
typedef enum
|
||||
{
|
||||
SWKBD_TYPE_NORMAL = 0, ///< Normal keyboard with several pages (QWERTY/accents/symbol/mobile)
|
||||
SWKBD_TYPE_QWERTY, ///< QWERTY keyboard only.
|
||||
SWKBD_TYPE_NUMPAD, ///< Number pad.
|
||||
SWKBD_TYPE_WESTERN, ///< On JPN systems, a text keyboard without Japanese input capabilities, otherwise same as SWKBD_TYPE_NORMAL.
|
||||
} SwkbdType;
|
||||
|
||||
/// Accepted input types.
|
||||
typedef enum
|
||||
{
|
||||
SWKBD_ANYTHING = 0, ///< All inputs are accepted.
|
||||
SWKBD_NOTEMPTY, ///< Empty inputs are not accepted.
|
||||
SWKBD_NOTEMPTY_NOTBLANK, ///< Empty or blank inputs (consisting solely of whitespace) are not accepted.
|
||||
SWKBD_NOTBLANK_NOTEMPTY = SWKBD_NOTEMPTY_NOTBLANK,
|
||||
SWKBD_NOTBLANK, ///< Blank inputs (consisting solely of whitespace) are not accepted, but empty inputs are.
|
||||
SWKBD_FIXEDLEN, ///< The input must have a fixed length (specified by maxTextLength in swkbdInit).
|
||||
} SwkbdValidInput;
|
||||
|
||||
/// Keyboard dialog buttons.
|
||||
typedef enum
|
||||
{
|
||||
SWKBD_BUTTON_LEFT = 0, ///< Left button (usually Cancel)
|
||||
SWKBD_BUTTON_MIDDLE, ///< Middle button (usually I Forgot)
|
||||
SWKBD_BUTTON_RIGHT, ///< Right button (usually OK)
|
||||
SWKBD_BUTTON_CONFIRM = SWKBD_BUTTON_RIGHT,
|
||||
SWKBD_BUTTON_NONE, ///< No button (returned by swkbdInputText in special cases)
|
||||
} SwkbdButton;
|
||||
|
||||
/// Keyboard password modes.
|
||||
typedef enum
|
||||
{
|
||||
SWKBD_PASSWORD_NONE = 0, ///< Characters are not concealed.
|
||||
SWKBD_PASSWORD_HIDE, ///< Characters are concealed immediately.
|
||||
SWKBD_PASSWORD_HIDE_DELAY, ///< Characters are concealed a second after they've been typed.
|
||||
} SwkbdPasswordMode;
|
||||
|
||||
/// Keyboard input filtering flags.
|
||||
enum
|
||||
{
|
||||
SWKBD_FILTER_DIGITS = BIT(0), ///< Disallow the use of more than a certain number of digits (0 or more)
|
||||
SWKBD_FILTER_AT = BIT(1), ///< Disallow the use of the @ sign.
|
||||
SWKBD_FILTER_PERCENT = BIT(2), ///< Disallow the use of the % sign.
|
||||
SWKBD_FILTER_BACKSLASH = BIT(3), ///< Disallow the use of the \ sign.
|
||||
SWKBD_FILTER_PROFANITY = BIT(4), ///< Disallow profanity using Nintendo's profanity filter.
|
||||
SWKBD_FILTER_CALLBACK = BIT(5), ///< Use a callback in order to check the input.
|
||||
};
|
||||
|
||||
/// Keyboard features.
|
||||
enum
|
||||
{
|
||||
SWKBD_PARENTAL = BIT(0), ///< Parental PIN mode.
|
||||
SWKBD_DARKEN_TOP_SCREEN = BIT(1), ///< Darken the top screen when the keyboard is shown.
|
||||
SWKBD_PREDICTIVE_INPUT = BIT(2), ///< Enable predictive input (necessary for Kanji input in JPN systems).
|
||||
SWKBD_MULTILINE = BIT(3), ///< Enable multiline input.
|
||||
SWKBD_FIXED_WIDTH = BIT(4), ///< Enable fixed-width mode.
|
||||
SWKBD_ALLOW_HOME = BIT(5), ///< Allow the usage of the HOME button.
|
||||
SWKBD_ALLOW_RESET = BIT(6), ///< Allow the usage of a software-reset combination.
|
||||
SWKBD_ALLOW_POWER = BIT(7), ///< Allow the usage of the POWER button.
|
||||
SWKBD_DEFAULT_QWERTY = BIT(9), ///< Default to the QWERTY page when the keyboard is shown.
|
||||
};
|
||||
|
||||
/// Keyboard filter callback return values.
|
||||
typedef enum
|
||||
{
|
||||
SWKBD_CALLBACK_OK = 0, ///< Specifies that the input is valid.
|
||||
SWKBD_CALLBACK_CLOSE, ///< Displays an error message, then closes the keyboard.
|
||||
SWKBD_CALLBACK_CONTINUE, ///< Displays an error message and continues displaying the keyboard.
|
||||
} SwkbdCallbackResult;
|
||||
|
||||
/// Keyboard return values.
|
||||
typedef enum
|
||||
{
|
||||
SWKBD_NONE = -1, ///< Dummy/unused.
|
||||
SWKBD_INVALID_INPUT = -2, ///< Invalid parameters to swkbd.
|
||||
SWKBD_OUTOFMEM = -3, ///< Out of memory.
|
||||
|
||||
SWKBD_D0_CLICK = 0, ///< The button was clicked in 1-button dialogs.
|
||||
SWKBD_D1_CLICK0, ///< The left button was clicked in 2-button dialogs.
|
||||
SWKBD_D1_CLICK1, ///< The right button was clicked in 2-button dialogs.
|
||||
SWKBD_D2_CLICK0, ///< The left button was clicked in 3-button dialogs.
|
||||
SWKBD_D2_CLICK1, ///< The middle button was clicked in 3-button dialogs.
|
||||
SWKBD_D2_CLICK2, ///< The right button was clicked in 3-button dialogs.
|
||||
|
||||
SWKBD_HOMEPRESSED = 10, ///< The HOME button was pressed.
|
||||
SWKBD_RESETPRESSED, ///< The soft-reset key combination was pressed.
|
||||
SWKBD_POWERPRESSED, ///< The POWER button was pressed.
|
||||
|
||||
SWKBD_PARENTAL_OK = 20, ///< The parental PIN was verified successfully.
|
||||
SWKBD_PARENTAL_FAIL, ///< The parental PIN was incorrect.
|
||||
|
||||
SWKBD_BANNED_INPUT = 30, ///< The filter callback returned SWKBD_CALLBACK_CLOSE.
|
||||
} SwkbdResult;
|
||||
|
||||
/// Maximum dictionary word length, in UTF-16 code units.
|
||||
#define SWKBD_MAX_WORD_LEN 40
|
||||
/// Maximum button text length, in UTF-16 code units.
|
||||
#define SWKBD_MAX_BUTTON_TEXT_LEN 16
|
||||
/// Maximum hint text length, in UTF-16 code units.
|
||||
#define SWKBD_MAX_HINT_TEXT_LEN 64
|
||||
/// Maximum filter callback error message length, in UTF-16 code units.
|
||||
#define SWKBD_MAX_CALLBACK_MSG_LEN 256
|
||||
|
||||
/// Keyboard dictionary word for predictive input.
|
||||
typedef struct
|
||||
{
|
||||
u16 reading[SWKBD_MAX_WORD_LEN+1]; ///< Reading of the word (that is, the string that needs to be typed).
|
||||
u16 word[SWKBD_MAX_WORD_LEN+1]; ///< Spelling of the word.
|
||||
u8 language; ///< Language the word applies to.
|
||||
bool all_languages; ///< Specifies if the word applies to all languages.
|
||||
} SwkbdDictWord;
|
||||
|
||||
/// Keyboard filter callback function.
|
||||
typedef SwkbdCallbackResult (* SwkbdCallbackFn)(void* user, const char** ppMessage, const char* text, size_t textlen);
|
||||
/// Keyboard status data.
|
||||
typedef struct { u32 data[0x11]; } SwkbdStatusData;
|
||||
/// Keyboard predictive input learning data.
|
||||
typedef struct { u32 data[0x291B]; } SwkbdLearningData;
|
||||
|
||||
/// Internal libctru book-keeping structure for software keyboards.
|
||||
typedef struct
|
||||
{
|
||||
const char* initial_text;
|
||||
const SwkbdDictWord* dict;
|
||||
SwkbdStatusData* status_data;
|
||||
SwkbdLearningData* learning_data;
|
||||
SwkbdCallbackFn callback;
|
||||
void* callback_user;
|
||||
} SwkbdExtra;
|
||||
|
||||
/// Software keyboard parameter structure, it shouldn't be modified directly.
|
||||
typedef struct
|
||||
{
|
||||
int type;
|
||||
int num_buttons_m1;
|
||||
int valid_input;
|
||||
int password_mode;
|
||||
int is_parental_screen;
|
||||
int darken_top_screen;
|
||||
u32 filter_flags;
|
||||
u32 save_state_flags;
|
||||
u16 max_text_len;
|
||||
u16 dict_word_count;
|
||||
u16 max_digits;
|
||||
u16 button_text[3][SWKBD_MAX_BUTTON_TEXT_LEN+1];
|
||||
u16 numpad_keys[2];
|
||||
u16 hint_text[SWKBD_MAX_HINT_TEXT_LEN+1];
|
||||
bool predictive_input;
|
||||
bool multiline;
|
||||
bool fixed_width;
|
||||
bool allow_home;
|
||||
bool allow_reset;
|
||||
bool allow_power;
|
||||
bool unknown; // XX: what is this supposed to do? "communicateWithOtherRegions"
|
||||
bool default_qwerty;
|
||||
bool button_submits_text[4];
|
||||
u16 language; // XX: not working? supposedly 0 = use system language, CFG_Language+1 = pick language
|
||||
int initial_text_offset;
|
||||
int dict_offset;
|
||||
int initial_status_offset;
|
||||
int initial_learning_offset;
|
||||
size_t shared_memory_size;
|
||||
u32 version;
|
||||
SwkbdResult result;
|
||||
int status_offset;
|
||||
int learning_offset;
|
||||
int text_offset;
|
||||
u16 text_length;
|
||||
int callback_result;
|
||||
u16 callback_msg[SWKBD_MAX_CALLBACK_MSG_LEN+1];
|
||||
bool skip_at_check;
|
||||
union
|
||||
{
|
||||
u8 reserved[171];
|
||||
SwkbdExtra extra;
|
||||
};
|
||||
} SwkbdState;
|
||||
|
||||
/**
|
||||
* @brief Initializes software keyboard status.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param type Keyboard type.
|
||||
* @param numButtons Number of dialog buttons to display (1, 2 or 3).
|
||||
* @param maxTextLength Maximum number of UTF-16 code units that input text can have (or -1 to let libctru use a big default).
|
||||
*/
|
||||
void swkbdInit(SwkbdState* swkbd, SwkbdType type, int numButtons, int maxTextLength);
|
||||
|
||||
/**
|
||||
* @brief Configures password mode in a software keyboard.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param mode Password mode.
|
||||
*/
|
||||
static inline void swkbdSetPasswordMode(SwkbdState* swkbd, SwkbdPasswordMode mode)
|
||||
{
|
||||
swkbd->password_mode = mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures input validation in a software keyboard.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param validInput Specifies which inputs are valid.
|
||||
* @param filterFlags Bitmask specifying which characters are disallowed (filtered).
|
||||
* @param maxDigits In case digits are disallowed, specifies how many digits are allowed at maximum in input strings (0 completely restricts digit input).
|
||||
*/
|
||||
static inline void swkbdSetValidation(SwkbdState* swkbd, SwkbdValidInput validInput, u32 filterFlags, int maxDigits)
|
||||
{
|
||||
swkbd->valid_input = validInput;
|
||||
swkbd->filter_flags = filterFlags;
|
||||
swkbd->max_digits = (filterFlags & SWKBD_FILTER_DIGITS) ? maxDigits : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures what characters will the two bottom keys in a numpad produce.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param left Unicode codepoint produced by the leftmost key in the bottom row (0 hides the key).
|
||||
* @param left Unicode codepoint produced by the rightmost key in the bottom row (0 hides the key).
|
||||
*/
|
||||
static inline void swkbdSetNumpadKeys(SwkbdState* swkbd, int left, int right)
|
||||
{
|
||||
swkbd->numpad_keys[0] = left;
|
||||
swkbd->numpad_keys[1] = right;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Specifies which special features are enabled in a software keyboard.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param features Feature bitmask.
|
||||
*/
|
||||
void swkbdSetFeatures(SwkbdState* swkbd, u32 features);
|
||||
|
||||
/**
|
||||
* @brief Sets the hint text of a software keyboard (that is, the help text that is displayed when the textbox is empty).
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param text Hint text.
|
||||
*/
|
||||
void swkbdSetHintText(SwkbdState* swkbd, const char* text);
|
||||
|
||||
/**
|
||||
* @brief Configures a dialog button in a software keyboard.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param button Specifies which button to configure.
|
||||
* @param text Button text.
|
||||
* @param submit Specifies whether pushing the button will submit the text or discard it.
|
||||
*/
|
||||
void swkbdSetButton(SwkbdState* swkbd, SwkbdButton button, const char* text, bool submit);
|
||||
|
||||
/**
|
||||
* @brief Sets the initial text that a software keyboard will display on launch.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param text Initial text.
|
||||
*/
|
||||
void swkbdSetInitialText(SwkbdState* swkbd, const char* text);
|
||||
|
||||
/**
|
||||
* @brief Configures a word in a predictive dictionary for use with a software keyboard.
|
||||
* @param word Pointer to dictionary word structure.
|
||||
* @param reading Reading of the word, that is, the sequence of characters that need to be typed to trigger the word in the predictive input system.
|
||||
* @param text Spelling of the word, that is, the actual characters that will be produced when the user decides to select the word.
|
||||
*/
|
||||
void swkbdSetDictWord(SwkbdDictWord* word, const char* reading, const char* text);
|
||||
|
||||
/**
|
||||
* @brief Sets the custom word dictionary to be used with the predictive input system of a software keyboard.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param dict Pointer to dictionary words.
|
||||
* @param wordCount Number of words in the dictionary.
|
||||
*/
|
||||
void swkbdSetDictionary(SwkbdState* swkbd, const SwkbdDictWord* dict, int wordCount);
|
||||
|
||||
/**
|
||||
* @brief Configures software keyboard internal status management.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param data Pointer to internal status structure (can be in, out or both depending on the other parameters).
|
||||
* @param in Specifies whether the data should be read from the structure when the keyboard is launched.
|
||||
* @param out Specifies whether the data should be written to the structure when the keyboard is closed.
|
||||
*/
|
||||
void swkbdSetStatusData(SwkbdState* swkbd, SwkbdStatusData* data, bool in, bool out);
|
||||
|
||||
/**
|
||||
* @brief Configures software keyboard predictive input learning data management.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param data Pointer to learning data structure (can be in, out or both depending on the other parameters).
|
||||
* @param in Specifies whether the data should be read from the structure when the keyboard is launched.
|
||||
* @param out Specifies whether the data should be written to the structure when the keyboard is closed.
|
||||
*/
|
||||
void swkbdSetLearningData(SwkbdState* swkbd, SwkbdLearningData* data, bool in, bool out);
|
||||
|
||||
/**
|
||||
* @brief Configures a custom function to be used to check the validity of input when it is submitted in a software keyboard.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param callback Filter callback function.
|
||||
* @param user Custom data to be passed to the callback function.
|
||||
*/
|
||||
void swkbdSetFilterCallback(SwkbdState* swkbd, SwkbdCallbackFn callback, void* user);
|
||||
|
||||
/**
|
||||
* @brief Launches a software keyboard in order to input text.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @param buf Pointer to output buffer which will hold the inputted text.
|
||||
* @param bufsize Maximum number of UTF-8 code units that the buffer can hold (including null terminator).
|
||||
* @return The identifier of the dialog button that was pressed, or SWKBD_BUTTON_NONE if a different condition was triggered - in that case use swkbdGetResult to check the condition.
|
||||
*/
|
||||
SwkbdButton swkbdInputText(SwkbdState* swkbd, char* buf, size_t bufsize);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the result condition of a software keyboard after it has been used.
|
||||
* @param swkbd Pointer to swkbd state.
|
||||
* @return The result value.
|
||||
*/
|
||||
static inline SwkbdResult swkbdGetResult(SwkbdState* swkbd)
|
||||
{
|
||||
return swkbd->result;
|
||||
}
|
43
libctru/include/3ds/archive.h
Normal file
43
libctru/include/3ds/archive.h
Normal file
@ -0,0 +1,43 @@
|
||||
/**
|
||||
* @file archive.h
|
||||
* @brief FS_Archive driver
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/services/fs.h>
|
||||
|
||||
#define ARCHIVE_DIRITER_MAGIC 0x68637261 /* "arch" */
|
||||
|
||||
/*! Open directory struct */
|
||||
typedef struct
|
||||
{
|
||||
u32 magic; /*! "arch" */
|
||||
Handle fd; /*! CTRU handle */
|
||||
ssize_t index; /*! Current entry index */
|
||||
size_t size; /*! Current batch size */
|
||||
FS_DirectoryEntry entry_data[32]; /*! Temporary storage for reading entries */
|
||||
} archive_dir_t;
|
||||
|
||||
/// Mounts the SD
|
||||
Result archiveMountSdmc(void);
|
||||
|
||||
/// Mounts and opens an archive as deviceName
|
||||
/// Returns either an archive open error code, or -1 for generic failure
|
||||
Result archiveMount(FS_ArchiveID archiveID, FS_Path archivePath, const char *deviceName);
|
||||
|
||||
/// Uses FSUSER_ControlArchive with control action ARCHIVE_ACTION_COMMIT_SAVE_DATA on the opened archive. Not done automatically at unmount.
|
||||
/// Returns -1 if the specified device is not found
|
||||
Result archiveCommitSaveData(const char *deviceName);
|
||||
|
||||
/// Unmounts the specified device, closing its archive in the process
|
||||
/// Returns -1 if the specified device was not found
|
||||
Result archiveUnmount(const char *deviceName);
|
||||
|
||||
/// Unmounts all devices and cleans up any resources used by the driver
|
||||
Result archiveUnmountAll(void);
|
||||
|
||||
/// Get a file's mtime
|
||||
Result archive_getmtime(const char *name, u64 *mtime);
|
21
libctru/include/3ds/asminc.h
Normal file
21
libctru/include/3ds/asminc.h
Normal file
@ -0,0 +1,21 @@
|
||||
#pragma once
|
||||
|
||||
#if !__ASSEMBLER__
|
||||
#error This header file is only for use in assembly files!
|
||||
#endif // !__ASSEMBLER__
|
||||
|
||||
.macro BEGIN_ASM_FUNC name, linkage=global, section=text
|
||||
.section .\section\().\name, "ax", %progbits
|
||||
.align 2
|
||||
.\linkage \name
|
||||
.type \name, %function
|
||||
.func \name
|
||||
.cfi_sections .debug_frame
|
||||
.cfi_startproc
|
||||
\name:
|
||||
.endm
|
||||
|
||||
.macro END_ASM_FUNC
|
||||
.cfi_endproc
|
||||
.endfunc
|
||||
.endm
|
@ -1,160 +1,176 @@
|
||||
|
||||
|
||||
/*! \file console.h
|
||||
\brief 3ds stdio support.
|
||||
|
||||
<div class="fileHeader">
|
||||
Provides stdio integration for printing to the 3DS screen as well as debug print
|
||||
functionality provided by stderr.
|
||||
|
||||
General usage is to initialize the console by:
|
||||
consoleDemoInit()
|
||||
or to customize the console usage by:
|
||||
consoleInit()
|
||||
|
||||
*/
|
||||
|
||||
#ifndef CONSOLE_H
|
||||
#define CONSOLE_H
|
||||
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/gfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef bool(* ConsolePrint)(void* con, int c);
|
||||
|
||||
//! a font struct for the console.
|
||||
typedef struct ConsoleFont
|
||||
{
|
||||
u8* gfx; //!< A pointer to the font graphics
|
||||
u16 asciiOffset; //!< Offset to the first valid character in the font table
|
||||
u16 numChars; //!< Number of characters in the font graphics
|
||||
|
||||
}ConsoleFont;
|
||||
|
||||
/** \brief console structure used to store the state of a console render context.
|
||||
|
||||
Default values from consoleGetDefault();
|
||||
<div class="fixedFont"><pre>
|
||||
PrintConsole defaultConsole =
|
||||
{
|
||||
//Font:
|
||||
{
|
||||
(u8*)default_font_bin, //font gfx
|
||||
0, //first ascii character in the set
|
||||
128, //number of characters in the font set
|
||||
},
|
||||
0,0, //cursorX cursorY
|
||||
0,0, //prevcursorX prevcursorY
|
||||
40, //console width
|
||||
30, //console height
|
||||
0, //window x
|
||||
0, //window y
|
||||
32, //window width
|
||||
24, //window height
|
||||
3, //tab size
|
||||
0, //font character offset
|
||||
0, //print callback
|
||||
false //console initialized
|
||||
};
|
||||
</pre></div>
|
||||
*/
|
||||
typedef struct PrintConsole
|
||||
{
|
||||
ConsoleFont font; //!< font of the console.
|
||||
|
||||
u16 *frameBuffer; //!< framebuffer address.
|
||||
|
||||
int cursorX; /*!< Current X location of the cursor (as a tile offset by default) */
|
||||
int cursorY; /*!< Current Y location of the cursor (as a tile offset by default) */
|
||||
|
||||
int prevCursorX; /*!< Internal state */
|
||||
int prevCursorY; /*!< Internal state */
|
||||
|
||||
int consoleWidth; /*!< Width of the console hardware layer in characters */
|
||||
int consoleHeight; /*!< Height of the console hardware layer in characters */
|
||||
|
||||
int windowX; /*!< Window X location in characters (not implemented) */
|
||||
int windowY; /*!< Window Y location in characters (not implemented) */
|
||||
int windowWidth; /*!< Window width in characters (not implemented) */
|
||||
int windowHeight; /*!< Window height in characters (not implemented) */
|
||||
|
||||
int tabSize; /*!< Size of a tab*/
|
||||
int fg; /*!< foreground color*/
|
||||
int bg; /*!< background color*/
|
||||
int flags; /*!< reverse/bright flags*/
|
||||
|
||||
ConsolePrint PrintChar; /*!< callback for printing a character. Should return true if it has handled rendering the graphics
|
||||
(else the print engine will attempt to render via tiles) */
|
||||
|
||||
bool consoleInitialised; /*!< True if the console is initialized */
|
||||
}PrintConsole;
|
||||
|
||||
#define CONSOLE_COLOR_BOLD (1<<0)
|
||||
#define CONSOLE_COLOR_FAINT (1<<1)
|
||||
#define CONSOLE_ITALIC (1<<2)
|
||||
#define CONSOLE_UNDERLINE (1<<3)
|
||||
#define CONSOLE_BLINK_SLOW (1<<4)
|
||||
#define CONSOLE_BLINK_FAST (1<<5)
|
||||
#define CONSOLE_COLOR_REVERSE (1<<6)
|
||||
#define CONSOLE_CONCEAL (1<<7)
|
||||
#define CONSOLE_CROSSED_OUT (1<<8)
|
||||
|
||||
//! Console debug devices supported by libnds.
|
||||
typedef enum {
|
||||
debugDevice_NULL, //!< swallows prints to stderr
|
||||
debugDevice_3DMOO, //!< Directs stderr debug statements to 3dmoo
|
||||
debugDevice_CONSOLE, //!< Directs stderr debug statements to 3DS console window
|
||||
} debugDevice;
|
||||
|
||||
/*! \brief Loads the font into the console
|
||||
\param console pointer to the console to update, if NULL it will update the current console
|
||||
\param font the font to load
|
||||
*/
|
||||
void consoleSetFont(PrintConsole* console, ConsoleFont* font);
|
||||
|
||||
/*! \brief Sets the print window
|
||||
\param console console to set, if NULL it will set the current console window
|
||||
\param x x location of the window
|
||||
\param y y location of the window
|
||||
\param width width of the window
|
||||
\param height height of the window
|
||||
*/
|
||||
void consoleSetWindow(PrintConsole* console, int x, int y, int width, int height);
|
||||
|
||||
/*! \brief Gets a pointer to the console with the default values
|
||||
this should only be used when using a single console or without changing the console that is returned, other wise use consoleInit()
|
||||
\return A pointer to the console with the default values
|
||||
*/
|
||||
PrintConsole* consoleGetDefault(void);
|
||||
|
||||
/*! \brief Make the specified console the render target
|
||||
\param console A pointer to the console struct (must have been initialized with consoleInit(PrintConsole* console)
|
||||
\return a pointer to the previous console
|
||||
*/
|
||||
PrintConsole *consoleSelect(PrintConsole* console);
|
||||
|
||||
/*! \brief Initialise the console.
|
||||
\param screen The screen to use for the console
|
||||
\param console A pointer to the console data to initialze (if it's NULL, the default console will be used)
|
||||
\return A pointer to the current console.
|
||||
*/
|
||||
PrintConsole* consoleInit(gfxScreen_t screen, PrintConsole* console);
|
||||
|
||||
/*! \brief Initializes debug console output on stderr to the specified device
|
||||
\param device The debug device (or devices) to output debug print statements to
|
||||
*/
|
||||
void consoleDebugInit(debugDevice device);
|
||||
|
||||
|
||||
//! Clears the screan by using iprintf("\x1b[2J");
|
||||
void consoleClear(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
/**
|
||||
* @file console.h
|
||||
* @brief 3ds stdio support.
|
||||
*
|
||||
* Provides stdio integration for printing to the 3DS screen as well as debug print
|
||||
* functionality provided by stderr.
|
||||
*
|
||||
* General usage is to initialize the console by:
|
||||
* @code
|
||||
* consoleDemoInit()
|
||||
* @endcode
|
||||
* or to customize the console usage by:
|
||||
* @code
|
||||
* consoleInit()
|
||||
* @endcode
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/gfx.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define CONSOLE_ESC(x) "\x1b[" #x
|
||||
#define CONSOLE_RESET CONSOLE_ESC(0m)
|
||||
#define CONSOLE_BLACK CONSOLE_ESC(30m)
|
||||
#define CONSOLE_RED CONSOLE_ESC(31;1m)
|
||||
#define CONSOLE_GREEN CONSOLE_ESC(32;1m)
|
||||
#define CONSOLE_YELLOW CONSOLE_ESC(33;1m)
|
||||
#define CONSOLE_BLUE CONSOLE_ESC(34;1m)
|
||||
#define CONSOLE_MAGENTA CONSOLE_ESC(35;1m)
|
||||
#define CONSOLE_CYAN CONSOLE_ESC(36;1m)
|
||||
#define CONSOLE_WHITE CONSOLE_ESC(37;1m)
|
||||
|
||||
/// A callback for printing a character.
|
||||
typedef bool(*ConsolePrint)(void* con, int c);
|
||||
|
||||
/// A font struct for the console.
|
||||
typedef struct ConsoleFont
|
||||
{
|
||||
u8* gfx; ///< A pointer to the font graphics
|
||||
u16 asciiOffset; ///< Offset to the first valid character in the font table
|
||||
u16 numChars; ///< Number of characters in the font graphics
|
||||
}ConsoleFont;
|
||||
|
||||
/**
|
||||
* @brief Console structure used to store the state of a console render context.
|
||||
*
|
||||
* Default values from consoleGetDefault();
|
||||
* @code
|
||||
* PrintConsole defaultConsole =
|
||||
* {
|
||||
* //Font:
|
||||
* {
|
||||
* (u8*)default_font_bin, //font gfx
|
||||
* 0, //first ascii character in the set
|
||||
* 128, //number of characters in the font set
|
||||
* },
|
||||
* 0,0, //cursorX cursorY
|
||||
* 0,0, //prevcursorX prevcursorY
|
||||
* 40, //console width
|
||||
* 30, //console height
|
||||
* 0, //window x
|
||||
* 0, //window y
|
||||
* 32, //window width
|
||||
* 24, //window height
|
||||
* 3, //tab size
|
||||
* 0, //font character offset
|
||||
* 0, //print callback
|
||||
* false //console initialized
|
||||
* };
|
||||
* @endcode
|
||||
*/
|
||||
typedef struct PrintConsole
|
||||
{
|
||||
ConsoleFont font; ///< Font of the console
|
||||
|
||||
u16 *frameBuffer; ///< Framebuffer address
|
||||
|
||||
int cursorX; ///< Current X location of the cursor (as a tile offset by default)
|
||||
int cursorY; ///< Current Y location of the cursor (as a tile offset by default)
|
||||
|
||||
int prevCursorX; ///< Internal state
|
||||
int prevCursorY; ///< Internal state
|
||||
|
||||
int consoleWidth; ///< Width of the console hardware layer in characters
|
||||
int consoleHeight; ///< Height of the console hardware layer in characters
|
||||
|
||||
int windowX; ///< Window X location in characters (not implemented)
|
||||
int windowY; ///< Window Y location in characters (not implemented)
|
||||
int windowWidth; ///< Window width in characters (not implemented)
|
||||
int windowHeight; ///< Window height in characters (not implemented)
|
||||
|
||||
int tabSize; ///< Size of a tab
|
||||
u16 fg; ///< Foreground color
|
||||
u16 bg; ///< Background color
|
||||
int flags; ///< Reverse/bright flags
|
||||
|
||||
ConsolePrint PrintChar; ///< Callback for printing a character. Should return true if it has handled rendering the graphics (else the print engine will attempt to render via tiles).
|
||||
|
||||
bool consoleInitialised; ///< True if the console is initialized
|
||||
}PrintConsole;
|
||||
|
||||
#define CONSOLE_COLOR_BOLD (1<<0) ///< Bold text
|
||||
#define CONSOLE_COLOR_FAINT (1<<1) ///< Faint text
|
||||
#define CONSOLE_ITALIC (1<<2) ///< Italic text
|
||||
#define CONSOLE_UNDERLINE (1<<3) ///< Underlined text
|
||||
#define CONSOLE_BLINK_SLOW (1<<4) ///< Slow blinking text
|
||||
#define CONSOLE_BLINK_FAST (1<<5) ///< Fast blinking text
|
||||
#define CONSOLE_COLOR_REVERSE (1<<6) ///< Reversed color text
|
||||
#define CONSOLE_CONCEAL (1<<7) ///< Concealed text
|
||||
#define CONSOLE_CROSSED_OUT (1<<8) ///< Crossed out text
|
||||
#define CONSOLE_FG_CUSTOM (1<<9) ///< Foreground custom color
|
||||
#define CONSOLE_BG_CUSTOM (1<<10) ///< Background custom color
|
||||
|
||||
/// Console debug devices supported by libnds.
|
||||
typedef enum {
|
||||
debugDevice_NULL, ///< Swallows prints to stderr
|
||||
debugDevice_SVC, ///< Outputs stderr debug statements using svcOutputDebugString, which can then be captured by interactive debuggers
|
||||
debugDevice_CONSOLE, ///< Directs stderr debug statements to 3DS console window
|
||||
debugDevice_3DMOO = debugDevice_SVC,
|
||||
} debugDevice;
|
||||
|
||||
/**
|
||||
* @brief Loads the font into the console.
|
||||
* @param console Pointer to the console to update, if NULL it will update the current console.
|
||||
* @param font The font to load.
|
||||
*/
|
||||
void consoleSetFont(PrintConsole* console, ConsoleFont* font);
|
||||
|
||||
/**
|
||||
* @brief Sets the print window.
|
||||
* @param console Console to set, if NULL it will set the current console window.
|
||||
* @param x X location of the window.
|
||||
* @param y Y location of the window.
|
||||
* @param width Width of the window.
|
||||
* @param height Height of the window.
|
||||
*/
|
||||
void consoleSetWindow(PrintConsole* console, int x, int y, int width, int height);
|
||||
|
||||
/**
|
||||
* @brief Gets a pointer to the console with the default values.
|
||||
* This should only be used when using a single console or without changing the console that is returned, otherwise use consoleInit().
|
||||
* @return A pointer to the console with the default values.
|
||||
*/
|
||||
PrintConsole* consoleGetDefault(void);
|
||||
|
||||
/**
|
||||
* @brief Make the specified console the render target.
|
||||
* @param console A pointer to the console struct (must have been initialized with consoleInit(PrintConsole* console)).
|
||||
* @return A pointer to the previous console.
|
||||
*/
|
||||
PrintConsole *consoleSelect(PrintConsole* console);
|
||||
|
||||
/**
|
||||
* @brief Initialise the console.
|
||||
* @param screen The screen to use for the console.
|
||||
* @param console A pointer to the console data to initialize (if it's NULL, the default console will be used).
|
||||
* @return A pointer to the current console.
|
||||
*/
|
||||
PrintConsole* consoleInit(gfxScreen_t screen, PrintConsole* console);
|
||||
|
||||
/**
|
||||
* @brief Initializes debug console output on stderr to the specified device.
|
||||
* @param device The debug device (or devices) to output debug print statements to.
|
||||
*/
|
||||
void consoleDebugInit(debugDevice device);
|
||||
|
||||
/// Clears the screen by using iprintf("\x1b[2J");
|
||||
void consoleClear(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
73
libctru/include/3ds/env.h
Normal file
73
libctru/include/3ds/env.h
Normal file
@ -0,0 +1,73 @@
|
||||
/**
|
||||
* @file env.h
|
||||
* @brief Homebrew environment information.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/// System run-flags.
|
||||
enum {
|
||||
RUNFLAG_APTWORKAROUND = BIT(0), ///< Use APT workaround.
|
||||
RUNFLAG_APTREINIT = BIT(1), ///< Reinitialize APT.
|
||||
RUNFLAG_APTCHAINLOAD = BIT(2), ///< Chainload APT on return.
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Gets whether the application was launched from a homebrew environment.
|
||||
* @return Whether the application was launched from a homebrew environment.
|
||||
*/
|
||||
static inline bool envIsHomebrew(void) {
|
||||
extern void* __service_ptr;
|
||||
return __service_ptr != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieves a handle from the environment handle list.
|
||||
* @param name Name of the handle.
|
||||
* @return The retrieved handle.
|
||||
*/
|
||||
Handle envGetHandle(const char* name);
|
||||
|
||||
/**
|
||||
* @brief Gets the environment-recommended app ID to use with APT.
|
||||
* @return The APT app ID.
|
||||
*/
|
||||
static inline u32 envGetAptAppId(void) {
|
||||
extern u32 __apt_appid;
|
||||
return __apt_appid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the size of the application heap.
|
||||
* @return The application heap size.
|
||||
*/
|
||||
static inline u32 envGetHeapSize(void) {
|
||||
extern u32 __ctru_heap_size;
|
||||
return __ctru_heap_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the size of the linear heap.
|
||||
* @return The linear heap size.
|
||||
*/
|
||||
static inline u32 envGetLinearHeapSize(void) {
|
||||
extern u32 __ctru_linear_heap_size;
|
||||
return __ctru_linear_heap_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the environment argument list.
|
||||
* @return The argument list.
|
||||
*/
|
||||
static inline const char* envGetSystemArgList(void) {
|
||||
extern const char* __system_arglist;
|
||||
return __system_arglist;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the environment run flags.
|
||||
* @return The run flags.
|
||||
*/
|
||||
static inline u32 envGetSystemRunFlags(void) {
|
||||
extern u32 __system_runflags;
|
||||
return __system_runflags;
|
||||
}
|
137
libctru/include/3ds/errf.h
Normal file
137
libctru/include/3ds/errf.h
Normal file
@ -0,0 +1,137 @@
|
||||
/**
|
||||
* @file errf.h
|
||||
* @brief Error Display API
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
/// Types of errors that can be thrown by err:f.
|
||||
typedef enum {
|
||||
ERRF_ERRTYPE_GENERIC = 0, ///< Generic fatal error. Shows miscellaneous info, including the address of the caller
|
||||
ERRF_ERRTYPE_NAND_DAMAGED = 1, ///< Damaged NAND (CC_ERROR after reading CSR)
|
||||
ERRF_ERRTYPE_CARD_REMOVED = 2, ///< Game content storage medium (cartridge and/or SD card) ejected. Not logged
|
||||
ERRF_ERRTYPE_EXCEPTION = 3, ///< CPU or VFP exception
|
||||
ERRF_ERRTYPE_FAILURE = 4, ///< Fatal error with a message instead of the caller's address
|
||||
ERRF_ERRTYPE_LOG_ONLY = 5, ///< Log-level failure. Does not display the exception and does not force the system to reboot
|
||||
} ERRF_ErrType;
|
||||
|
||||
/// Types of 'Exceptions' thrown for ERRF_ERRTYPE_EXCEPTION
|
||||
typedef enum {
|
||||
ERRF_EXCEPTION_PREFETCH_ABORT = 0, ///< Prefetch Abort
|
||||
ERRF_EXCEPTION_DATA_ABORT = 1, ///< Data abort
|
||||
ERRF_EXCEPTION_UNDEFINED = 2, ///< Undefined instruction
|
||||
ERRF_EXCEPTION_VFP = 3, ///< VFP (floating point) exception.
|
||||
} ERRF_ExceptionType;
|
||||
|
||||
typedef struct {
|
||||
ERRF_ExceptionType type; ///< Type of the exception. One of the ERRF_EXCEPTION_* values.
|
||||
u8 reserved[3];
|
||||
u32 fsr; ///< ifsr (prefetch abort) / dfsr (data abort)
|
||||
u32 far; ///< pc = ifar (prefetch abort) / dfar (data abort)
|
||||
u32 fpexc;
|
||||
u32 fpinst;
|
||||
u32 fpinst2;
|
||||
} ERRF_ExceptionInfo;
|
||||
|
||||
typedef struct {
|
||||
ERRF_ExceptionInfo excep; ///< Exception info struct
|
||||
CpuRegisters regs; ///< CPU register dump.
|
||||
} ERRF_ExceptionData;
|
||||
|
||||
typedef struct {
|
||||
ERRF_ErrType type; ///< Type, one of the ERRF_ERRTYPE_* enum
|
||||
u8 revHigh; ///< High revison ID
|
||||
u16 revLow; ///< Low revision ID
|
||||
u32 resCode; ///< Result code
|
||||
u32 pcAddr; ///< PC address at exception
|
||||
u32 procId; ///< Process ID of the caller
|
||||
u64 titleId; ///< Title ID of the caller
|
||||
u64 appTitleId; ///< Title ID of the running application
|
||||
union {
|
||||
ERRF_ExceptionData exception_data; ///< Data for when type is ERRF_ERRTYPE_EXCEPTION
|
||||
char failure_mesg[0x60]; ///< String for when type is ERRF_ERRTYPE_FAILURE
|
||||
} data; ///< The different types of data for errors.
|
||||
} ERRF_FatalErrInfo;
|
||||
|
||||
/// Initializes ERR:f. Unless you plan to call ERRF_Throw yourself, do not use this.
|
||||
Result errfInit(void);
|
||||
|
||||
/// Exits ERR:f. Unless you plan to call ERRF_Throw yourself, do not use this.
|
||||
void errfExit(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the current err:f API session handle.
|
||||
* @return The current err:f API session handle.
|
||||
*/
|
||||
Handle *errfGetSessionHandle(void);
|
||||
|
||||
/**
|
||||
* @brief Throws a system error and possibly logs it.
|
||||
* @param[in] error Error to throw.
|
||||
*
|
||||
* ErrDisp may convert the error info to \ref ERRF_ERRTYPE_NAND_DAMAGED or \ref ERRF_ERRTYPE_CARD_REMOVED
|
||||
* depending on the error code.
|
||||
*
|
||||
* Except with \ref ERRF_ERRTYPE_LOG_ONLY, the system will panic and will need to be rebooted.
|
||||
* Fatal error information will also be logged into a file, unless the type either \ref ERRF_ERRTYPE_NAND_DAMAGED
|
||||
* or \ref ERRF_ERRTYPE_CARD_REMOVED.
|
||||
*
|
||||
* No error will be shown if the system is asleep.
|
||||
*
|
||||
* On retail units with vanilla firmware, no detailed information will be displayed on screen.
|
||||
*
|
||||
* You may wish to use ERRF_ThrowResult() or ERRF_ThrowResultWithMessage() instead of
|
||||
* constructing the ERRF_FatalErrInfo struct yourself.
|
||||
*/
|
||||
Result ERRF_Throw(const ERRF_FatalErrInfo* error);
|
||||
|
||||
/**
|
||||
* @brief Throws (and logs) a system error with the given Result code.
|
||||
* @param[in] failure Result code to throw.
|
||||
*
|
||||
* This calls \ref ERRF_Throw with error type \ref ERRF_ERRTYPE_GENERIC and fills in the required data.
|
||||
*
|
||||
* This function \em does fill in the address where this function was called from.
|
||||
*/
|
||||
Result ERRF_ThrowResult(Result failure);
|
||||
|
||||
/**
|
||||
* @brief Logs a system error with the given Result code.
|
||||
* @param[in] failure Result code to log.
|
||||
*
|
||||
* Similar to \ref ERRF_Throw, except that it does not display anything on the screen,
|
||||
* nor does it force the system to reboot.
|
||||
*
|
||||
* This function \em does fill in the address where this function was called from.
|
||||
*/
|
||||
Result ERRF_LogResult(Result failure);
|
||||
|
||||
/**
|
||||
* @brief Throws a system error with the given Result code and message.
|
||||
* @param[in] failure Result code to throw.
|
||||
* @param[in] message The message to display.
|
||||
*
|
||||
* This calls \ref ERRF_Throw with error type \ref ERRF_ERRTYPE_FAILURE and fills in the required data.
|
||||
*
|
||||
* This function does \em not fill in the address where this function was called from because it
|
||||
* would not be displayed.
|
||||
*/
|
||||
Result ERRF_ThrowResultWithMessage(Result failure, const char* message);
|
||||
|
||||
/**
|
||||
* @brief Specify an additional user string to use for error reporting.
|
||||
* @param[in] user_string User string (up to 256 bytes, not including NUL byte)
|
||||
*/
|
||||
Result ERRF_SetUserString(const char* user_string);
|
||||
|
||||
/**
|
||||
* @brief Handles an exception using ErrDisp.
|
||||
* @param excep Exception information
|
||||
* @param regs CPU registers
|
||||
*
|
||||
* You might want to clear ENVINFO's bit0 to be able to see any debugging information.
|
||||
* @sa threadOnException
|
||||
*/
|
||||
void ERRF_ExceptionHandler(ERRF_ExceptionInfo* excep, CpuRegisters* regs) __attribute__((noreturn));
|
199
libctru/include/3ds/exheader.h
Normal file
199
libctru/include/3ds/exheader.h
Normal file
@ -0,0 +1,199 @@
|
||||
/**
|
||||
* @file exheader.h
|
||||
* @brief NCCH extended header definitions.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
/// ARM9 descriptor flags
|
||||
enum
|
||||
{
|
||||
ARM9DESC_MOUNT_NAND = BIT(0), ///< Mount "nand:/"
|
||||
ARM9DESC_MOUNT_NANDRO_RW = BIT(1), ///< Mount nand:/ro/ as read-write
|
||||
ARM9DESC_MOUNT_TWLN = BIT(2), ///< Mount "twln:/"
|
||||
ARM9DESC_MOUNT_WNAND = BIT(3), ///< Mount "wnand:/"
|
||||
ARM9DESC_MOUNT_CARDSPI = BIT(4), ///< Mount "cardspi:/"
|
||||
ARM9DESC_USE_SDIF3 = BIT(5), ///< Use SDIF3
|
||||
ARM9DESC_CREATE_SEED = BIT(6), ///< Create seed (movable.sed)
|
||||
ARM9DESC_USE_CARD_SPI = BIT(7), ///< Use card SPI, required by multiple pxi:dev commands
|
||||
ARM9DESC_SD_APPLICATION = BIT(8), ///< SD application (not checked)
|
||||
ARM9DESC_MOUNT_SDMC_RW = BIT(9), ///< Mount "sdmc:/" as read-write
|
||||
};
|
||||
|
||||
/// Filesystem access flags
|
||||
enum
|
||||
{
|
||||
FSACCESS_CATEGORY_SYSTEM_APPLICATION = BIT(0), ///< Category "system application"
|
||||
FSACCESS_CATEGORY_HARDWARE_CHECK = BIT(1), ///< Category "hardware check"
|
||||
FSACCESS_CATEGORY_FILESYSTEM_TOOL = BIT(2), ///< Category "filesystem tool"
|
||||
FSACCESS_DEBUG = BIT(3), ///< Debug
|
||||
FSACCESS_TWLCARD_BACKUP = BIT(4), ///< TWLCARD backup
|
||||
FSACCESS_TWLNAND_DATA = BIT(5), ///< TWLNAND data
|
||||
FSACCESS_BOSS = BIT(6), ///< BOSS (SpotPass)
|
||||
FSACCESS_SDMC_RW = BIT(7), ///< SDMC (read-write)
|
||||
FSACCESS_CORE = BIT(8), ///< Core
|
||||
FSACCESS_NANDRO_RO = BIT(9), ///< nand:/ro/ (read-only)
|
||||
FSACCESS_NANDRW = BIT(10), ///< nand:/rw/
|
||||
FSACCESS_NANDRO_RW = BIT(11), ///< nand:/ro/ (read-write)
|
||||
FSACCESS_CATEGORY_SYSTEM_SETTINGS = BIT(12), ///< Category "System Settings"
|
||||
FSACCESS_CARDBOARD = BIT(13), ///< Cardboard (System Transfer)
|
||||
FSACCESS_EXPORT_IMPORT_IVS = BIT(14), ///< Export/Import IVs (movable.sed)
|
||||
FSACCESS_SDMC_WO = BIT(15), ///< SDMC (write-only)
|
||||
FSACCESS_SWITCH_CLEANUP = BIT(16), ///< "Switch cleanup" (3.0+)
|
||||
FSACCESS_SAVEDATA_MOVE = BIT(17), ///< Savedata move (5.0+)
|
||||
FSACCESS_SHOP = BIT(18), ///< Shop (5.0+)
|
||||
FSACCESS_SHELL = BIT(19), ///< Shop (5.0+)
|
||||
FSACCESS_CATEGORY_HOME_MENU = BIT(20), ///< Category "Home Menu" (6.0+)
|
||||
FSACCESS_SEEDDB = BIT(21), ///< Seed DB (9.6+)
|
||||
};
|
||||
|
||||
/// The resource limit category of a title
|
||||
typedef enum
|
||||
{
|
||||
RESLIMIT_CATEGORY_APPLICATION = 0, ///< Regular application
|
||||
RESLIMIT_CATEGORY_SYS_APPLET = 1, ///< System applet
|
||||
RESLIMIT_CATEGORY_LIB_APPLET = 2, ///< Library applet
|
||||
RESLIMIT_CATEGORY_OTHER = 3, ///< System modules running inside the BASE memregion
|
||||
} ResourceLimitCategory;
|
||||
|
||||
/// The system mode a title should be launched under
|
||||
typedef enum
|
||||
{
|
||||
SYSMODE_O3DS_PROD = 0, ///< 64MB of usable application memory
|
||||
SYSMODE_N3DS_PROD = 1, ///< 124MB of usable application memory. Unusable on O3DS
|
||||
SYSMODE_DEV1 = 2, ///< 97MB/178MB of usable application memory
|
||||
SYSMODE_DEV2 = 3, ///< 80MB/124MB of usable application memory
|
||||
SYSMODE_DEV3 = 4, ///< 72MB of usable application memory. Same as "Prod" on N3DS
|
||||
SYSMODE_DEV4 = 5, ///< 32MB of usable application memory. Same as "Prod" on N3DS
|
||||
} SystemMode;
|
||||
|
||||
|
||||
/// The system info flags and remaster version of a title
|
||||
typedef struct
|
||||
{
|
||||
u8 reserved[5]; ///< Reserved
|
||||
bool compress_exefs_code : 1; ///< Whether the ExeFS's .code section is compressed
|
||||
bool is_sd_application : 1; ///< Whether the title is meant to be used on an SD card
|
||||
u16 remaster_version; ///< Remaster version
|
||||
} ExHeader_SystemInfoFlags;
|
||||
|
||||
/// Information about a title's section
|
||||
typedef struct
|
||||
{
|
||||
u32 address; ///< The address of the section
|
||||
u32 num_pages; ///< The number of pages the section occupies
|
||||
u32 size; ///< The size of the section
|
||||
} ExHeader_CodeSectionInfo;
|
||||
|
||||
/// The name of a title and infomation about its section
|
||||
typedef struct
|
||||
{
|
||||
char name[8]; ///< Title name
|
||||
ExHeader_SystemInfoFlags flags; ///< System info flags, see @ref ExHeader_SystemInfoFlags
|
||||
ExHeader_CodeSectionInfo text; ///< .text section info, see @ref ExHeader_CodeSectionInfo
|
||||
u32 stack_size; ///< Stack size
|
||||
ExHeader_CodeSectionInfo rodata; ///< .rodata section info, see @ref ExHeader_CodeSectionInfo
|
||||
u32 reserved; ///< Reserved
|
||||
ExHeader_CodeSectionInfo data; ///< .data section info, see @ref ExHeader_CodeSectionInfo
|
||||
u32 bss_size; ///< .bss section size
|
||||
} ExHeader_CodeSetInfo;
|
||||
|
||||
/// The savedata size and jump ID of a title
|
||||
typedef struct
|
||||
{
|
||||
u64 savedata_size; ///< Savedata size
|
||||
u64 jump_id; ///< Jump ID
|
||||
u8 reserved[0x30]; ///< Reserved
|
||||
} ExHeader_SystemInfo;
|
||||
|
||||
/// The code set info, dependencies and system info of a title (SCI)
|
||||
typedef struct
|
||||
{
|
||||
ExHeader_CodeSetInfo codeset_info; ///< Code set info, see @ref ExHeader_CodeSetInfo
|
||||
u64 dependencies[48]; ///< Title IDs of the titles that this program depends on
|
||||
ExHeader_SystemInfo system_info; ///< System info, see @ref ExHeader_SystemInfo
|
||||
} ExHeader_SystemControlInfo;
|
||||
|
||||
/// The ARM11 filesystem info of a title
|
||||
typedef struct
|
||||
{
|
||||
u64 extdata_id; ///< Extdata ID
|
||||
u32 system_savedata_ids[2]; ///< IDs of the system savedata accessible by the title
|
||||
u64 accessible_savedata_ids; ///< IDs of the savedata accessible by the title, 20 bits each, followed by "Use other variation savedata"
|
||||
u32 fs_access_info; ///< FS access flags
|
||||
u32 reserved : 24; ///< Reserved
|
||||
bool no_romfs : 1; ///< Don't use any RomFS
|
||||
bool use_extended_savedata_access : 1; ///< Use the "extdata_id" field to store 3 additional accessible savedata IDs
|
||||
} ExHeader_Arm11StorageInfo;
|
||||
|
||||
/// The CPU-related and memory-layout-related info of a title
|
||||
typedef struct
|
||||
{
|
||||
u32 core_version; ///< The low title ID of the target firmware
|
||||
bool use_cpu_clockrate_804MHz : 1; ///< Whether to start the title with the 804MHz clock rate
|
||||
bool enable_l2c : 1; ///< Whether to start the title with the L2C-310 enabled enabled
|
||||
u8 flag1_unused : 6; ///< Unused
|
||||
SystemMode n3ds_system_mode : 4; ///< The system mode to use on N3DS
|
||||
u8 flag2_unused : 4; ///< Unused
|
||||
u8 ideal_processor : 2; ///< The ideal processor to start the title on
|
||||
u8 affinity_mask : 2; ///< The affinity mask of the title
|
||||
SystemMode o3ds_system_mode : 4; ///< The system mode to use on N3DS
|
||||
u8 priority; ///< The priority of the title's main thread
|
||||
} ExHeader_Arm11CoreInfo;
|
||||
|
||||
/// The ARM11 system-local capabilities of a title
|
||||
typedef struct
|
||||
{
|
||||
u64 title_id; ///< Title ID
|
||||
ExHeader_Arm11CoreInfo core_info; ///< Core info, see @ref ExHeader_Arm11CoreInfo
|
||||
u16 reslimits[16]; ///< Resource limit descriptors, only "CpuTime" (first byte) sems to be used
|
||||
ExHeader_Arm11StorageInfo storage_info; ///< Storage info, see @ref ExHeader_Arm11StorageInfo
|
||||
char service_access[34][8]; ///< List of the services the title has access to. Limited to 32 prior to system version 9.3
|
||||
u8 reserved[15]; ///< Reserved
|
||||
ResourceLimitCategory reslimit_category; ///< Resource limit category, see @ref ExHeader_Arm11SystemLocalCapabilities
|
||||
} ExHeader_Arm11SystemLocalCapabilities;
|
||||
|
||||
/// The ARM11 kernel capabilities of a title
|
||||
typedef struct
|
||||
{
|
||||
u32 descriptors[28]; ///< ARM11 kernel descriptors, see 3dbrew
|
||||
u8 reserved[16]; ///< Reserved
|
||||
} ExHeader_Arm11KernelCapabilities;
|
||||
|
||||
/// The ARM9 access control of a title
|
||||
typedef struct
|
||||
{
|
||||
u8 descriptors[15]; ///< Process9 FS descriptors, see 3dbrew
|
||||
u8 descriptor_version; ///< Descriptor version
|
||||
} ExHeader_Arm9AccessControl;
|
||||
|
||||
/// The access control information of a title
|
||||
typedef struct
|
||||
{
|
||||
ExHeader_Arm11SystemLocalCapabilities local_caps; ///< ARM11 system-local capabilities, see @ref ExHeader_Arm11SystemLocalCapabilities
|
||||
ExHeader_Arm11KernelCapabilities kernel_caps; ///< ARM11 kernel capabilities, see @ref ExHeader_Arm11SystemLocalCapabilities
|
||||
ExHeader_Arm9AccessControl access_control; ///< ARM9 access control, see @ref ExHeader_Arm9AccessControl
|
||||
} ExHeader_AccessControlInfo;
|
||||
|
||||
/// Main extended header data, as returned by PXIPM, Loader and FSREG service commands
|
||||
typedef struct
|
||||
{
|
||||
ExHeader_SystemControlInfo sci; ///< System control info, see @ref ExHeader_SystemControlInfo
|
||||
ExHeader_AccessControlInfo aci; ///< Access control info, see @ref ExHeader_AccessControlInfo
|
||||
} ExHeader_Info;
|
||||
|
||||
/// Extended header access descriptor
|
||||
typedef struct
|
||||
{
|
||||
u8 signature[0x100]; ///< The signature of the access descriptor (RSA-2048-SHA256)
|
||||
u8 ncchModulus[0x100]; ///< The modulus used for the above signature, with 65537 as public exponent
|
||||
ExHeader_AccessControlInfo acli; ///< This is compared for equality with the first ACI by Process9, see @ref ExHeader_AccessControlInfo
|
||||
} ExHeader_AccessDescriptor;
|
||||
|
||||
/// The NCCH Extended Header of a title
|
||||
typedef struct
|
||||
{
|
||||
ExHeader_Info info; ///< Main extended header data, see @ref ExHeader_Info
|
||||
ExHeader_AccessDescriptor access_descriptor; ///< Access descriptor, see @ref ExHeader_AccessDescriptor
|
||||
} ExHeader;
|
236
libctru/include/3ds/font.h
Normal file
236
libctru/include/3ds/font.h
Normal file
@ -0,0 +1,236 @@
|
||||
/**
|
||||
* @file font.h
|
||||
* @brief Shared font support.
|
||||
*/
|
||||
#pragma once
|
||||
#include <3ds/types.h>
|
||||
|
||||
///@name Data types
|
||||
///@{
|
||||
|
||||
/// Character width information structure.
|
||||
typedef struct
|
||||
{
|
||||
s8 left; ///< Horizontal offset to draw the glyph with.
|
||||
u8 glyphWidth; ///< Width of the glyph.
|
||||
u8 charWidth; ///< Width of the character, that is, horizontal distance to advance.
|
||||
} charWidthInfo_s;
|
||||
|
||||
/// Font texture sheet information.
|
||||
typedef struct
|
||||
{
|
||||
u8 cellWidth; ///< Width of a glyph cell.
|
||||
u8 cellHeight; ///< Height of a glyph cell.
|
||||
u8 baselinePos; ///< Vertical position of the baseline.
|
||||
u8 maxCharWidth; ///< Maximum character width.
|
||||
|
||||
u32 sheetSize; ///< Size in bytes of a texture sheet.
|
||||
u16 nSheets; ///< Number of texture sheets.
|
||||
u16 sheetFmt; ///< GPU texture format (GPU_TEXCOLOR).
|
||||
|
||||
u16 nRows; ///< Number of glyphs per row per sheet.
|
||||
u16 nLines; ///< Number of glyph rows per sheet.
|
||||
|
||||
u16 sheetWidth; ///< Texture sheet width.
|
||||
u16 sheetHeight; ///< Texture sheet height.
|
||||
u8* sheetData; ///< Pointer to texture sheet data.
|
||||
} TGLP_s;
|
||||
|
||||
/// Font character width information block type.
|
||||
typedef struct tag_CWDH_s CWDH_s;
|
||||
|
||||
/// Font character width information block structure.
|
||||
struct tag_CWDH_s
|
||||
{
|
||||
u16 startIndex; ///< First Unicode codepoint the block applies to.
|
||||
u16 endIndex; ///< Last Unicode codepoint the block applies to.
|
||||
CWDH_s* next; ///< Pointer to the next block.
|
||||
|
||||
charWidthInfo_s widths[0]; ///< Table of character width information structures.
|
||||
};
|
||||
|
||||
/// Font character map methods.
|
||||
enum
|
||||
{
|
||||
CMAP_TYPE_DIRECT = 0, ///< Identity mapping.
|
||||
CMAP_TYPE_TABLE = 1, ///< Mapping using a table.
|
||||
CMAP_TYPE_SCAN = 2, ///< Mapping using a list of mapped characters.
|
||||
};
|
||||
|
||||
/// Font character map type.
|
||||
typedef struct tag_CMAP_s CMAP_s;
|
||||
|
||||
/// Font character map structure.
|
||||
struct tag_CMAP_s
|
||||
{
|
||||
u16 codeBegin; ///< First Unicode codepoint the block applies to.
|
||||
u16 codeEnd; ///< Last Unicode codepoint the block applies to.
|
||||
u16 mappingMethod; ///< Mapping method.
|
||||
u16 reserved;
|
||||
CMAP_s* next; ///< Pointer to the next map.
|
||||
|
||||
union
|
||||
{
|
||||
u16 indexOffset; ///< For CMAP_TYPE_DIRECT: index of the first glyph.
|
||||
u16 indexTable[0]; ///< For CMAP_TYPE_TABLE: table of glyph indices.
|
||||
/// For CMAP_TYPE_SCAN: Mapping data.
|
||||
struct
|
||||
{
|
||||
u16 nScanEntries; ///< Number of pairs.
|
||||
/// Mapping pairs.
|
||||
struct
|
||||
{
|
||||
u16 code; ///< Unicode codepoint.
|
||||
u16 glyphIndex; ///< Mapped glyph index.
|
||||
} scanEntries[0];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
/// Font information structure.
|
||||
typedef struct
|
||||
{
|
||||
u32 signature; ///< Signature (FINF).
|
||||
u32 sectionSize; ///< Section size.
|
||||
|
||||
u8 fontType; ///< Font type
|
||||
u8 lineFeed; ///< Line feed vertical distance.
|
||||
u16 alterCharIndex; ///< Glyph index of the replacement character.
|
||||
charWidthInfo_s defaultWidth; ///< Default character width information.
|
||||
u8 encoding; ///< Font encoding (?)
|
||||
|
||||
TGLP_s* tglp; ///< Pointer to texture sheet information.
|
||||
CWDH_s* cwdh; ///< Pointer to the first character width information block.
|
||||
CMAP_s* cmap; ///< Pointer to the first character map.
|
||||
|
||||
u8 height; ///< Font height.
|
||||
u8 width; ///< Font width.
|
||||
u8 ascent; ///< Font ascent.
|
||||
u8 padding;
|
||||
} FINF_s;
|
||||
|
||||
/// Font structure.
|
||||
typedef struct
|
||||
{
|
||||
u32 signature; ///< Signature (CFNU).
|
||||
u16 endianness; ///< Endianness constant (0xFEFF).
|
||||
u16 headerSize; ///< Header size.
|
||||
u32 version; ///< Format version.
|
||||
u32 fileSize; ///< File size.
|
||||
u32 nBlocks; ///< Number of blocks.
|
||||
|
||||
FINF_s finf; ///< Font information.
|
||||
} CFNT_s;
|
||||
|
||||
/// Font glyph position structure.
|
||||
typedef struct
|
||||
{
|
||||
int sheetIndex; ///< Texture sheet index to use to render the glyph.
|
||||
float xOffset; ///< Horizontal offset to draw the glyph width.
|
||||
float xAdvance; ///< Horizontal distance to advance after drawing the glyph.
|
||||
float width; ///< Glyph width.
|
||||
/// Texture coordinates to use to render the glyph.
|
||||
struct
|
||||
{
|
||||
float left, top, right, bottom;
|
||||
} texcoord;
|
||||
/// Vertex coordinates to use to render the glyph.
|
||||
struct
|
||||
{
|
||||
float left, top, right, bottom;
|
||||
} vtxcoord;
|
||||
} fontGlyphPos_s;
|
||||
|
||||
/// Flags for use with fontCalcGlyphPos.
|
||||
enum
|
||||
{
|
||||
GLYPH_POS_CALC_VTXCOORD = BIT(0), ///< Calculates vertex coordinates in addition to texture coordinates.
|
||||
GLYPH_POS_AT_BASELINE = BIT(1), ///< Position the glyph at the baseline instead of at the top-left corner.
|
||||
GLYPH_POS_Y_POINTS_UP = BIT(2), ///< Indicates that the Y axis points up instead of down.
|
||||
};
|
||||
|
||||
///@}
|
||||
|
||||
///@name Initialization and basic operations
|
||||
///@{
|
||||
|
||||
/// Ensures the shared system font is mapped.
|
||||
Result fontEnsureMapped(void);
|
||||
|
||||
/**
|
||||
* @brief Fixes the pointers internal to a just-loaded font
|
||||
* @param font Font to fix
|
||||
* @remark Should never be run on the system font, and only once on any other font.
|
||||
*/
|
||||
void fontFixPointers(CFNT_s* font);
|
||||
|
||||
/// Gets the currently loaded system font
|
||||
static inline CFNT_s* fontGetSystemFont(void)
|
||||
{
|
||||
extern CFNT_s* g_sharedFont;
|
||||
if (!g_sharedFont)
|
||||
fontEnsureMapped();
|
||||
return g_sharedFont;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieves the font information structure of a font.
|
||||
* @param font Pointer to font structure. If NULL, the shared system font is used.
|
||||
*/
|
||||
static inline FINF_s* fontGetInfo(CFNT_s* font)
|
||||
{
|
||||
if (!font)
|
||||
font = fontGetSystemFont();
|
||||
return &font->finf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieves the texture sheet information of a font.
|
||||
* @param font Pointer to font structure. If NULL, the shared system font is used.
|
||||
*/
|
||||
static inline TGLP_s* fontGetGlyphInfo(CFNT_s* font)
|
||||
{
|
||||
if (!font)
|
||||
font = fontGetSystemFont();
|
||||
return fontGetInfo(font)->tglp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieves the pointer to texture data for the specified texture sheet.
|
||||
* @param font Pointer to font structure. If NULL, the shared system font is used.
|
||||
* @param sheetIndex Index of the texture sheet.
|
||||
*/
|
||||
static inline void* fontGetGlyphSheetTex(CFNT_s* font, int sheetIndex)
|
||||
{
|
||||
if (!font)
|
||||
font = fontGetSystemFont();
|
||||
TGLP_s* tglp = fontGetGlyphInfo(font);
|
||||
return &tglp->sheetData[sheetIndex*tglp->sheetSize];
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Retrieves the glyph index of the specified Unicode codepoint.
|
||||
* @param font Pointer to font structure. If NULL, the shared system font is used.
|
||||
* @param codePoint Unicode codepoint.
|
||||
*/
|
||||
int fontGlyphIndexFromCodePoint(CFNT_s* font, u32 codePoint);
|
||||
|
||||
/**
|
||||
* @brief Retrieves character width information of the specified glyph.
|
||||
* @param font Pointer to font structure. If NULL, the shared system font is used.
|
||||
* @param glyphIndex Index of the glyph.
|
||||
*/
|
||||
charWidthInfo_s* fontGetCharWidthInfo(CFNT_s* font, int glyphIndex);
|
||||
|
||||
/**
|
||||
* @brief Calculates position information for the specified glyph.
|
||||
* @param out Output structure in which to write the information.
|
||||
* @param font Pointer to font structure. If NULL, the shared system font is used.
|
||||
* @param glyphIndex Index of the glyph.
|
||||
* @param flags Calculation flags (see GLYPH_POS_* flags).
|
||||
* @param scaleX Scale factor to apply horizontally.
|
||||
* @param scaleY Scale factor to apply vertically.
|
||||
*/
|
||||
void fontCalcGlyphPos(fontGlyphPos_s* out, CFNT_s* font, int glyphIndex, u32 flags, float scaleX, float scaleY);
|
||||
|
||||
///@}
|
29
libctru/include/3ds/gdbhio.h
Normal file
29
libctru/include/3ds/gdbhio.h
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
* @file gdbhio.h
|
||||
* @brief Luma3DS GDB HIO (called File I/O in GDB documentation) functions.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define GDBHIO_STDIN_FILENO 0
|
||||
#define GDBHIO_STDOUT_FILENO 1
|
||||
#define GDBHIO_STDERR_FILENO 2
|
||||
|
||||
int gdbHioOpen(const char *pathname, int flags, mode_t mode);
|
||||
int gdbHioClose(int fd);
|
||||
int gdbHioRead(int fd, void *buf, unsigned int count);
|
||||
int gdbHioWrite(int fd, const void *buf, unsigned int count);
|
||||
off_t gdbHioLseek(int fd, off_t offset, int flag);
|
||||
int gdbHioRename(const char *oldpath, const char *newpath);
|
||||
int gdbHioUnlink(const char *pathname);
|
||||
int gdbHioStat(const char *pathname, struct stat *st);
|
||||
int gdbHioFstat(int fd, struct stat *st);
|
||||
int gdbHioGettimeofday(struct timeval *tv, void *tz);
|
||||
int gdbHioIsatty(int fd);
|
||||
|
||||
///< Host I/O 'system' function, requires 'set remote system-call-allowed 1'.
|
||||
int gdbHioSystem(const char *command);
|
37
libctru/include/3ds/gdbhio_dev.h
Normal file
37
libctru/include/3ds/gdbhio_dev.h
Normal file
@ -0,0 +1,37 @@
|
||||
/**
|
||||
* @file gdbhio_dev.h
|
||||
* @brief Luma3DS GDB HIO (called File I/O in GDB documentation) devoptab wrapper.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
struct timeval;
|
||||
|
||||
///< Initializes the GDB HIO devoptab wrapper, returns 0 on success, -1 on failure.
|
||||
int gdbHioDevInit(void);
|
||||
|
||||
///< Deinitializes the GDB HIO devoptab wrapper.
|
||||
void gdbHioDevExit(void);
|
||||
|
||||
///< Returns a file descriptor mapping to the GDB client console's standard input stream.
|
||||
int gdbHioDevGetStdin(void);
|
||||
|
||||
///< Returns a file descriptor mapping to the GDB client console's standard output stream.
|
||||
int gdbHioDevGetStdout(void);
|
||||
|
||||
///< Returns a file descriptor mapping to the GDB client console's standard error stream.
|
||||
int gdbHioDevGetStderr(void);
|
||||
|
||||
///< Redirects 0 to 3 of the application's standard streams to GDB client console's. Returns -1, -2, or -3, resp., on failure; 0 on success.
|
||||
int gdbHioDevRedirectStdStreams(bool in, bool out, bool err);
|
||||
|
||||
///< GDB HIO POSIX function gettimeofday.
|
||||
int gdbHioDevGettimeofday(struct timeval *tv, void *tz);
|
||||
|
||||
///< GDB HIO POSIX function isatty.
|
||||
int gdbHioDevIsatty(int fd);
|
||||
|
||||
///< GDB HIO POSIX function system. Requires 'set remote system-call-allowed 1'.
|
||||
int gdbHioDevSystem(const char *command);
|
@ -1,42 +1,180 @@
|
||||
/**
|
||||
* @file gfx.h
|
||||
* @brief Simple framebuffer API
|
||||
*
|
||||
* This API provides basic functionality needed to bring up framebuffers for both screens,
|
||||
* as well as managing display mode (stereoscopic 3D) and double buffering.
|
||||
* It is mainly an abstraction over the gsp service.
|
||||
*
|
||||
* Please note that the 3DS uses *portrait* screens rotated 90 degrees counterclockwise.
|
||||
* Width/height refer to the physical dimensions of the screen; that is, the top screen
|
||||
* is 240 pixels wide and 400 pixels tall; while the bottom screen is 240x320.
|
||||
*/
|
||||
#pragma once
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/services/gsp.h>
|
||||
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/services/gspgpu.h>
|
||||
|
||||
/// Converts red, green, and blue components to packed RGB565.
|
||||
#define RGB565(r,g,b) (((b)&0x1f)|(((g)&0x3f)<<5)|(((r)&0x1f)<<11))
|
||||
|
||||
/// Converts packed RGB8 to packed RGB565.
|
||||
#define RGB8_to_565(r,g,b) (((b)>>3)&0x1f)|((((g)>>2)&0x3f)<<5)|((((r)>>3)&0x1f)<<11)
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GFX_TOP = 0,
|
||||
GFX_BOTTOM = 1
|
||||
}gfxScreen_t;
|
||||
/// Screen IDs.
|
||||
typedef enum {
|
||||
GFX_TOP = GSP_SCREEN_TOP, ///< Top screen
|
||||
GFX_BOTTOM = GSP_SCREEN_BOTTOM, ///< Bottom screen
|
||||
} gfxScreen_t;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GFX_LEFT = 0,
|
||||
GFX_RIGHT = 1,
|
||||
// GFX_BOTTOM = 0
|
||||
}gfx3dSide_t;
|
||||
/**
|
||||
* @brief Top screen framebuffer side.
|
||||
*
|
||||
* This is only meaningful when stereoscopic 3D is enabled on the top screen.
|
||||
* In any other case, use \ref GFX_LEFT.
|
||||
*/
|
||||
typedef enum {
|
||||
GFX_LEFT = 0, ///< Left eye framebuffer
|
||||
GFX_RIGHT = 1, ///< Right eye framebuffer
|
||||
} gfx3dSide_t;
|
||||
|
||||
//system stuff
|
||||
void gfxInitDefault();
|
||||
void gfxInit(GSP_FramebufferFormats topFormat, GSP_FramebufferFormats bottomFormat, bool vrambuffers);
|
||||
void gfxExit();
|
||||
///@name Initialization and deinitialization
|
||||
///@{
|
||||
|
||||
//control stuff
|
||||
/**
|
||||
* @brief Initializes the LCD framebuffers with default parameters
|
||||
* This is equivalent to calling: @code gfxInit(GSP_BGR8_OES,GSP_BGR8_OES,false); @endcode
|
||||
*/
|
||||
void gfxInitDefault(void);
|
||||
|
||||
/**
|
||||
* @brief Initializes the LCD framebuffers.
|
||||
* @param topFormat The format of the top screen framebuffers.
|
||||
* @param bottomFormat The format of the bottom screen framebuffers.
|
||||
* @param vramBuffers Whether to allocate the framebuffers in VRAM.
|
||||
*
|
||||
* This function allocates memory for the framebuffers in the specified memory region.
|
||||
* Initially, stereoscopic 3D is disabled and double buffering is enabled.
|
||||
*
|
||||
* @note This function internally calls \ref gspInit.
|
||||
*/
|
||||
void gfxInit(GSPGPU_FramebufferFormat topFormat, GSPGPU_FramebufferFormat bottomFormat, bool vrambuffers);
|
||||
|
||||
/**
|
||||
* @brief Deinitializes and frees the LCD framebuffers.
|
||||
* @note This function internally calls \ref gspExit.
|
||||
*/
|
||||
void gfxExit(void);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Control
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Enables or disables the 3D stereoscopic effect on the top screen.
|
||||
* @param enable Pass true to enable, false to disable.
|
||||
* @note Stereoscopic 3D is disabled by default.
|
||||
*/
|
||||
void gfxSet3D(bool enable);
|
||||
void gfxSetScreenFormat(gfxScreen_t screen, GSP_FramebufferFormats format);
|
||||
GSP_FramebufferFormats gfxGetScreenFormat(gfxScreen_t screen);
|
||||
void gfxSetDoubleBuffering(gfxScreen_t screen, bool doubleBuffering);
|
||||
void gfxFlushBuffers();
|
||||
void gfxSwapBuffers();
|
||||
void gfxSwapBuffersGpu();
|
||||
|
||||
//helper stuff
|
||||
/**
|
||||
* @brief Retrieves the status of the 3D stereoscopic effect on the top screen.
|
||||
* @return true if 3D enabled, false otherwise.
|
||||
*/
|
||||
bool gfxIs3D(void);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the status of the 800px (double-height) high resolution display mode of the top screen.
|
||||
* @return true if wide mode enabled, false otherwise.
|
||||
*/
|
||||
bool gfxIsWide(void);
|
||||
|
||||
/**
|
||||
* @brief Enables or disables the 800px (double-height) high resolution display mode of the top screen.
|
||||
* @param enable Pass true to enable, false to disable.
|
||||
* @note Wide mode is disabled by default.
|
||||
* @note Wide and stereoscopic 3D modes are mutually exclusive.
|
||||
* @note In wide mode pixels are not square, since scanlines are half as tall as they normally are.
|
||||
* @warning Wide mode does not work on Old 2DS consoles (however it does work on New 2DS XL consoles).
|
||||
*/
|
||||
void gfxSetWide(bool enable);
|
||||
|
||||
/**
|
||||
* @brief Changes the pixel format of a screen.
|
||||
* @param screen Screen ID (see \ref gfxScreen_t)
|
||||
* @param format Pixel format (see \ref GSPGPU_FramebufferFormat)
|
||||
* @note If the currently allocated framebuffers are too small for the specified format,
|
||||
* they are freed and new ones are reallocated.
|
||||
*/
|
||||
void gfxSetScreenFormat(gfxScreen_t screen, GSPGPU_FramebufferFormat format);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the current pixel format of a screen.
|
||||
* @param screen Screen ID (see \ref gfxScreen_t)
|
||||
* @return Pixel format (see \ref GSPGPU_FramebufferFormat)
|
||||
*/
|
||||
GSPGPU_FramebufferFormat gfxGetScreenFormat(gfxScreen_t screen);
|
||||
|
||||
/**
|
||||
* @brief Enables or disables double buffering on a screen.
|
||||
* @param screen Screen ID (see \ref gfxScreen_t)
|
||||
* @param enable Pass true to enable, false to disable.
|
||||
* @note Double buffering is enabled by default.
|
||||
*/
|
||||
void gfxSetDoubleBuffering(gfxScreen_t screen, bool enable);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Rendering and presentation
|
||||
///@{
|
||||
|
||||
/**
|
||||
* @brief Retrieves the framebuffer of the specified screen to which graphics should be rendered.
|
||||
* @param screen Screen ID (see \ref gfxScreen_t)
|
||||
* @param side Framebuffer side (see \ref gfx3dSide_t) (pass \ref GFX_LEFT if not using stereoscopic 3D)
|
||||
* @param width Pointer that will hold the width of the framebuffer in pixels.
|
||||
* @param height Pointer that will hold the height of the framebuffer in pixels.
|
||||
* @return A pointer to the current framebuffer of the chosen screen.
|
||||
*
|
||||
* Please remember that the returned pointer will change every frame if double buffering is enabled.
|
||||
*/
|
||||
u8* gfxGetFramebuffer(gfxScreen_t screen, gfx3dSide_t side, u16* width, u16* height);
|
||||
|
||||
//global variables
|
||||
extern u8* gfxTopLeftFramebuffers[2];
|
||||
extern u8* gfxTopRightFramebuffers[2];
|
||||
extern u8* gfxBottomFramebuffers[2];
|
||||
extern u32* gxCmdBuf;
|
||||
/**
|
||||
* @brief Flushes the data cache for the current framebuffers.
|
||||
* @warning This is **only used during software rendering**. Since this function has significant overhead,
|
||||
* it is preferred to call this only once per frame, after all software rendering is completed.
|
||||
*/
|
||||
void gfxFlushBuffers(void);
|
||||
|
||||
/**
|
||||
* @brief Updates the configuration of the specified screen, swapping the buffers if double buffering is enabled.
|
||||
* @param scr Screen ID (see \ref gfxScreen_t)
|
||||
* @param hasStereo For the top screen in 3D mode: true if the framebuffer contains individual images
|
||||
* for both eyes, or false if the left image should be duplicated to the right eye.
|
||||
* @note Previously rendered content will be displayed on the screen after the next VBlank.
|
||||
* @note This function is still useful even if double buffering is disabled, as it must be used to commit configuration changes.
|
||||
* @warning Only call this once per screen per frame, otherwise graphical glitches will occur
|
||||
* since this API does not implement triple buffering.
|
||||
*/
|
||||
void gfxScreenSwapBuffers(gfxScreen_t scr, bool hasStereo);
|
||||
|
||||
/**
|
||||
* @brief Same as \ref gfxScreenSwapBuffers, but with hasStereo set to true.
|
||||
* @param scr Screen ID (see \ref gfxScreen_t)
|
||||
* @param immediate This parameter no longer has any effect and is thus ignored.
|
||||
* @deprecated This function has been superseded by \ref gfxScreenSwapBuffers, please use that instead.
|
||||
*/
|
||||
CTR_DEPRECATED void gfxConfigScreen(gfxScreen_t scr, bool immediate);
|
||||
|
||||
/**
|
||||
* @brief Updates the configuration of both screens.
|
||||
* @note This function is equivalent to: \code gfxScreenSwapBuffers(GFX_TOP,true); gfxScreenSwapBuffers(GFX_BOTTOM,true); \endcode
|
||||
*/
|
||||
void gfxSwapBuffers(void);
|
||||
|
||||
/// Same as \ref gfxSwapBuffers (formerly different).
|
||||
void gfxSwapBuffersGpu(void);
|
||||
|
||||
///@}
|
||||
|
505
libctru/include/3ds/gpu/enums.h
Normal file
505
libctru/include/3ds/gpu/enums.h
Normal file
@ -0,0 +1,505 @@
|
||||
/**
|
||||
* @file enums.h
|
||||
* @brief GPU enumeration values.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/// Creates a texture magnification filter parameter from a @ref GPU_TEXTURE_FILTER_PARAM
|
||||
#define GPU_TEXTURE_MAG_FILTER(v) (((v)&0x1)<<1)
|
||||
/// Creates a texture minification filter parameter from a @ref GPU_TEXTURE_FILTER_PARAM
|
||||
#define GPU_TEXTURE_MIN_FILTER(v) (((v)&0x1)<<2)
|
||||
/// Creates a texture mipmap filter parameter from a @ref GPU_TEXTURE_FILTER_PARAM
|
||||
#define GPU_TEXTURE_MIP_FILTER(v) (((v)&0x1)<<24)
|
||||
/// Creates a texture wrap S parameter from a @ref GPU_TEXTURE_WRAP_PARAM
|
||||
#define GPU_TEXTURE_WRAP_S(v) (((v)&0x3)<<12)
|
||||
/// Creates a texture wrap T parameter from a @ref GPU_TEXTURE_WRAP_PARAM
|
||||
#define GPU_TEXTURE_WRAP_T(v) (((v)&0x3)<<8)
|
||||
/// Creates a texture mode parameter from a @ref GPU_TEXTURE_MODE_PARAM
|
||||
#define GPU_TEXTURE_MODE(v) (((v)&0x7)<<28)
|
||||
/// Texture parameter indicating ETC1 texture.
|
||||
#define GPU_TEXTURE_ETC1_PARAM BIT(5)
|
||||
/// Texture parameter indicating shadow texture.
|
||||
#define GPU_TEXTURE_SHADOW_PARAM BIT(20)
|
||||
|
||||
/// Creates a combiner buffer write configuration.
|
||||
#define GPU_TEV_BUFFER_WRITE_CONFIG(stage0, stage1, stage2, stage3) ((stage0) | ((stage1) << 1) | ((stage2) << 2) | ((stage3) << 3))
|
||||
|
||||
/// Texture filters.
|
||||
typedef enum
|
||||
{
|
||||
GPU_NEAREST = 0x0, ///< Nearest-neighbor interpolation.
|
||||
GPU_LINEAR = 0x1, ///< Linear interpolation.
|
||||
} GPU_TEXTURE_FILTER_PARAM;
|
||||
|
||||
/// Texture wrap modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_CLAMP_TO_EDGE = 0x0, ///< Clamps to edge.
|
||||
GPU_CLAMP_TO_BORDER = 0x1, ///< Clamps to border.
|
||||
GPU_REPEAT = 0x2, ///< Repeats texture.
|
||||
GPU_MIRRORED_REPEAT = 0x3, ///< Repeats with mirrored texture.
|
||||
} GPU_TEXTURE_WRAP_PARAM;
|
||||
|
||||
/// Texture modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_TEX_2D = 0x0, ///< 2D texture
|
||||
GPU_TEX_CUBE_MAP = 0x1, ///< Cube map
|
||||
GPU_TEX_SHADOW_2D = 0x2, ///< 2D Shadow texture
|
||||
GPU_TEX_PROJECTION = 0x3, ///< Projection texture
|
||||
GPU_TEX_SHADOW_CUBE = 0x4, ///< Shadow cube map
|
||||
GPU_TEX_DISABLED = 0x5, ///< Disabled
|
||||
} GPU_TEXTURE_MODE_PARAM;
|
||||
|
||||
/// Supported texture units.
|
||||
typedef enum
|
||||
{
|
||||
GPU_TEXUNIT0 = 0x1, ///< Texture unit 0.
|
||||
GPU_TEXUNIT1 = 0x2, ///< Texture unit 1.
|
||||
GPU_TEXUNIT2 = 0x4, ///< Texture unit 2.
|
||||
} GPU_TEXUNIT;
|
||||
|
||||
/// Supported texture formats.
|
||||
typedef enum
|
||||
{
|
||||
GPU_RGBA8 = 0x0, ///< 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha
|
||||
GPU_RGB8 = 0x1, ///< 8-bit Red + 8-bit Green + 8-bit Blue
|
||||
GPU_RGBA5551 = 0x2, ///< 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha
|
||||
GPU_RGB565 = 0x3, ///< 5-bit Red + 6-bit Green + 5-bit Blue
|
||||
GPU_RGBA4 = 0x4, ///< 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha
|
||||
GPU_LA8 = 0x5, ///< 8-bit Luminance + 8-bit Alpha
|
||||
GPU_HILO8 = 0x6, ///< 8-bit Hi + 8-bit Lo
|
||||
GPU_L8 = 0x7, ///< 8-bit Luminance
|
||||
GPU_A8 = 0x8, ///< 8-bit Alpha
|
||||
GPU_LA4 = 0x9, ///< 4-bit Luminance + 4-bit Alpha
|
||||
GPU_L4 = 0xA, ///< 4-bit Luminance
|
||||
GPU_A4 = 0xB, ///< 4-bit Alpha
|
||||
GPU_ETC1 = 0xC, ///< ETC1 texture compression
|
||||
GPU_ETC1A4 = 0xD, ///< ETC1 texture compression + 4-bit Alpha
|
||||
} GPU_TEXCOLOR;
|
||||
|
||||
/// Texture faces.
|
||||
typedef enum
|
||||
{
|
||||
GPU_TEXFACE_2D = 0, ///< 2D face
|
||||
GPU_POSITIVE_X = 0, ///< +X face
|
||||
GPU_NEGATIVE_X = 1, ///< -X face
|
||||
GPU_POSITIVE_Y = 2, ///< +Y face
|
||||
GPU_NEGATIVE_Y = 3, ///< -Y face
|
||||
GPU_POSITIVE_Z = 4, ///< +Z face
|
||||
GPU_NEGATIVE_Z = 5, ///< -Z face
|
||||
} GPU_TEXFACE;
|
||||
|
||||
/// Procedural texture clamp modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_PT_CLAMP_TO_ZERO = 0, ///< Clamp to zero.
|
||||
GPU_PT_CLAMP_TO_EDGE = 1, ///< Clamp to edge.
|
||||
GPU_PT_REPEAT = 2, ///< Symmetrical repeat.
|
||||
GPU_PT_MIRRORED_REPEAT = 3, ///< Mirrored repeat.
|
||||
GPU_PT_PULSE = 4, ///< Pulse.
|
||||
} GPU_PROCTEX_CLAMP;
|
||||
|
||||
/// Procedural texture mapping functions.
|
||||
typedef enum
|
||||
{
|
||||
GPU_PT_U = 0, ///< U
|
||||
GPU_PT_U2 = 1, ///< U2
|
||||
GPU_PT_V = 2, ///< V
|
||||
GPU_PT_V2 = 3, ///< V2
|
||||
GPU_PT_ADD = 4, ///< U+V
|
||||
GPU_PT_ADD2 = 5, ///< U2+V2
|
||||
GPU_PT_SQRT2 = 6, ///< sqrt(U2+V2)
|
||||
GPU_PT_MIN = 7, ///< min
|
||||
GPU_PT_MAX = 8, ///< max
|
||||
GPU_PT_RMAX = 9, ///< rmax
|
||||
} GPU_PROCTEX_MAPFUNC;
|
||||
|
||||
/// Procedural texture shift values.
|
||||
typedef enum
|
||||
{
|
||||
GPU_PT_NONE = 0, ///< No shift.
|
||||
GPU_PT_ODD = 1, ///< Odd shift.
|
||||
GPU_PT_EVEN = 2, ///< Even shift.
|
||||
} GPU_PROCTEX_SHIFT;
|
||||
|
||||
/// Procedural texture filter values.
|
||||
typedef enum
|
||||
{
|
||||
GPU_PT_NEAREST = 0, ///< Nearest-neighbor
|
||||
GPU_PT_LINEAR = 1, ///< Linear interpolation
|
||||
GPU_PT_NEAREST_MIP_NEAREST = 2, ///< Nearest-neighbor with mipmap using nearest-neighbor
|
||||
GPU_PT_LINEAR_MIP_NEAREST = 3, ///< Linear interpolation with mipmap using nearest-neighbor
|
||||
GPU_PT_NEAREST_MIP_LINEAR = 4, ///< Nearest-neighbor with mipmap using linear interpolation
|
||||
GPU_PT_LINEAR_MIP_LINEAR = 5, ///< Linear interpolation with mipmap using linear interpolation
|
||||
} GPU_PROCTEX_FILTER;
|
||||
|
||||
/// Procedural texture LUT IDs.
|
||||
typedef enum
|
||||
{
|
||||
GPU_LUT_NOISE = 0, ///< Noise table
|
||||
GPU_LUT_RGBMAP = 2, ///< RGB mapping function table
|
||||
GPU_LUT_ALPHAMAP = 3, ///< Alpha mapping function table
|
||||
GPU_LUT_COLOR = 4, ///< Color table
|
||||
GPU_LUT_COLORDIF = 5, ///< Color difference table
|
||||
} GPU_PROCTEX_LUTID;
|
||||
|
||||
/// Supported color buffer formats.
|
||||
typedef enum
|
||||
{
|
||||
GPU_RB_RGBA8 = 0, ///< 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha
|
||||
GPU_RB_RGB8 = 1, ///< 8-bit Red + 8-bit Green + 8-bit Blue
|
||||
GPU_RB_RGBA5551 = 2, ///< 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha
|
||||
GPU_RB_RGB565 = 3, ///< 5-bit Red + 6-bit Green + 5-bit Blue
|
||||
GPU_RB_RGBA4 = 4, ///< 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha
|
||||
} GPU_COLORBUF;
|
||||
|
||||
/// Supported depth buffer formats.
|
||||
typedef enum
|
||||
{
|
||||
GPU_RB_DEPTH16 = 0, ///< 16-bit Depth
|
||||
GPU_RB_DEPTH24 = 2, ///< 24-bit Depth
|
||||
GPU_RB_DEPTH24_STENCIL8 = 3, ///< 24-bit Depth + 8-bit Stencil
|
||||
} GPU_DEPTHBUF;
|
||||
|
||||
/// Test functions.
|
||||
typedef enum
|
||||
{
|
||||
GPU_NEVER = 0, ///< Never pass.
|
||||
GPU_ALWAYS = 1, ///< Always pass.
|
||||
GPU_EQUAL = 2, ///< Pass if equal.
|
||||
GPU_NOTEQUAL = 3, ///< Pass if not equal.
|
||||
GPU_LESS = 4, ///< Pass if less than.
|
||||
GPU_LEQUAL = 5, ///< Pass if less than or equal.
|
||||
GPU_GREATER = 6, ///< Pass if greater than.
|
||||
GPU_GEQUAL = 7, ///< Pass if greater than or equal.
|
||||
} GPU_TESTFUNC;
|
||||
|
||||
/// Early depth test functions.
|
||||
typedef enum
|
||||
{
|
||||
GPU_EARLYDEPTH_GEQUAL = 0, ///< Pass if greater than or equal.
|
||||
GPU_EARLYDEPTH_GREATER = 1, ///< Pass if greater than.
|
||||
GPU_EARLYDEPTH_LEQUAL = 2, ///< Pass if less than or equal.
|
||||
GPU_EARLYDEPTH_LESS = 3, ///< Pass if less than.
|
||||
} GPU_EARLYDEPTHFUNC;
|
||||
|
||||
/// Gas depth functions.
|
||||
typedef enum
|
||||
{
|
||||
GPU_GAS_NEVER = 0, ///< Never pass (0).
|
||||
GPU_GAS_ALWAYS = 1, ///< Always pass (1).
|
||||
GPU_GAS_GREATER = 2, ///< Pass if greater than (1-X).
|
||||
GPU_GAS_LESS = 3, ///< Pass if less than (X).
|
||||
} GPU_GASDEPTHFUNC;
|
||||
|
||||
/// Converts \ref GPU_TESTFUNC into \ref GPU_GASDEPTHFUNC.
|
||||
#define GPU_MAKEGASDEPTHFUNC(n) (GPU_GASDEPTHFUNC)((0xAF02>>((int)(n)<<1))&3)
|
||||
|
||||
/// Scissor test modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_SCISSOR_DISABLE = 0, ///< Disable.
|
||||
GPU_SCISSOR_INVERT = 1, ///< Exclude pixels inside the scissor box.
|
||||
// 2 is the same as 0
|
||||
GPU_SCISSOR_NORMAL = 3, ///< Exclude pixels outside of the scissor box.
|
||||
} GPU_SCISSORMODE;
|
||||
|
||||
/// Stencil operations.
|
||||
typedef enum
|
||||
{
|
||||
GPU_STENCIL_KEEP = 0, ///< Keep old value. (old_stencil)
|
||||
GPU_STENCIL_ZERO = 1, ///< Zero. (0)
|
||||
GPU_STENCIL_REPLACE = 2, ///< Replace value. (ref)
|
||||
GPU_STENCIL_INCR = 3, ///< Increment value. (old_stencil + 1 saturated to [0, 255])
|
||||
GPU_STENCIL_DECR = 4, ///< Decrement value. (old_stencil - 1 saturated to [0, 255])
|
||||
GPU_STENCIL_INVERT = 5, ///< Invert value. (~old_stencil)
|
||||
GPU_STENCIL_INCR_WRAP = 6, ///< Increment value. (old_stencil + 1)
|
||||
GPU_STENCIL_DECR_WRAP = 7, ///< Decrement value. (old_stencil - 1)
|
||||
} GPU_STENCILOP;
|
||||
|
||||
/// Pixel write mask.
|
||||
typedef enum
|
||||
{
|
||||
GPU_WRITE_RED = 0x01, ///< Write red.
|
||||
GPU_WRITE_GREEN = 0x02, ///< Write green.
|
||||
GPU_WRITE_BLUE = 0x04, ///< Write blue.
|
||||
GPU_WRITE_ALPHA = 0x08, ///< Write alpha.
|
||||
GPU_WRITE_DEPTH = 0x10, ///< Write depth.
|
||||
|
||||
GPU_WRITE_COLOR = 0x0F, ///< Write all color components.
|
||||
GPU_WRITE_ALL = 0x1F, ///< Write all components.
|
||||
} GPU_WRITEMASK;
|
||||
|
||||
/// Blend modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_BLEND_ADD = 0, ///< Add colors.
|
||||
GPU_BLEND_SUBTRACT = 1, ///< Subtract colors.
|
||||
GPU_BLEND_REVERSE_SUBTRACT = 2, ///< Reverse-subtract colors.
|
||||
GPU_BLEND_MIN = 3, ///< Use the minimum color.
|
||||
GPU_BLEND_MAX = 4, ///< Use the maximum color.
|
||||
} GPU_BLENDEQUATION;
|
||||
|
||||
/// Blend factors.
|
||||
typedef enum
|
||||
{
|
||||
GPU_ZERO = 0, ///< Zero.
|
||||
GPU_ONE = 1, ///< One.
|
||||
GPU_SRC_COLOR = 2, ///< Source color.
|
||||
GPU_ONE_MINUS_SRC_COLOR = 3, ///< Source color - 1.
|
||||
GPU_DST_COLOR = 4, ///< Destination color.
|
||||
GPU_ONE_MINUS_DST_COLOR = 5, ///< Destination color - 1.
|
||||
GPU_SRC_ALPHA = 6, ///< Source alpha.
|
||||
GPU_ONE_MINUS_SRC_ALPHA = 7, ///< Source alpha - 1.
|
||||
GPU_DST_ALPHA = 8, ///< Destination alpha.
|
||||
GPU_ONE_MINUS_DST_ALPHA = 9, ///< Destination alpha - 1.
|
||||
GPU_CONSTANT_COLOR = 10, ///< Constant color.
|
||||
GPU_ONE_MINUS_CONSTANT_COLOR = 11, ///< Constant color - 1.
|
||||
GPU_CONSTANT_ALPHA = 12, ///< Constant alpha.
|
||||
GPU_ONE_MINUS_CONSTANT_ALPHA = 13, ///< Constant alpha - 1.
|
||||
GPU_SRC_ALPHA_SATURATE = 14, ///< Saturated alpha.
|
||||
} GPU_BLENDFACTOR;
|
||||
|
||||
/// Logical operations.
|
||||
typedef enum
|
||||
{
|
||||
GPU_LOGICOP_CLEAR = 0, ///< Clear.
|
||||
GPU_LOGICOP_AND = 1, ///< Bitwise AND.
|
||||
GPU_LOGICOP_AND_REVERSE = 2, ///< Reverse bitwise AND.
|
||||
GPU_LOGICOP_COPY = 3, ///< Copy.
|
||||
GPU_LOGICOP_SET = 4, ///< Set.
|
||||
GPU_LOGICOP_COPY_INVERTED = 5, ///< Inverted copy.
|
||||
GPU_LOGICOP_NOOP = 6, ///< No operation.
|
||||
GPU_LOGICOP_INVERT = 7, ///< Invert.
|
||||
GPU_LOGICOP_NAND = 8, ///< Bitwise NAND.
|
||||
GPU_LOGICOP_OR = 9, ///< Bitwise OR.
|
||||
GPU_LOGICOP_NOR = 10, ///< Bitwise NOR.
|
||||
GPU_LOGICOP_XOR = 11, ///< Bitwise XOR.
|
||||
GPU_LOGICOP_EQUIV = 12, ///< Equivalent.
|
||||
GPU_LOGICOP_AND_INVERTED = 13, ///< Inverted bitwise AND.
|
||||
GPU_LOGICOP_OR_REVERSE = 14, ///< Reverse bitwise OR.
|
||||
GPU_LOGICOP_OR_INVERTED = 15, ///< Inverted bitwize OR.
|
||||
} GPU_LOGICOP;
|
||||
|
||||
/// Fragment operation modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_FRAGOPMODE_GL = 0, ///< OpenGL mode.
|
||||
GPU_FRAGOPMODE_GAS_ACC = 1, ///< Gas mode (?).
|
||||
GPU_FRAGOPMODE_SHADOW = 3, ///< Shadow mode (?).
|
||||
} GPU_FRAGOPMODE;
|
||||
|
||||
/// Supported component formats.
|
||||
typedef enum
|
||||
{
|
||||
GPU_BYTE = 0, ///< 8-bit byte.
|
||||
GPU_UNSIGNED_BYTE = 1, ///< 8-bit unsigned byte.
|
||||
GPU_SHORT = 2, ///< 16-bit short.
|
||||
GPU_FLOAT = 3, ///< 32-bit float.
|
||||
} GPU_FORMATS;
|
||||
|
||||
/// Cull modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_CULL_NONE = 0, ///< Disabled.
|
||||
GPU_CULL_FRONT_CCW = 1, ///< Front, counter-clockwise.
|
||||
GPU_CULL_BACK_CCW = 2, ///< Back, counter-clockwise.
|
||||
} GPU_CULLMODE;
|
||||
|
||||
/// Creates a VBO attribute parameter from its index, size, and format.
|
||||
#define GPU_ATTRIBFMT(i, n, f) (((((n)-1)<<2)|((f)&3))<<((i)*4))
|
||||
|
||||
/// Texture combiner sources.
|
||||
typedef enum
|
||||
{
|
||||
GPU_PRIMARY_COLOR = 0x00, ///< Primary color.
|
||||
GPU_FRAGMENT_PRIMARY_COLOR = 0x01, ///< Primary fragment color.
|
||||
GPU_FRAGMENT_SECONDARY_COLOR = 0x02, ///< Secondary fragment color.
|
||||
GPU_TEXTURE0 = 0x03, ///< Texture unit 0.
|
||||
GPU_TEXTURE1 = 0x04, ///< Texture unit 1.
|
||||
GPU_TEXTURE2 = 0x05, ///< Texture unit 2.
|
||||
GPU_TEXTURE3 = 0x06, ///< Texture unit 3.
|
||||
GPU_PREVIOUS_BUFFER = 0x0D, ///< Previous buffer.
|
||||
GPU_CONSTANT = 0x0E, ///< Constant value.
|
||||
GPU_PREVIOUS = 0x0F, ///< Previous value.
|
||||
} GPU_TEVSRC;
|
||||
|
||||
/// Texture RGB combiner operands.
|
||||
typedef enum
|
||||
{
|
||||
GPU_TEVOP_RGB_SRC_COLOR = 0x00, ///< Source color.
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_COLOR = 0x01, ///< Source color - 1.
|
||||
GPU_TEVOP_RGB_SRC_ALPHA = 0x02, ///< Source alpha.
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_ALPHA = 0x03, ///< Source alpha - 1.
|
||||
GPU_TEVOP_RGB_SRC_R = 0x04, ///< Source red.
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_R = 0x05, ///< Source red - 1.
|
||||
GPU_TEVOP_RGB_0x06 = 0x06, ///< Unknown.
|
||||
GPU_TEVOP_RGB_0x07 = 0x07, ///< Unknown.
|
||||
GPU_TEVOP_RGB_SRC_G = 0x08, ///< Source green.
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_G = 0x09, ///< Source green - 1.
|
||||
GPU_TEVOP_RGB_0x0A = 0x0A, ///< Unknown.
|
||||
GPU_TEVOP_RGB_0x0B = 0x0B, ///< Unknown.
|
||||
GPU_TEVOP_RGB_SRC_B = 0x0C, ///< Source blue.
|
||||
GPU_TEVOP_RGB_ONE_MINUS_SRC_B = 0x0D, ///< Source blue - 1.
|
||||
GPU_TEVOP_RGB_0x0E = 0x0E, ///< Unknown.
|
||||
GPU_TEVOP_RGB_0x0F = 0x0F, ///< Unknown.
|
||||
} GPU_TEVOP_RGB;
|
||||
|
||||
/// Texture Alpha combiner operands.
|
||||
typedef enum
|
||||
{
|
||||
GPU_TEVOP_A_SRC_ALPHA = 0x00, ///< Source alpha.
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_ALPHA = 0x01, ///< Source alpha - 1.
|
||||
GPU_TEVOP_A_SRC_R = 0x02, ///< Source red.
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_R = 0x03, ///< Source red - 1.
|
||||
GPU_TEVOP_A_SRC_G = 0x04, ///< Source green.
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_G = 0x05, ///< Source green - 1.
|
||||
GPU_TEVOP_A_SRC_B = 0x06, ///< Source blue.
|
||||
GPU_TEVOP_A_ONE_MINUS_SRC_B = 0x07, ///< Source blue - 1.
|
||||
} GPU_TEVOP_A;
|
||||
|
||||
/// Texture combiner functions.
|
||||
typedef enum
|
||||
{
|
||||
GPU_REPLACE = 0x00, ///< Replace.
|
||||
GPU_MODULATE = 0x01, ///< Modulate.
|
||||
GPU_ADD = 0x02, ///< Add.
|
||||
GPU_ADD_SIGNED = 0x03, ///< Signed add.
|
||||
GPU_INTERPOLATE = 0x04, ///< Interpolate.
|
||||
GPU_SUBTRACT = 0x05, ///< Subtract.
|
||||
GPU_DOT3_RGB = 0x06, ///< Dot3. Scalar result is written to RGB only.
|
||||
GPU_DOT3_RGBA = 0x07, ///< Dot3. Scalar result is written to RGBA.
|
||||
GPU_MULTIPLY_ADD = 0x08, ///< Multiply then add.
|
||||
GPU_ADD_MULTIPLY = 0x09, ///< Add then multiply.
|
||||
} GPU_COMBINEFUNC;
|
||||
|
||||
/// Texture scale factors.
|
||||
typedef enum
|
||||
{
|
||||
GPU_TEVSCALE_1 = 0x0, ///< 1x
|
||||
GPU_TEVSCALE_2 = 0x1, ///< 2x
|
||||
GPU_TEVSCALE_4 = 0x2, ///< 4x
|
||||
} GPU_TEVSCALE;
|
||||
|
||||
/// Creates a texture combiner source parameter from three sources.
|
||||
#define GPU_TEVSOURCES(a,b,c) (((a))|((b)<<4)|((c)<<8))
|
||||
/// Creates a texture combiner operand parameter from three operands.
|
||||
#define GPU_TEVOPERANDS(a,b,c) (((a))|((b)<<4)|((c)<<8))
|
||||
|
||||
/// Creates a light environment layer configuration parameter.
|
||||
#define GPU_LIGHT_ENV_LAYER_CONFIG(n) ((n)+((n)==7))
|
||||
/// Light shadow disable bits in GPUREG_LIGHT_CONFIG1.
|
||||
#define GPU_LC1_SHADOWBIT(n) BIT(n)
|
||||
/// Light spot disable bits in GPUREG_LIGHT_CONFIG1.
|
||||
#define GPU_LC1_SPOTBIT(n) BIT((n)+8)
|
||||
/// LUT disable bits in GPUREG_LIGHT_CONFIG1.
|
||||
#define GPU_LC1_LUTBIT(n) BIT((n)+16)
|
||||
/// Light distance attenuation disable bits in GPUREG_LIGHT_CONFIG1.
|
||||
#define GPU_LC1_ATTNBIT(n) BIT((n)+24)
|
||||
/// Creates a light permutation parameter.
|
||||
#define GPU_LIGHTPERM(i,n) ((n) << ((i)*4))
|
||||
/// Creates a light LUT input parameter.
|
||||
#define GPU_LIGHTLUTINPUT(i,n) ((n) << ((i)*4))
|
||||
/// Creates a light LUT index parameter.
|
||||
#define GPU_LIGHTLUTIDX(c,i,o) ((o) | ((i) << 8) | ((c) << 11))
|
||||
/// Creates a light color parameter from red, green, and blue components.
|
||||
#define GPU_LIGHTCOLOR(r,g,b) (((b) & 0xFF) | (((g) << 10) & 0xFF) | (((r) << 20) & 0xFF))
|
||||
|
||||
/// Fresnel options.
|
||||
typedef enum
|
||||
{
|
||||
GPU_NO_FRESNEL = 0, ///< None.
|
||||
GPU_PRI_ALPHA_FRESNEL = 1, ///< Primary alpha.
|
||||
GPU_SEC_ALPHA_FRESNEL = 2, ///< Secondary alpha.
|
||||
GPU_PRI_SEC_ALPHA_FRESNEL = 3, ///< Primary and secondary alpha.
|
||||
} GPU_FRESNELSEL;
|
||||
|
||||
/// Bump map modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_BUMP_NOT_USED = 0, ///< Disabled.
|
||||
GPU_BUMP_AS_BUMP = 1, ///< Bump as bump mapping.
|
||||
GPU_BUMP_AS_TANG = 2, ///< Bump as tangent/normal mapping.
|
||||
} GPU_BUMPMODE;
|
||||
|
||||
/// LUT IDs.
|
||||
typedef enum
|
||||
{
|
||||
GPU_LUT_D0 = 0, ///< D0 LUT.
|
||||
GPU_LUT_D1 = 1, ///< D1 LUT.
|
||||
GPU_LUT_SP = 2, ///< Spotlight LUT.
|
||||
GPU_LUT_FR = 3, ///< Fresnel LUT.
|
||||
GPU_LUT_RB = 4, ///< Reflection-Blue LUT.
|
||||
GPU_LUT_RG = 5, ///< Reflection-Green LUT.
|
||||
GPU_LUT_RR = 6, ///< Reflection-Red LUT.
|
||||
GPU_LUT_DA = 7, ///< Distance attenuation LUT.
|
||||
} GPU_LIGHTLUTID;
|
||||
|
||||
/// LUT inputs.
|
||||
typedef enum
|
||||
{
|
||||
GPU_LUTINPUT_NH = 0, ///< Normal*HalfVector
|
||||
GPU_LUTINPUT_VH = 1, ///< View*HalfVector
|
||||
GPU_LUTINPUT_NV = 2, ///< Normal*View
|
||||
GPU_LUTINPUT_LN = 3, ///< LightVector*Normal
|
||||
GPU_LUTINPUT_SP = 4, ///< -LightVector*SpotlightVector
|
||||
GPU_LUTINPUT_CP = 5, ///< cosine of phi
|
||||
} GPU_LIGHTLUTINPUT;
|
||||
|
||||
/// LUT scalers.
|
||||
typedef enum
|
||||
{
|
||||
GPU_LUTSCALER_1x = 0, ///< 1x scale.
|
||||
GPU_LUTSCALER_2x = 1, ///< 2x scale.
|
||||
GPU_LUTSCALER_4x = 2, ///< 4x scale.
|
||||
GPU_LUTSCALER_8x = 3, ///< 8x scale.
|
||||
GPU_LUTSCALER_0_25x = 6, ///< 0.25x scale.
|
||||
GPU_LUTSCALER_0_5x = 7, ///< 0.5x scale.
|
||||
} GPU_LIGHTLUTSCALER;
|
||||
|
||||
/// LUT selection.
|
||||
typedef enum
|
||||
{
|
||||
GPU_LUTSELECT_COMMON = 0, ///< LUTs that are common to all lights.
|
||||
GPU_LUTSELECT_SP = 1, ///< Spotlight LUT.
|
||||
GPU_LUTSELECT_DA = 2, ///< Distance attenuation LUT.
|
||||
} GPU_LIGHTLUTSELECT;
|
||||
|
||||
/// Fog modes.
|
||||
typedef enum
|
||||
{
|
||||
GPU_NO_FOG = 0, ///< Fog/Gas unit disabled.
|
||||
GPU_FOG = 5, ///< Fog/Gas unit configured in Fog mode.
|
||||
GPU_GAS = 7, ///< Fog/Gas unit configured in Gas mode.
|
||||
} GPU_FOGMODE;
|
||||
|
||||
/// Gas shading density source values.
|
||||
typedef enum
|
||||
{
|
||||
GPU_PLAIN_DENSITY = 0, ///< Plain density.
|
||||
GPU_DEPTH_DENSITY = 1, ///< Depth density.
|
||||
} GPU_GASMODE;
|
||||
|
||||
/// Gas color LUT inputs.
|
||||
typedef enum
|
||||
{
|
||||
GPU_GAS_DENSITY = 0, ///< Gas density used as input.
|
||||
GPU_GAS_LIGHT_FACTOR = 1, ///< Light factor used as input.
|
||||
} GPU_GASLUTINPUT;
|
||||
|
||||
/// Supported primitives.
|
||||
typedef enum
|
||||
{
|
||||
GPU_TRIANGLES = 0x0000, ///< Triangles.
|
||||
GPU_TRIANGLE_STRIP = 0x0100, ///< Triangle strip.
|
||||
GPU_TRIANGLE_FAN = 0x0200, ///< Triangle fan.
|
||||
GPU_GEOMETRY_PRIM = 0x0300, ///< Geometry shader primitive.
|
||||
} GPU_Primitive_t;
|
||||
|
||||
/// Shader types.
|
||||
typedef enum
|
||||
{
|
||||
GPU_VERTEX_SHADER = 0x0, ///< Vertex shader.
|
||||
GPU_GEOMETRY_SHADER = 0x1, ///< Geometry shader.
|
||||
} GPU_SHADER_TYPE;
|
@ -1,222 +1,119 @@
|
||||
/**
|
||||
* @file gpu.h
|
||||
* @brief Barebones GPU communications driver.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
void GPU_Init(Handle *gsphandle);
|
||||
void GPU_Reset(u32* gxbuf, u32* gpuBuf, u32 gpuBufSize);
|
||||
#include "registers.h"
|
||||
#include "enums.h"
|
||||
|
||||
void GPUCMD_SetBuffer(u32* adr, u32 size, u32 offset);
|
||||
void GPUCMD_SetBufferOffset(u32 offset);
|
||||
void GPUCMD_GetBuffer(u32** adr, u32* size, u32* offset);
|
||||
void GPUCMD_AddRawCommands(u32* cmd, u32 size);
|
||||
void GPUCMD_Run(u32* gxbuf);
|
||||
void GPUCMD_FlushAndRun(u32* gxbuf);
|
||||
void GPUCMD_Add(u32 cmd, u32* param, u32 paramlength);
|
||||
void GPUCMD_AddSingleParam(u32 cmd, u32 param);
|
||||
void GPUCMD_Finalize();
|
||||
/// Creates a GPU command header from its write increments, mask, and register.
|
||||
#define GPUCMD_HEADER(incremental, mask, reg) (((incremental)<<31)|(((mask)&0xF)<<16)|((reg)&0x3FF))
|
||||
|
||||
//tex param
|
||||
#define GPU_TEXTURE_MAG_FILTER(v) (((v)&0x1)<<1) //takes a GPU_TEXTURE_FILTER_PARAM
|
||||
#define GPU_TEXTURE_MIN_FILTER(v) (((v)&0x1)<<2) //takes a GPU_TEXTURE_FILTER_PARAM
|
||||
#define GPU_TEXTURE_WRAP_S(v) (((v)&0x3)<<8) //takes a GPU_TEXTURE_WRAP_PARAM
|
||||
#define GPU_TEXTURE_WRAP_T(v) (((v)&0x3)<<12) //takes a GPU_TEXTURE_WRAP_PARAM
|
||||
extern u32* gpuCmdBuf; ///< GPU command buffer.
|
||||
extern u32 gpuCmdBufSize; ///< GPU command buffer size.
|
||||
extern u32 gpuCmdBufOffset; ///< GPU command buffer offset.
|
||||
|
||||
typedef enum
|
||||
/**
|
||||
* @brief Sets the GPU command buffer to use.
|
||||
* @param adr Pointer to the command buffer.
|
||||
* @param size Size of the command buffer.
|
||||
* @param offset Offset of the command buffer.
|
||||
*/
|
||||
static inline void GPUCMD_SetBuffer(u32* adr, u32 size, u32 offset)
|
||||
{
|
||||
GPU_NEAREST = 0x0,
|
||||
GPU_LINEAR = 0x1,
|
||||
}GPU_TEXTURE_FILTER_PARAM;
|
||||
gpuCmdBuf=adr;
|
||||
gpuCmdBufSize=size;
|
||||
gpuCmdBufOffset=offset;
|
||||
}
|
||||
|
||||
typedef enum
|
||||
/**
|
||||
* @brief Sets the offset of the GPU command buffer.
|
||||
* @param offset Offset of the command buffer.
|
||||
*/
|
||||
static inline void GPUCMD_SetBufferOffset(u32 offset)
|
||||
{
|
||||
GPU_CLAMP_TO_EDGE = 0x0,
|
||||
GPU_REPEAT = 0x2,
|
||||
}GPU_TEXTURE_WRAP_PARAM;
|
||||
gpuCmdBufOffset=offset;
|
||||
}
|
||||
|
||||
typedef enum
|
||||
/**
|
||||
* @brief Gets the current GPU command buffer.
|
||||
* @param addr Pointer to output the command buffer to.
|
||||
* @param size Pointer to output the size (in words) of the command buffer to.
|
||||
* @param offset Pointer to output the offset of the command buffer to.
|
||||
*/
|
||||
static inline void GPUCMD_GetBuffer(u32** addr, u32* size, u32* offset)
|
||||
{
|
||||
GPU_TEXUNIT0 = 0x1,
|
||||
GPU_TEXUNIT1 = 0x2,
|
||||
GPU_TEXUNIT2 = 0x4
|
||||
} GPU_TEXUNIT;
|
||||
if(addr)*addr=gpuCmdBuf;
|
||||
if(size)*size=gpuCmdBufSize;
|
||||
if(offset)*offset=gpuCmdBufOffset;
|
||||
}
|
||||
|
||||
typedef enum{
|
||||
GPU_RGBA8=0x0,
|
||||
GPU_RGB8=0x1,
|
||||
GPU_RGBA5551=0x2,
|
||||
GPU_RGB565=0x3,
|
||||
GPU_RGBA4=0x4,
|
||||
GPU_LA8=0x5,
|
||||
GPU_HILO8=0x6,
|
||||
GPU_L8=0x7,
|
||||
GPU_A8=0x8,
|
||||
GPU_LA4=0x9,
|
||||
GPU_L4=0xA,
|
||||
GPU_ETC1=0xB,
|
||||
GPU_ETC1A4=0xC
|
||||
}GPU_TEXCOLOR;
|
||||
/**
|
||||
* @brief Adds raw GPU commands to the current command buffer.
|
||||
* @param cmd Buffer containing commands to add.
|
||||
* @param size Size of the buffer.
|
||||
*/
|
||||
void GPUCMD_AddRawCommands(const u32* cmd, u32 size);
|
||||
|
||||
typedef enum
|
||||
/**
|
||||
* @brief Adds a GPU command to the current command buffer.
|
||||
* @param header Header of the command.
|
||||
* @param param Parameters of the command.
|
||||
* @param paramlength Size of the parameter buffer.
|
||||
*/
|
||||
void GPUCMD_Add(u32 header, const u32* param, u32 paramlength);
|
||||
|
||||
/**
|
||||
* @brief Splits the current GPU command buffer.
|
||||
* @param addr Pointer to output the command buffer to.
|
||||
* @param size Pointer to output the size (in words) of the command buffer to.
|
||||
*/
|
||||
void GPUCMD_Split(u32** addr, u32* size);
|
||||
|
||||
/**
|
||||
* @brief Converts a 32-bit float to a 16-bit float.
|
||||
* @param f Float to convert.
|
||||
* @return The converted float.
|
||||
*/
|
||||
u32 f32tof16(float f);
|
||||
|
||||
/**
|
||||
* @brief Converts a 32-bit float to a 20-bit float.
|
||||
* @param f Float to convert.
|
||||
* @return The converted float.
|
||||
*/
|
||||
u32 f32tof20(float f);
|
||||
|
||||
/**
|
||||
* @brief Converts a 32-bit float to a 24-bit float.
|
||||
* @param f Float to convert.
|
||||
* @return The converted float.
|
||||
*/
|
||||
u32 f32tof24(float f);
|
||||
|
||||
/**
|
||||
* @brief Converts a 32-bit float to a 31-bit float.
|
||||
* @param f Float to convert.
|
||||
* @return The converted float.
|
||||
*/
|
||||
u32 f32tof31(float f);
|
||||
|
||||
/// Adds a command with a single parameter to the current command buffer.
|
||||
static inline void GPUCMD_AddSingleParam(u32 header, u32 param)
|
||||
{
|
||||
GPU_NEVER = 0,
|
||||
GPU_ALWAYS = 1,
|
||||
GPU_EQUAL = 2,
|
||||
GPU_NOTEQUAL = 3,
|
||||
GPU_LESS = 4,
|
||||
GPU_LEQUAL = 5,
|
||||
GPU_GREATER = 6,
|
||||
GPU_GEQUAL = 7
|
||||
}GPU_TESTFUNC;
|
||||
GPUCMD_Add(header, ¶m, 1);
|
||||
}
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPU_SCISSOR_DISABLE = 0, // disable scissor test
|
||||
GPU_SCISSOR_INVERT = 1, // exclude pixels inside the scissor box
|
||||
// 2 is the same as 0
|
||||
GPU_SCISSOR_NORMAL = 3, // exclude pixels outside of the scissor box
|
||||
|
||||
} GPU_SCISSORMODE;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPU_KEEP = 0, // keep destination value
|
||||
GPU_AND_NOT = 1, // destination & ~source
|
||||
GPU_XOR = 5, // destination ^ source
|
||||
// 2 is the same as 1. Other values are too weird to even be usable.
|
||||
} GPU_STENCILOP;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPU_WRITE_RED = 0x01,
|
||||
GPU_WRITE_GREEN = 0x02,
|
||||
GPU_WRITE_BLUE = 0x04,
|
||||
GPU_WRITE_ALPHA = 0x08,
|
||||
GPU_WRITE_DEPTH = 0x10,
|
||||
|
||||
GPU_WRITE_COLOR = 0x0F,
|
||||
GPU_WRITE_ALL = 0x1F
|
||||
} GPU_WRITEMASK;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPU_BLEND_ADD = 0,
|
||||
GPU_BLEND_SUBTRACT = 1,
|
||||
GPU_BLEND_REVERSE_SUBTRACT = 2,
|
||||
GPU_BLEND_MIN = 3,
|
||||
GPU_BLEND_MAX = 4
|
||||
} GPU_BLENDEQUATION;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPU_ZERO = 0,
|
||||
GPU_ONE = 1,
|
||||
GPU_SRC_COLOR = 2,
|
||||
GPU_ONE_MINUS_SRC_COLOR = 3,
|
||||
GPU_DST_COLOR = 4,
|
||||
GPU_ONE_MINUS_DST_COLOR = 5,
|
||||
GPU_SRC_ALPHA = 6,
|
||||
GPU_ONE_MINUS_SRC_ALPHA = 7,
|
||||
GPU_DST_ALPHA = 8,
|
||||
GPU_ONE_MINUS_DST_ALPHA = 9,
|
||||
GPU_CONSTANT_COLOR = 10,
|
||||
GPU_ONE_MINUS_CONSTANT_COLOR = 11,
|
||||
GPU_CONSTANT_ALPHA = 12,
|
||||
GPU_ONE_MINUS_CONSTANT_ALPHA = 13,
|
||||
GPU_SRC_ALPHA_SATURATE = 14
|
||||
} GPU_BLENDFACTOR;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
GPU_LOGICOP_CLEAR = 0,
|
||||
GPU_LOGICOP_AND = 1,
|
||||
GPU_LOGICOP_AND_REVERSE = 2,
|
||||
GPU_LOGICOP_COPY = 3,
|
||||
GPU_LOGICOP_SET = 4,
|
||||
GPU_LOGICOP_COPY_INVERTED = 5,
|
||||
GPU_LOGICOP_NOOP = 6,
|
||||
GPU_LOGICOP_INVERT = 7,
|
||||
GPU_LOGICOP_NAND = 8,
|
||||
GPU_LOGICOP_OR = 9,
|
||||
GPU_LOGICOP_NOR = 10,
|
||||
GPU_LOGICOP_XOR = 11,
|
||||
GPU_LOGICOP_EQUIV = 12,
|
||||
GPU_LOGICOP_AND_INVERTED = 13,
|
||||
GPU_LOGICOP_OR_REVERSE = 14,
|
||||
GPU_LOGICOP_OR_INVERTED = 15
|
||||
} GPU_LOGICOP;
|
||||
|
||||
typedef enum{
|
||||
GPU_BYTE = 0,
|
||||
GPU_UNSIGNED_BYTE = 1,
|
||||
GPU_SHORT = 2,
|
||||
GPU_FLOAT = 3
|
||||
}GPU_FORMATS;
|
||||
|
||||
//defines for CW ?
|
||||
typedef enum{
|
||||
GPU_CULL_NONE = 0,
|
||||
GPU_CULL_FRONT_CCW = 1,
|
||||
GPU_CULL_BACK_CCW = 2
|
||||
}GPU_CULLMODE;
|
||||
|
||||
#define GPU_ATTRIBFMT(i, n, f) (((((n)-1)<<2)|((f)&3))<<((i)*4))
|
||||
|
||||
typedef enum{
|
||||
GPU_PRIMARY_COLOR = 0x00,
|
||||
GPU_TEXTURE0 = 0x03,
|
||||
GPU_TEXTURE1 = 0x04,
|
||||
GPU_TEXTURE2 = 0x05,
|
||||
GPU_TEXTURE3 = 0x06,
|
||||
GPU_CONSTANT = 0x0E,
|
||||
GPU_PREVIOUS = 0x0F,
|
||||
}GPU_TEVSRC;
|
||||
|
||||
typedef enum{
|
||||
GPU_REPLACE = 0x00,
|
||||
GPU_MODULATE = 0x01,
|
||||
GPU_ADD = 0x02,
|
||||
GPU_ADD_SIGNED = 0x03,
|
||||
GPU_INTERPOLATE = 0x04,
|
||||
GPU_SUBTRACT = 0x05,
|
||||
GPU_DOT3_RGB = 0x06 //RGB only
|
||||
}GPU_COMBINEFUNC;
|
||||
|
||||
#define GPU_TEVSOURCES(a,b,c) (((a))|((b)<<4)|((c)<<8))
|
||||
#define GPU_TEVOPERANDS(a,b,c) (((a))|((b)<<4)|((c)<<8))
|
||||
|
||||
typedef enum{
|
||||
GPU_TRIANGLES = 0x0000,
|
||||
GPU_TRIANGLE_STRIP = 0x0100,
|
||||
GPU_TRIANGLE_FAN = 0x0200,
|
||||
GPU_UNKPRIM = 0x0300 // ?
|
||||
}GPU_Primitive_t;
|
||||
|
||||
void GPU_SetUniform(u32 startreg, u32* data, u32 numreg);
|
||||
|
||||
void GPU_SetViewport(u32* depthBuffer, u32* colorBuffer, u32 x, u32 y, u32 w, u32 h);
|
||||
|
||||
void GPU_SetScissorTest(GPU_SCISSORMODE mode, u32 x, u32 y, u32 w, u32 h);
|
||||
|
||||
void GPU_DepthRange(float nearVal, float farVal);
|
||||
void GPU_SetAlphaTest(bool enable, GPU_TESTFUNC function, u8 ref);
|
||||
void GPU_SetDepthTestAndWriteMask(bool enable, GPU_TESTFUNC function, GPU_WRITEMASK writemask); // GPU_WRITEMASK values can be ORed together
|
||||
void GPU_SetStencilTest(bool enable, GPU_TESTFUNC function, u8 ref, u8 mask, u8 replace);
|
||||
void GPU_SetStencilOp(GPU_STENCILOP sfail, GPU_STENCILOP dfail, GPU_STENCILOP pass);
|
||||
void GPU_SetFaceCulling(GPU_CULLMODE mode);
|
||||
|
||||
// these two can't be used together
|
||||
void GPU_SetAlphaBlending(GPU_BLENDEQUATION colorEquation, GPU_BLENDEQUATION alphaEquation,
|
||||
GPU_BLENDFACTOR colorSrc, GPU_BLENDFACTOR colorDst,
|
||||
GPU_BLENDFACTOR alphaSrc, GPU_BLENDFACTOR alphaDst);
|
||||
void GPU_SetColorLogicOp(GPU_LOGICOP op);
|
||||
|
||||
void GPU_SetBlendingColor(u8 r, u8 g, u8 b, u8 a);
|
||||
|
||||
void GPU_SetAttributeBuffers(u8 totalAttributes, u32* baseAddress, u64 attributeFormats, u16 attributeMask, u64 attributePermutation, u8 numBuffers, u32 bufferOffsets[], u64 bufferPermutations[], u8 bufferNumAttributes[]);
|
||||
|
||||
void GPU_SetTextureEnable(GPU_TEXUNIT units); // GPU_TEXUNITx values can be ORed together to enable multiple texture units
|
||||
void GPU_SetTexture(GPU_TEXUNIT unit, u32* data, u16 width, u16 height, u32 param, GPU_TEXCOLOR colorType);
|
||||
void GPU_SetTexEnv(u8 id, u16 rgbSources, u16 alphaSources, u16 rgbOperands, u16 alphaOperands, GPU_COMBINEFUNC rgbCombine, GPU_COMBINEFUNC alphaCombine, u32 constantColor);
|
||||
|
||||
void GPU_DrawArray(GPU_Primitive_t primitive, u32 n);
|
||||
void GPU_DrawElements(GPU_Primitive_t primitive, u32* indexArray, u32 n);
|
||||
|
||||
void GPU_FinishDrawing();
|
||||
/// Adds a masked register write to the current command buffer.
|
||||
#define GPUCMD_AddMaskedWrite(reg, mask, val) GPUCMD_AddSingleParam(GPUCMD_HEADER(0, (mask), (reg)), (val))
|
||||
/// Adds a register write to the current command buffer.
|
||||
#define GPUCMD_AddWrite(reg, val) GPUCMD_AddMaskedWrite((reg), 0xF, (val))
|
||||
/// Adds multiple masked register writes to the current command buffer.
|
||||
#define GPUCMD_AddMaskedWrites(reg, mask, vals, num) GPUCMD_Add(GPUCMD_HEADER(0, (mask), (reg)), (vals), (num))
|
||||
/// Adds multiple register writes to the current command buffer.
|
||||
#define GPUCMD_AddWrites(reg, vals, num) GPUCMD_AddMaskedWrites((reg), 0xF, (vals), (num))
|
||||
/// Adds multiple masked incremental register writes to the current command buffer.
|
||||
#define GPUCMD_AddMaskedIncrementalWrites(reg, mask, vals, num) GPUCMD_Add(GPUCMD_HEADER(1, (mask), (reg)), (vals), (num))
|
||||
/// Adds multiple incremental register writes to the current command buffer.
|
||||
#define GPUCMD_AddIncrementalWrites(reg, vals, num) GPUCMD_AddMaskedIncrementalWrites((reg), 0xF, (vals), (num))
|
||||
|
@ -1,10 +1,206 @@
|
||||
/**
|
||||
* @file gx.h
|
||||
* @brief GX commands.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief Creates a buffer dimension parameter from width and height values.
|
||||
* @param w buffer width for GX_DisplayTransfer, linesize for GX_TextureCopy
|
||||
* @param h buffer height for GX_DisplayTransfer, gap for GX_TextureCopy
|
||||
*/
|
||||
#define GX_BUFFER_DIM(w, h) (((h)<<16)|((w)&0xFFFF))
|
||||
|
||||
Result GX_RequestDma(u32* gxbuf, u32* src, u32* dst, u32 length);
|
||||
Result GX_SetCommandList_Last(u32* gxbuf, u32* buf0a, u32 buf0s, u8 flags);
|
||||
Result GX_SetMemoryFill(u32* gxbuf, u32* buf0a, u32 buf0v, u32* buf0e, u16 width0, u32* buf1a, u32 buf1v, u32* buf1e, u16 width1);
|
||||
Result GX_SetDisplayTransfer(u32* gxbuf, u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 flags);
|
||||
Result GX_SetTextureCopy(u32* gxbuf, u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 size, u32 flags);
|
||||
Result GX_SetCommandList_First(u32* gxbuf, u32* buf0a, u32 buf0s, u32* buf1a, u32 buf1s, u32* buf2a, u32 buf2s);
|
||||
/**
|
||||
* @brief Supported transfer pixel formats.
|
||||
* @sa GSPGPU_FramebufferFormat
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GX_TRANSFER_FMT_RGBA8 = 0, ///< 8-bit Red + 8-bit Green + 8-bit Blue + 8-bit Alpha
|
||||
GX_TRANSFER_FMT_RGB8 = 1, ///< 8-bit Red + 8-bit Green + 8-bit Blue
|
||||
GX_TRANSFER_FMT_RGB565 = 2, ///< 5-bit Red + 6-bit Green + 5-bit Blue
|
||||
GX_TRANSFER_FMT_RGB5A1 = 3, ///< 5-bit Red + 5-bit Green + 5-bit Blue + 1-bit Alpha
|
||||
GX_TRANSFER_FMT_RGBA4 = 4 ///< 4-bit Red + 4-bit Green + 4-bit Blue + 4-bit Alpha
|
||||
} GX_TRANSFER_FORMAT;
|
||||
|
||||
/**
|
||||
* @brief Anti-aliasing modes
|
||||
*
|
||||
* Please remember that the framebuffer is sideways.
|
||||
* Hence if you activate 2x1 anti-aliasing the destination dimensions are w = 240*2 and h = 400
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
GX_TRANSFER_SCALE_NO = 0, ///< No anti-aliasing
|
||||
GX_TRANSFER_SCALE_X = 1, ///< 2x1 anti-aliasing
|
||||
GX_TRANSFER_SCALE_XY = 2, ///< 2x2 anti-aliasing
|
||||
} GX_TRANSFER_SCALE;
|
||||
|
||||
/// GX transfer control flags
|
||||
typedef enum
|
||||
{
|
||||
GX_FILL_TRIGGER = 0x001, ///< Trigger the PPF event
|
||||
GX_FILL_FINISHED = 0x002, ///< Indicates if the memory fill is complete. You should not use it when requesting a transfer.
|
||||
GX_FILL_16BIT_DEPTH = 0x000, ///< The buffer has a 16 bit per pixel depth
|
||||
GX_FILL_24BIT_DEPTH = 0x100, ///< The buffer has a 24 bit per pixel depth
|
||||
GX_FILL_32BIT_DEPTH = 0x200, ///< The buffer has a 32 bit per pixel depth
|
||||
} GX_FILL_CONTROL;
|
||||
|
||||
/// Creates a transfer vertical flip flag.
|
||||
#define GX_TRANSFER_FLIP_VERT(x) ((x)<<0)
|
||||
/// Creates a transfer tiled output flag.
|
||||
#define GX_TRANSFER_OUT_TILED(x) ((x)<<1)
|
||||
/// Creates a transfer raw copy flag.
|
||||
#define GX_TRANSFER_RAW_COPY(x) ((x)<<3)
|
||||
/// Creates a transfer input format flag.
|
||||
#define GX_TRANSFER_IN_FORMAT(x) ((x)<<8)
|
||||
/// Creates a transfer output format flag.
|
||||
#define GX_TRANSFER_OUT_FORMAT(x) ((x)<<12)
|
||||
/// Creates a transfer scaling flag.
|
||||
#define GX_TRANSFER_SCALING(x) ((x)<<24)
|
||||
|
||||
/// Updates gas additive blend results.
|
||||
#define GX_CMDLIST_UPDATE_GAS_ACC BIT(0)
|
||||
/// Flushes the command list.
|
||||
#define GX_CMDLIST_FLUSH BIT(1)
|
||||
|
||||
/// GX command entry
|
||||
typedef union
|
||||
{
|
||||
u32 data[8]; ///< Raw command data
|
||||
struct
|
||||
{
|
||||
u8 type; ///< Command type
|
||||
u8 unk1;
|
||||
u8 unk2;
|
||||
u8 unk3;
|
||||
u32 args[7]; ///< Command arguments
|
||||
};
|
||||
} gxCmdEntry_s;
|
||||
|
||||
/// GX command queue structure
|
||||
typedef struct tag_gxCmdQueue_s
|
||||
{
|
||||
gxCmdEntry_s* entries; ///< Pointer to array of GX command entries
|
||||
u16 maxEntries; ///< Capacity of the command array
|
||||
u16 numEntries; ///< Number of commands in the queue
|
||||
u16 curEntry; ///< Index of the first pending command to be submitted to GX
|
||||
u16 lastEntry; ///< Number of commands completed by GX
|
||||
void (* callback)(struct tag_gxCmdQueue_s*); ///< User callback
|
||||
void* user; ///< Data for user callback
|
||||
} gxCmdQueue_s;
|
||||
|
||||
/**
|
||||
* @brief Clears a GX command queue.
|
||||
* @param queue The GX command queue.
|
||||
*/
|
||||
void gxCmdQueueClear(gxCmdQueue_s* queue);
|
||||
|
||||
/**
|
||||
* @brief Adds a command to a GX command queue.
|
||||
* @param queue The GX command queue.
|
||||
* @param entry The GX command to add.
|
||||
*/
|
||||
void gxCmdQueueAdd(gxCmdQueue_s* queue, const gxCmdEntry_s* entry);
|
||||
|
||||
/**
|
||||
* @brief Runs a GX command queue, causing it to begin processing incoming commands as they arrive.
|
||||
* @param queue The GX command queue.
|
||||
*/
|
||||
void gxCmdQueueRun(gxCmdQueue_s* queue);
|
||||
|
||||
/**
|
||||
* @brief Stops a GX command queue from processing incoming commands.
|
||||
* @param queue The GX command queue.
|
||||
*/
|
||||
void gxCmdQueueStop(gxCmdQueue_s* queue);
|
||||
|
||||
/**
|
||||
* @brief Waits for a GX command queue to finish executing pending commands.
|
||||
* @param queue The GX command queue.
|
||||
* @param timeout Optional timeout (in nanoseconds) to wait (specify -1 for no timeout).
|
||||
* @return false if timeout expired, true otherwise.
|
||||
*/
|
||||
bool gxCmdQueueWait(gxCmdQueue_s* queue, s64 timeout);
|
||||
|
||||
/**
|
||||
* @brief Sets the completion callback for a GX command queue.
|
||||
* @param queue The GX command queue.
|
||||
* @param callback The completion callback.
|
||||
* @param user User data.
|
||||
*/
|
||||
static inline void gxCmdQueueSetCallback(gxCmdQueue_s* queue, void (* callback)(gxCmdQueue_s*), void* user)
|
||||
{
|
||||
queue->callback = callback;
|
||||
queue->user = user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Selects a command queue to which GX_* functions will add commands instead of immediately submitting them to GX.
|
||||
* @param queue The GX command queue. (Pass NULL to remove the bound command queue)
|
||||
*/
|
||||
void GX_BindQueue(gxCmdQueue_s* queue);
|
||||
|
||||
/**
|
||||
* @brief Requests a DMA.
|
||||
* @param src Source to DMA from.
|
||||
* @param dst Destination to DMA to.
|
||||
* @param length Length of data to transfer.
|
||||
*/
|
||||
Result GX_RequestDma(u32* src, u32* dst, u32 length);
|
||||
|
||||
/**
|
||||
* @brief Processes a GPU command list.
|
||||
* @param buf0a Command list address.
|
||||
* @param buf0s Command list size.
|
||||
* @param flags Flags to process with.
|
||||
*/
|
||||
Result GX_ProcessCommandList(u32* buf0a, u32 buf0s, u8 flags);
|
||||
|
||||
/**
|
||||
* @brief Fills the memory of two buffers with the given values.
|
||||
* @param buf0a Start address of the first buffer.
|
||||
* @param buf0v Dimensions of the first buffer.
|
||||
* @param buf0e End address of the first buffer.
|
||||
* @param control0 Value to fill the first buffer with.
|
||||
* @param buf1a Start address of the second buffer.
|
||||
* @param buf1v Dimensions of the second buffer.
|
||||
* @param buf1e End address of the second buffer.
|
||||
* @param control1 Value to fill the second buffer with.
|
||||
*/
|
||||
Result GX_MemoryFill(u32* buf0a, u32 buf0v, u32* buf0e, u16 control0, u32* buf1a, u32 buf1v, u32* buf1e, u16 control1);
|
||||
|
||||
/**
|
||||
* @brief Initiates a display transfer.
|
||||
* @note The PPF event will be signaled on completion.
|
||||
* @param inadr Address of the input.
|
||||
* @param indim Dimensions of the input.
|
||||
* @param outadr Address of the output.
|
||||
* @param outdim Dimensions of the output.
|
||||
* @param flags Flags to transfer with.
|
||||
*/
|
||||
Result GX_DisplayTransfer(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 flags);
|
||||
|
||||
/**
|
||||
* @brief Initiates a texture copy.
|
||||
* @note The PPF event will be signaled on completion.
|
||||
* @param inadr Address of the input.
|
||||
* @param indim Dimensions of the input.
|
||||
* @param outadr Address of the output.
|
||||
* @param outdim Dimensions of the output.
|
||||
* @param size Size of the data to transfer.
|
||||
* @param flags Flags to transfer with.
|
||||
*/
|
||||
Result GX_TextureCopy(u32* inadr, u32 indim, u32* outadr, u32 outdim, u32 size, u32 flags);
|
||||
|
||||
/**
|
||||
* @brief Flushes the cache regions of three buffers. (This command cannot be queued in a GX command queue)
|
||||
* @param buf0a Address of the first buffer.
|
||||
* @param buf0s Size of the first buffer.
|
||||
* @param buf1a Address of the second buffer.
|
||||
* @param buf1s Size of the second buffer.
|
||||
* @param buf2a Address of the third buffer.
|
||||
* @param buf2s Size of the third buffer.
|
||||
*/
|
||||
Result GX_FlushCacheRegions(u32* buf0a, u32 buf0s, u32* buf1a, u32 buf1s, u32* buf2a, u32 buf2s);
|
||||
|
767
libctru/include/3ds/gpu/registers.h
Normal file
767
libctru/include/3ds/gpu/registers.h
Normal file
@ -0,0 +1,767 @@
|
||||
/**
|
||||
* @file registers.h
|
||||
* @description GPU registers.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
///@name Miscellaneous registers (0x000-0x03F)
|
||||
///@{
|
||||
#define GPUREG_0000 0x0000 ///< Unknown.
|
||||
#define GPUREG_0001 0x0001 ///< Unknown.
|
||||
#define GPUREG_0002 0x0002 ///< Unknown.
|
||||
#define GPUREG_0003 0x0003 ///< Unknown.
|
||||
#define GPUREG_0004 0x0004 ///< Unknown.
|
||||
#define GPUREG_0005 0x0005 ///< Unknown.
|
||||
#define GPUREG_0006 0x0006 ///< Unknown.
|
||||
#define GPUREG_0007 0x0007 ///< Unknown.
|
||||
#define GPUREG_0008 0x0008 ///< Unknown.
|
||||
#define GPUREG_0009 0x0009 ///< Unknown.
|
||||
#define GPUREG_000A 0x000A ///< Unknown.
|
||||
#define GPUREG_000B 0x000B ///< Unknown.
|
||||
#define GPUREG_000C 0x000C ///< Unknown.
|
||||
#define GPUREG_000D 0x000D ///< Unknown.
|
||||
#define GPUREG_000E 0x000E ///< Unknown.
|
||||
#define GPUREG_000F 0x000F ///< Unknown.
|
||||
#define GPUREG_FINALIZE 0x0010 ///< Used to finalize GPU drawing.
|
||||
#define GPUREG_0011 0x0011 ///< Unknown.
|
||||
#define GPUREG_0012 0x0012 ///< Unknown.
|
||||
#define GPUREG_0013 0x0013 ///< Unknown.
|
||||
#define GPUREG_0014 0x0014 ///< Unknown.
|
||||
#define GPUREG_0015 0x0015 ///< Unknown.
|
||||
#define GPUREG_0016 0x0016 ///< Unknown.
|
||||
#define GPUREG_0017 0x0017 ///< Unknown.
|
||||
#define GPUREG_0018 0x0018 ///< Unknown.
|
||||
#define GPUREG_0019 0x0019 ///< Unknown.
|
||||
#define GPUREG_001A 0x001A ///< Unknown.
|
||||
#define GPUREG_001B 0x001B ///< Unknown.
|
||||
#define GPUREG_001C 0x001C ///< Unknown.
|
||||
#define GPUREG_001D 0x001D ///< Unknown.
|
||||
#define GPUREG_001E 0x001E ///< Unknown.
|
||||
#define GPUREG_001F 0x001F ///< Unknown.
|
||||
#define GPUREG_0020 0x0020 ///< Unknown.
|
||||
#define GPUREG_0021 0x0021 ///< Unknown.
|
||||
#define GPUREG_0022 0x0022 ///< Unknown.
|
||||
#define GPUREG_0023 0x0023 ///< Unknown.
|
||||
#define GPUREG_0024 0x0024 ///< Unknown.
|
||||
#define GPUREG_0025 0x0025 ///< Unknown.
|
||||
#define GPUREG_0026 0x0026 ///< Unknown.
|
||||
#define GPUREG_0027 0x0027 ///< Unknown.
|
||||
#define GPUREG_0028 0x0028 ///< Unknown.
|
||||
#define GPUREG_0029 0x0029 ///< Unknown.
|
||||
#define GPUREG_002A 0x002A ///< Unknown.
|
||||
#define GPUREG_002B 0x002B ///< Unknown.
|
||||
#define GPUREG_002C 0x002C ///< Unknown.
|
||||
#define GPUREG_002D 0x002D ///< Unknown.
|
||||
#define GPUREG_002E 0x002E ///< Unknown.
|
||||
#define GPUREG_002F 0x002F ///< Unknown.
|
||||
#define GPUREG_0030 0x0030 ///< Unknown.
|
||||
#define GPUREG_0031 0x0031 ///< Unknown.
|
||||
#define GPUREG_0032 0x0032 ///< Unknown.
|
||||
#define GPUREG_0033 0x0033 ///< Unknown.
|
||||
#define GPUREG_0034 0x0034 ///< Unknown.
|
||||
#define GPUREG_0035 0x0035 ///< Unknown.
|
||||
#define GPUREG_0036 0x0036 ///< Unknown.
|
||||
#define GPUREG_0037 0x0037 ///< Unknown.
|
||||
#define GPUREG_0038 0x0038 ///< Unknown.
|
||||
#define GPUREG_0039 0x0039 ///< Unknown.
|
||||
#define GPUREG_003A 0x003A ///< Unknown.
|
||||
#define GPUREG_003B 0x003B ///< Unknown.
|
||||
#define GPUREG_003C 0x003C ///< Unknown.
|
||||
#define GPUREG_003D 0x003D ///< Unknown.
|
||||
#define GPUREG_003E 0x003E ///< Unknown.
|
||||
#define GPUREG_003F 0x003F ///< Unknown.
|
||||
///@}
|
||||
|
||||
///@name Rasterizer registers (0x040-0x07F)
|
||||
///@{
|
||||
#define GPUREG_FACECULLING_CONFIG 0x0040 ///< Face culling configuration.
|
||||
#define GPUREG_VIEWPORT_WIDTH 0x0041 ///< Viewport width.
|
||||
#define GPUREG_VIEWPORT_INVW 0x0042 ///< Inverted viewport width.
|
||||
#define GPUREG_VIEWPORT_HEIGHT 0x0043 ///< Viewport height.
|
||||
#define GPUREG_VIEWPORT_INVH 0x0044 ///< Inverted viewport height.
|
||||
#define GPUREG_0045 0x0045 ///< Unknown
|
||||
#define GPUREG_0046 0x0046 ///< Unknown
|
||||
#define GPUREG_FRAGOP_CLIP 0x0047 ///< Unknown
|
||||
#define GPUREG_FRAGOP_CLIP_DATA0 0x0048 ///< Unknown
|
||||
#define GPUREG_FRAGOP_CLIP_DATA1 0x0049 ///< Unknown
|
||||
#define GPUREG_FRAGOP_CLIP_DATA2 0x004A ///< Unknown
|
||||
#define GPUREG_FRAGOP_CLIP_DATA3 0x004B ///< Unknown
|
||||
#define GPUREG_004C 0x004C ///< Unknown
|
||||
#define GPUREG_DEPTHMAP_SCALE 0x004D ///< Depth map scale.
|
||||
#define GPUREG_DEPTHMAP_OFFSET 0x004E ///< Depth map offset.
|
||||
#define GPUREG_SH_OUTMAP_TOTAL 0x004F ///< Shader output map total.
|
||||
#define GPUREG_SH_OUTMAP_O0 0x0050 ///< Shader output map 0.
|
||||
#define GPUREG_SH_OUTMAP_O1 0x0051 ///< Shader output map 1.
|
||||
#define GPUREG_SH_OUTMAP_O2 0x0052 ///< Shader output map 2.
|
||||
#define GPUREG_SH_OUTMAP_O3 0x0053 ///< Shader output map 3.
|
||||
#define GPUREG_SH_OUTMAP_O4 0x0054 ///< Shader output map 4.
|
||||
#define GPUREG_SH_OUTMAP_O5 0x0055 ///< Shader output map 5.
|
||||
#define GPUREG_SH_OUTMAP_O6 0x0056 ///< Shader output map 6.
|
||||
#define GPUREG_0057 0x0057 ///< Unknown
|
||||
#define GPUREG_0058 0x0058 ///< Unknown
|
||||
#define GPUREG_0059 0x0059 ///< Unknown
|
||||
#define GPUREG_005A 0x005A ///< Unknown
|
||||
#define GPUREG_005B 0x005B ///< Unknown
|
||||
#define GPUREG_005C 0x005C ///< Unknown
|
||||
#define GPUREG_005D 0x005D ///< Unknown
|
||||
#define GPUREG_005E 0x005E ///< Unknown
|
||||
#define GPUREG_005F 0x005F ///< Unknown
|
||||
#define GPUREG_0060 0x0060 ///< Unknown
|
||||
#define GPUREG_EARLYDEPTH_FUNC 0x0061 ///< Unknown
|
||||
#define GPUREG_EARLYDEPTH_TEST1 0x0062 ///< Unknown
|
||||
#define GPUREG_EARLYDEPTH_CLEAR 0x0063 ///< Unknown
|
||||
#define GPUREG_SH_OUTATTR_MODE 0x0064 ///< Shader output attributes mode.
|
||||
#define GPUREG_SCISSORTEST_MODE 0x0065 ///< Scissor test mode.
|
||||
#define GPUREG_SCISSORTEST_POS 0x0066 ///< Scissor test position.
|
||||
#define GPUREG_SCISSORTEST_DIM 0x0067 ///< Scissor text dimensions.
|
||||
#define GPUREG_VIEWPORT_XY 0x0068 ///< Viewport X and Y.
|
||||
#define GPUREG_0069 0x0069 ///< Unknown
|
||||
#define GPUREG_EARLYDEPTH_DATA 0x006A ///< Unknown
|
||||
#define GPUREG_006B 0x006B ///< Unknown
|
||||
#define GPUREG_006C 0x006C ///< Unknown
|
||||
#define GPUREG_DEPTHMAP_ENABLE 0x006D ///< Depth map enable.
|
||||
#define GPUREG_RENDERBUF_DIM 0x006E ///< Renderbuffer dimensions.
|
||||
#define GPUREG_SH_OUTATTR_CLOCK 0x006F ///< Shader output attributes clock enable.
|
||||
#define GPUREG_0070 0x0070 ///< Unknown
|
||||
#define GPUREG_0071 0x0071 ///< Unknown
|
||||
#define GPUREG_0072 0x0072 ///< Unknown
|
||||
#define GPUREG_0073 0x0073 ///< Unknown
|
||||
#define GPUREG_0074 0x0074 ///< Unknown
|
||||
#define GPUREG_0075 0x0075 ///< Unknown
|
||||
#define GPUREG_0076 0x0076 ///< Unknown
|
||||
#define GPUREG_0077 0x0077 ///< Unknown
|
||||
#define GPUREG_0078 0x0078 ///< Unknown
|
||||
#define GPUREG_0079 0x0079 ///< Unknown
|
||||
#define GPUREG_007A 0x007A ///< Unknown
|
||||
#define GPUREG_007B 0x007B ///< Unknown
|
||||
#define GPUREG_007C 0x007C ///< Unknown
|
||||
#define GPUREG_007D 0x007D ///< Unknown
|
||||
#define GPUREG_007E 0x007E ///< Unknown
|
||||
#define GPUREG_007F 0x007F ///< Unknown
|
||||
///@}
|
||||
|
||||
///@name Texturing registers (0x080-0x0FF)
|
||||
///@{
|
||||
#define GPUREG_TEXUNIT_CONFIG 0x0080 ///< Texture unit configuration.
|
||||
#define GPUREG_TEXUNIT0_BORDER_COLOR 0x0081 ///< Texture unit 0 border color.
|
||||
#define GPUREG_TEXUNIT0_DIM 0x0082 ///< Texture unit 0 dimensions.
|
||||
#define GPUREG_TEXUNIT0_PARAM 0x0083 ///< Texture unit 0 parameters.
|
||||
#define GPUREG_TEXUNIT0_LOD 0x0084 ///< Texture unit 0 LOD.
|
||||
#define GPUREG_TEXUNIT0_ADDR1 0x0085 ///< Texture unit 0 address.
|
||||
#define GPUREG_TEXUNIT0_ADDR2 0x0086 ///< Unknown.
|
||||
#define GPUREG_TEXUNIT0_ADDR3 0x0087 ///< Unknown.
|
||||
#define GPUREG_TEXUNIT0_ADDR4 0x0088 ///< Unknown.
|
||||
#define GPUREG_TEXUNIT0_ADDR5 0x0089 ///< Unknown.
|
||||
#define GPUREG_TEXUNIT0_ADDR6 0x008A ///< Unknown.
|
||||
#define GPUREG_TEXUNIT0_SHADOW 0x008B ///< Unknown.
|
||||
#define GPUREG_008C 0x008C ///< Unknown.
|
||||
#define GPUREG_008D 0x008D ///< Unknown.
|
||||
#define GPUREG_TEXUNIT0_TYPE 0x008E ///< Texture unit 0 type.
|
||||
#define GPUREG_LIGHTING_ENABLE0 0x008F ///< Lighting toggle.
|
||||
#define GPUREG_0090 0x0090 ///< Unknown.
|
||||
#define GPUREG_TEXUNIT1_BORDER_COLOR 0x0091 ///< Texture unit 1 border color.
|
||||
#define GPUREG_TEXUNIT1_DIM 0x0092 ///< Texture unit 1 dimensions.
|
||||
#define GPUREG_TEXUNIT1_PARAM 0x0093 ///< Texture unit 1 parameters.
|
||||
#define GPUREG_TEXUNIT1_LOD 0x0094 ///< Texture unit 1 LOD.
|
||||
#define GPUREG_TEXUNIT1_ADDR 0x0095 ///< Texture unit 1 address.
|
||||
#define GPUREG_TEXUNIT1_TYPE 0x0096 ///< Texture unit 1 type.
|
||||
#define GPUREG_0097 0x0097 ///< Unknown.
|
||||
#define GPUREG_0098 0x0098 ///< Unknown.
|
||||
#define GPUREG_TEXUNIT2_BORDER_COLOR 0x0099 ///< Texture unit 2 border color.
|
||||
#define GPUREG_TEXUNIT2_DIM 0x009A ///< Texture unit 2 dimensions.
|
||||
#define GPUREG_TEXUNIT2_PARAM 0x009B ///< Texture unit 2 parameters.
|
||||
#define GPUREG_TEXUNIT2_LOD 0x009C ///< Texture unit 2 LOD.
|
||||
#define GPUREG_TEXUNIT2_ADDR 0x009D ///< Texture unit 2 address.
|
||||
#define GPUREG_TEXUNIT2_TYPE 0x009E ///< Texture unit 2 type.
|
||||
#define GPUREG_009F 0x009F ///< Unknown.
|
||||
#define GPUREG_00A0 0x00A0 ///< Unknown.
|
||||
#define GPUREG_00A1 0x00A1 ///< Unknown.
|
||||
#define GPUREG_00A2 0x00A2 ///< Unknown.
|
||||
#define GPUREG_00A3 0x00A3 ///< Unknown.
|
||||
#define GPUREG_00A4 0x00A4 ///< Unknown.
|
||||
#define GPUREG_00A5 0x00A5 ///< Unknown.
|
||||
#define GPUREG_00A6 0x00A6 ///< Unknown.
|
||||
#define GPUREG_00A7 0x00A7 ///< Unknown.
|
||||
#define GPUREG_TEXUNIT3_PROCTEX0 0x00A8 ///< Unknown.
|
||||
#define GPUREG_TEXUNIT3_PROCTEX1 0x00A9 ///< Unknown.
|
||||
#define GPUREG_TEXUNIT3_PROCTEX2 0x00AA ///< Unknown.
|
||||
#define GPUREG_TEXUNIT3_PROCTEX3 0x00AB ///< Unknown.
|
||||
#define GPUREG_TEXUNIT3_PROCTEX4 0x00A ///< Unknown.
|
||||
#define GPUREG_TEXUNIT3_PROCTEX5 0x00D ///< Unknown.
|
||||
#define GPUREG_00AE 0x00AE ///< Unknown.
|
||||
#define GPUREG_PROCTEX_LUT 0x00AF ///< Unknown.
|
||||
#define GPUREG_PROCTEX_LUT_DATA0 0x00B0 ///< Unknown.
|
||||
#define GPUREG_PROCTEX_LUT_DATA1 0x00B1 ///< Unknown.
|
||||
#define GPUREG_PROCTEX_LUT_DATA2 0x00B2 ///< Unknown.
|
||||
#define GPUREG_PROCTEX_LUT_DATA3 0x00B3 ///< Unknown.
|
||||
#define GPUREG_PROCTEX_LUT_DATA4 0x00B4 ///< Unknown.
|
||||
#define GPUREG_PROCTEX_LUT_DATA5 0x00B5 ///< Unknown.
|
||||
#define GPUREG_PROCTEX_LUT_DATA6 0x00B6 ///< Unknown.
|
||||
#define GPUREG_PROCTEX_LUT_DATA7 0x00B7 ///< Unknown.
|
||||
#define GPUREG_00B8 0x00B8 ///< Unknown.
|
||||
#define GPUREG_00B9 0x00B9 ///< Unknown.
|
||||
#define GPUREG_00BA 0x00BA ///< Unknown.
|
||||
#define GPUREG_00BB 0x00BB ///< Unknown.
|
||||
#define GPUREG_00BC 0x00BC ///< Unknown.
|
||||
#define GPUREG_00BD 0x00BD ///< Unknown.
|
||||
#define GPUREG_00BE 0x00BE ///< Unknown.
|
||||
#define GPUREG_00BF 0x00BF ///< Unknown.
|
||||
#define GPUREG_TEXENV0_SOURCE 0x00C0 ///< Texture env 0 source.
|
||||
#define GPUREG_TEXENV0_OPERAND 0x00C1 ///< Texture env 0 operand.
|
||||
#define GPUREG_TEXENV0_COMBINER 0x00C2 ///< Texture env 0 combiner.
|
||||
#define GPUREG_TEXENV0_COLOR 0x00C3 ///< Texture env 0 color.
|
||||
#define GPUREG_TEXENV0_SCALE 0x00C4 ///< Texture env 0 scale.
|
||||
#define GPUREG_00C5 0x00C5 ///< Unknown.
|
||||
#define GPUREG_00C6 0x00C6 ///< Unknown.
|
||||
#define GPUREG_00C7 0x00C7 ///< Unknown.
|
||||
#define GPUREG_TEXENV1_SOURCE 0x00C8 ///< Texture env 1 source.
|
||||
#define GPUREG_TEXENV1_OPERAND 0x00C9 ///< Texture env 1 operand.
|
||||
#define GPUREG_TEXENV1_COMBINER 0x00CA ///< Texture env 1 combiner.
|
||||
#define GPUREG_TEXENV1_COLOR 0x00CB ///< Texture env 1 color.
|
||||
#define GPUREG_TEXENV1_SCALE 0x00CC ///< Texture env 1 scale.
|
||||
#define GPUREG_00CD 0x00CD ///< Unknown.
|
||||
#define GPUREG_00CE 0x00CE ///< Unknown.
|
||||
#define GPUREG_00CF 0x00CF ///< Unknown.
|
||||
#define GPUREG_TEXENV2_SOURCE 0x00D0 ///< Texture env 2 source.
|
||||
#define GPUREG_TEXENV2_OPERAND 0x00D1 ///< Texture env 2 operand.
|
||||
#define GPUREG_TEXENV2_COMBINER 0x00D2 ///< Texture env 2 combiner.
|
||||
#define GPUREG_TEXENV2_COLOR 0x00D3 ///< Texture env 2 color.
|
||||
#define GPUREG_TEXENV2_SCALE 0x00D4 ///< Texture env 2 scale.
|
||||
#define GPUREG_00D5 0x00D5 ///< Unknown.
|
||||
#define GPUREG_00D6 0x00D6 ///< Unknown.
|
||||
#define GPUREG_00D7 0x00D7 ///< Unknown.
|
||||
#define GPUREG_TEXENV3_SOURCE 0x00D8 ///< Texture env 3 source.
|
||||
#define GPUREG_TEXENV3_OPERAND 0x00D9 ///< Texture env 3 operand.
|
||||
#define GPUREG_TEXENV3_COMBINER 0x00DA ///< Texture env 3 combiner.
|
||||
#define GPUREG_TEXENV3_COLOR 0x00DB ///< Texture env 3 color.
|
||||
#define GPUREG_TEXENV3_SCALE 0x00DC ///< Texture env 3 scale.
|
||||
#define GPUREG_00DD 0x00DD ///< Unknown.
|
||||
#define GPUREG_00DE 0x00DE ///< Unknown.
|
||||
#define GPUREG_00DF 0x00DF ///< Unknown.
|
||||
#define GPUREG_TEXENV_UPDATE_BUFFER 0x00E0 ///< Texture env buffer update flag.
|
||||
#define GPUREG_FOG_COLOR 0x00E1 ///< Unknown.
|
||||
#define GPUREG_00E2 0x00E2 ///< Unknown.
|
||||
#define GPUREG_00E3 0x00E3 ///< Unknown.
|
||||
#define GPUREG_GAS_ATTENUATION 0x00E4 ///< Unknown.
|
||||
#define GPUREG_GAS_ACCMAX 0x00E5 ///< Unknown.
|
||||
#define GPUREG_FOG_LUT_INDEX 0x00E6 ///< Unknown.
|
||||
#define GPUREG_00E7 0x00E7 ///< Unknown.
|
||||
#define GPUREG_FOG_LUT_DATA0 0x00E8 ///< Unknown.
|
||||
#define GPUREG_FOG_LUT_DATA1 0x00E9 ///< Unknown.
|
||||
#define GPUREG_FOG_LUT_DATA2 0x00EA ///< Unknown.
|
||||
#define GPUREG_FOG_LUT_DATA3 0x00EB ///< Unknown.
|
||||
#define GPUREG_FOG_LUT_DATA4 0x00EC ///< Unknown.
|
||||
#define GPUREG_FOG_LUT_DATA5 0x00ED ///< Unknown.
|
||||
#define GPUREG_FOG_LUT_DATA6 0x00EE ///< Unknown.
|
||||
#define GPUREG_FOG_LUT_DATA7 0x00EF ///< Unknown.
|
||||
#define GPUREG_TEXENV4_SOURCE 0x00F0 ///< Texture env 4 source.
|
||||
#define GPUREG_TEXENV4_OPERAND 0x00F1 ///< Texture env 4 operand.
|
||||
#define GPUREG_TEXENV4_COMBINER 0x00F2 ///< Texture env 4 combiner.
|
||||
#define GPUREG_TEXENV4_COLOR 0x00F3 ///< Texture env 4 color.
|
||||
#define GPUREG_TEXENV4_SCALE 0x00F4 ///< Texture env 4 scale.
|
||||
#define GPUREG_00F5 0x00F5 ///< Unknown.
|
||||
#define GPUREG_00F6 0x00F6 ///< Unknown.
|
||||
#define GPUREG_00F7 0x00F7 ///< Unknown.
|
||||
#define GPUREG_TEXENV5_SOURCE 0x00F8 ///< Texture env 5 source.
|
||||
#define GPUREG_TEXENV5_OPERAND 0x00F9 ///< Texture env 5 operand.
|
||||
#define GPUREG_TEXENV5_COMBINER 0x00FA ///< Texture env 5 combiner.
|
||||
#define GPUREG_TEXENV5_COLOR 0x00FB ///< Texture env 5 color.
|
||||
#define GPUREG_TEXENV5_SCALE 0x00FC ///< Texture env 5 scale.
|
||||
#define GPUREG_TEXENV_BUFFER_COLOR 0x00FD ///< Texture env buffer color.
|
||||
#define GPUREG_00FE 0x00FE ///< Unknown.
|
||||
#define GPUREG_00FF 0x00FF ///< Unknown.
|
||||
///@}
|
||||
|
||||
///@name Framebuffer registers (0x100-0x13F)
|
||||
///@{
|
||||
#define GPUREG_COLOR_OPERATION 0x0100 ///< Configures fragment operation and blend mode.
|
||||
#define GPUREG_BLEND_FUNC 0x0101 ///< Blend function configuration.
|
||||
#define GPUREG_LOGIC_OP 0x0102 ///< Logical operator configuration.
|
||||
#define GPUREG_BLEND_COLOR 0x0103 ///< Blend color.
|
||||
#define GPUREG_FRAGOP_ALPHA_TEST 0x0104 ///< Alpha test configuration.
|
||||
#define GPUREG_STENCIL_TEST 0x0105 ///< Stencil test configuration.
|
||||
#define GPUREG_STENCIL_OP 0x0106 ///< Stencil test operation.
|
||||
#define GPUREG_DEPTH_COLOR_MASK 0x0107 ///< Depth test and color mask configuration.
|
||||
#define GPUREG_0108 0x0108 ///< Unknown.
|
||||
#define GPUREG_0109 0x0109 ///< Unknown.
|
||||
#define GPUREG_010A 0x010A ///< Unknown.
|
||||
#define GPUREG_010B 0x010B ///< Unknown.
|
||||
#define GPUREG_010C 0x010C ///< Unknown.
|
||||
#define GPUREG_010D 0x010D ///< Unknown.
|
||||
#define GPUREG_010E 0x010E ///< Unknown.
|
||||
#define GPUREG_010F 0x010F ///< Unknown.
|
||||
#define GPUREG_FRAMEBUFFER_INVALIDATE 0x0110 ///< Invalidates the frame buffer.
|
||||
#define GPUREG_FRAMEBUFFER_FLUSH 0x0111 ///< Flushes the frame buffer.
|
||||
#define GPUREG_COLORBUFFER_READ 0x0112 ///< Reads from the color buffer.
|
||||
#define GPUREG_COLORBUFFER_WRITE 0x0113 ///< Writes to the color buffer.
|
||||
#define GPUREG_DEPTHBUFFER_READ 0x0114 ///< Reads from the depth buffer.
|
||||
#define GPUREG_DEPTHBUFFER_WRITE 0x0115 ///< Writes to the depth buffer.
|
||||
#define GPUREG_DEPTHBUFFER_FORMAT 0x0116 ///< Depth buffer format.
|
||||
#define GPUREG_COLORBUFFER_FORMAT 0x0117 ///< Color buffer format.
|
||||
#define GPUREG_EARLYDEPTH_TEST2 0x0118 ///< Unknown.
|
||||
#define GPUREG_0119 0x0119 ///< Unknown.
|
||||
#define GPUREG_011A 0x011A ///< Unknown.
|
||||
#define GPUREG_FRAMEBUFFER_BLOCK32 0x011B ///< Frame buffer block 32.
|
||||
#define GPUREG_DEPTHBUFFER_LOC 0x011C ///< Depth buffer location.
|
||||
#define GPUREG_COLORBUFFER_LOC 0x011D ///< Color buffer location.
|
||||
#define GPUREG_FRAMEBUFFER_DIM 0x011E ///< Frame buffer dimensions.
|
||||
#define GPUREG_011F 0x011F ///< Unknown.
|
||||
#define GPUREG_GAS_LIGHT_XY 0x0120 ///< Unknown.
|
||||
#define GPUREG_GAS_LIGHT_Z 0x0121 ///< Unknown.
|
||||
#define GPUREG_GAS_LIGHT_Z_COLOR 0x0122 ///< Unknown.
|
||||
#define GPUREG_GAS_LUT_INDEX 0x0123 ///< Unknown.
|
||||
#define GPUREG_GAS_LUT_DATA 0x0124 ///< Unknown.
|
||||
#define GPUREG_GAS_ACCMAX_FEEDBACK 0x0125 ///< Unknown.
|
||||
#define GPUREG_GAS_DELTAZ_DEPTH 0x0126 ///< Unknown.
|
||||
#define GPUREG_0127 0x0127 ///< Unknown.
|
||||
#define GPUREG_0128 0x0128 ///< Unknown.
|
||||
#define GPUREG_0129 0x0129 ///< Unknown.
|
||||
#define GPUREG_012A 0x012A ///< Unknown.
|
||||
#define GPUREG_012B 0x012B ///< Unknown.
|
||||
#define GPUREG_012C 0x012C ///< Unknown.
|
||||
#define GPUREG_012D 0x012D ///< Unknown.
|
||||
#define GPUREG_012E 0x012E ///< Unknown.
|
||||
#define GPUREG_012F 0x012F ///< Unknown.
|
||||
#define GPUREG_FRAGOP_SHADOW 0x0130 ///< Unknown.
|
||||
#define GPUREG_0131 0x0131 ///< Unknown.
|
||||
#define GPUREG_0132 0x0132 ///< Unknown.
|
||||
#define GPUREG_0133 0x0133 ///< Unknown.
|
||||
#define GPUREG_0134 0x0134 ///< Unknown.
|
||||
#define GPUREG_0135 0x0135 ///< Unknown.
|
||||
#define GPUREG_0136 0x0136 ///< Unknown.
|
||||
#define GPUREG_0137 0x0137 ///< Unknown.
|
||||
#define GPUREG_0138 0x0138 ///< Unknown.
|
||||
#define GPUREG_0139 0x0139 ///< Unknown.
|
||||
#define GPUREG_013A 0x013A ///< Unknown.
|
||||
#define GPUREG_013B 0x013B ///< Unknown.
|
||||
#define GPUREG_013C 0x013C ///< Unknown.
|
||||
#define GPUREG_013D 0x013D ///< Unknown.
|
||||
#define GPUREG_013E 0x013E ///< Unknown.
|
||||
#define GPUREG_013F 0x013F ///< Unknown.
|
||||
///@}
|
||||
|
||||
///@name Fragment lighting registers (0x140-0x1FF)
|
||||
///@{
|
||||
#define GPUREG_LIGHT0_SPECULAR0 0x0140 ///< Light 0 specular lighting.
|
||||
#define GPUREG_LIGHT0_SPECULAR1 0x0141 ///< Light 0 specular lighting.
|
||||
#define GPUREG_LIGHT0_DIFFUSE 0x0142 ///< Light 0 diffuse lighting.
|
||||
#define GPUREG_LIGHT0_AMBIENT 0x0143 ///< Light 0 ambient lighting.
|
||||
#define GPUREG_LIGHT0_XY 0x0144 ///< Light 0 X and Y.
|
||||
#define GPUREG_LIGHT0_Z 0x0145 ///< Light 0 Z.
|
||||
#define GPUREG_LIGHT0_SPOTDIR_XY 0x0146 ///< Light 0 spotlight direction X and Y.
|
||||
#define GPUREG_LIGHT0_SPOTDIR_Z 0x0147 ///< Light 0 spotlight direction Z.
|
||||
#define GPUREG_0148 0x0148 ///< Unknown.
|
||||
#define GPUREG_LIGHT0_CONFIG 0x0149 ///< Light 0 configuration.
|
||||
#define GPUREG_LIGHT0_ATTENUATION_BIAS 0x014A ///< Light 0 attenuation bias.
|
||||
#define GPUREG_LIGHT0_ATTENUATION_SCALE 0x014B ///< Light 0 attenuation scale.
|
||||
#define GPUREG_014C 0x014C ///< Unknown.
|
||||
#define GPUREG_014D 0x014D ///< Unknown.
|
||||
#define GPUREG_014E 0x014E ///< Unknown.
|
||||
#define GPUREG_014F 0x014F ///< Unknown.
|
||||
#define GPUREG_LIGHT1_SPECULAR0 0x0150 ///< Light 1 specular lighting.
|
||||
#define GPUREG_LIGHT1_SPECULAR1 0x0151 ///< Light 1 specular lighting.
|
||||
#define GPUREG_LIGHT1_DIFFUSE 0x0152 ///< Light 1 diffuse lighting.
|
||||
#define GPUREG_LIGHT1_AMBIENT 0x0153 ///< Light 1 ambient lighting.
|
||||
#define GPUREG_LIGHT1_XY 0x0154 ///< Light 1 X and Y.
|
||||
#define GPUREG_LIGHT1_Z 0x0155 ///< Light 1 Z.
|
||||
#define GPUREG_LIGHT1_SPOTDIR_XY 0x0156 ///< Light 1 spotlight direction X and Y.
|
||||
#define GPUREG_LIGHT1_SPOTDIR_Z 0x0157 ///< Light 1 spotlight direction Z.
|
||||
#define GPUREG_0158 0x0158 ///< Unknown.
|
||||
#define GPUREG_LIGHT1_CONFIG 0x0159 ///< Light 1 configuration.
|
||||
#define GPUREG_LIGHT1_ATTENUATION_BIAS 0x015A ///< Light 1 attenuation bias.
|
||||
#define GPUREG_LIGHT1_ATTENUATION_SCALE 0x015B ///< Light 1 attenuation scale.
|
||||
#define GPUREG_015C 0x015C ///< Unknown.
|
||||
#define GPUREG_015D 0x015D ///< Unknown.
|
||||
#define GPUREG_015E 0x015E ///< Unknown.
|
||||
#define GPUREG_015F 0x015F ///< Unknown.
|
||||
#define GPUREG_LIGHT2_SPECULAR0 0x0160 ///< Light 2 specular lighting.
|
||||
#define GPUREG_LIGHT2_SPECULAR1 0x0161 ///< Light 2 specular lighting.
|
||||
#define GPUREG_LIGHT2_DIFFUSE 0x0162 ///< Light 2 diffuse lighting.
|
||||
#define GPUREG_LIGHT2_AMBIENT 0x0163 ///< Light 2 ambient lighting.
|
||||
#define GPUREG_LIGHT2_XY 0x0164 ///< Light 2 X and Y.
|
||||
#define GPUREG_LIGHT2_Z 0x0165 ///< Light 2 Z.
|
||||
#define GPUREG_LIGHT2_SPOTDIR_XY 0x0166 ///< Light 2 spotlight direction X and Y.
|
||||
#define GPUREG_LIGHT2_SPOTDIR_Z 0x0167 ///< Light 2 spotlight direction Z.
|
||||
#define GPUREG_0168 0x0168 ///< Unknown.
|
||||
#define GPUREG_LIGHT2_CONFIG 0x0169 ///< Light 2 configuration.
|
||||
#define GPUREG_LIGHT2_ATTENUATION_BIAS 0x016A ///< Light 2 attenuation bias.
|
||||
#define GPUREG_LIGHT2_ATTENUATION_SCALE 0x016B ///< Light 2 attenuation scale.
|
||||
#define GPUREG_016C 0x016C ///< Unknown.
|
||||
#define GPUREG_016D 0x016D ///< Unknown.
|
||||
#define GPUREG_016E 0x016E ///< Unknown.
|
||||
#define GPUREG_016F 0x016F ///< Unknown.
|
||||
#define GPUREG_LIGHT3_SPECULAR0 0x0170 ///< Light 3 specular lighting.
|
||||
#define GPUREG_LIGHT3_SPECULAR1 0x0171 ///< Light 3 specular lighting.
|
||||
#define GPUREG_LIGHT3_DIFFUSE 0x0172 ///< Light 3 diffuse lighting.
|
||||
#define GPUREG_LIGHT3_AMBIENT 0x0173 ///< Light 3 ambient lighting.
|
||||
#define GPUREG_LIGHT3_XY 0x0174 ///< Light 3 X and Y.
|
||||
#define GPUREG_LIGHT3_Z 0x0175 ///< Light 3 Z.
|
||||
#define GPUREG_LIGHT3_SPOTDIR_XY 0x0176 ///< Light 3 spotlight direction X and Y.
|
||||
#define GPUREG_LIGHT3_SPOTDIR_Z 0x0177 ///< Light 3 spotlight direction Z.
|
||||
#define GPUREG_0178 0x0178 ///< Unknown.
|
||||
#define GPUREG_LIGHT3_CONFIG 0x0179 ///< Light 3 configuration.
|
||||
#define GPUREG_LIGHT3_ATTENUATION_BIAS 0x017A ///< Light 3 attenuation bias.
|
||||
#define GPUREG_LIGHT3_ATTENUATION_SCALE 0x017B ///< Light 3 attenuation scale.
|
||||
#define GPUREG_017C 0x017C ///< Unknown.
|
||||
#define GPUREG_017D 0x017D ///< Unknown.
|
||||
#define GPUREG_017E 0x017E ///< Unknown.
|
||||
#define GPUREG_017F 0x017F ///< Unknown.
|
||||
#define GPUREG_LIGHT4_SPECULAR0 0x0180 ///< Light 4 specular lighting.
|
||||
#define GPUREG_LIGHT4_SPECULAR1 0x0181 ///< Light 4 specular lighting.
|
||||
#define GPUREG_LIGHT4_DIFFUSE 0x0182 ///< Light 4 diffuse lighting.
|
||||
#define GPUREG_LIGHT4_AMBIENT 0x0183 ///< Light 4 ambient lighting.
|
||||
#define GPUREG_LIGHT4_XY 0x0184 ///< Light 4 X and Y.
|
||||
#define GPUREG_LIGHT4_Z 0x0185 ///< Light 4 Z.
|
||||
#define GPUREG_LIGHT4_SPOTDIR_XY 0x0186 ///< Light 4 spotlight direction X and Y.
|
||||
#define GPUREG_LIGHT4_SPOTDIR_Z 0x0187 ///< Light 4 spotlight direction Z.
|
||||
#define GPUREG_0188 0x0188 ///< Unknown.
|
||||
#define GPUREG_LIGHT4_CONFIG 0x0189 ///< Light 4 configuration.
|
||||
#define GPUREG_LIGHT4_ATTENUATION_BIAS 0x018A ///< Light 4 attenuation bias.
|
||||
#define GPUREG_LIGHT4_ATTENUATION_SCALE 0x018B ///< Light 4 attenuation scale.
|
||||
#define GPUREG_018C 0x018C ///< Unknown.
|
||||
#define GPUREG_018D 0x018D ///< Unknown.
|
||||
#define GPUREG_018E 0x018E ///< Unknown.
|
||||
#define GPUREG_018F 0x018F ///< Unknown.
|
||||
#define GPUREG_LIGHT5_SPECULAR0 0x0190 ///< Light 5 specular lighting.
|
||||
#define GPUREG_LIGHT5_SPECULAR1 0x0191 ///< Light 5 specular lighting.
|
||||
#define GPUREG_LIGHT5_DIFFUSE 0x0192 ///< Light 5 diffuse lighting.
|
||||
#define GPUREG_LIGHT5_AMBIENT 0x0193 ///< Light 5 ambient lighting.
|
||||
#define GPUREG_LIGHT5_XY 0x0194 ///< Light 5 X and Y.
|
||||
#define GPUREG_LIGHT5_Z 0x0195 ///< Light 5 Z.
|
||||
#define GPUREG_LIGHT5_SPOTDIR_XY 0x0196 ///< Light 5 spotlight direction X and Y.
|
||||
#define GPUREG_LIGHT5_SPOTDIR_Z 0x0197 ///< Light 5 spotlight direction Z.
|
||||
#define GPUREG_0198 0x0198 ///< Unknown.
|
||||
#define GPUREG_LIGHT5_CONFIG 0x0199 ///< Light 5 configuration.
|
||||
#define GPUREG_LIGHT5_ATTENUATION_BIAS 0x019A ///< Light 5 attenuation bias.
|
||||
#define GPUREG_LIGHT5_ATTENUATION_SCALE 0x019B ///< Light 5 attenuation scale.
|
||||
#define GPUREG_019C 0x019C ///< Unknown.
|
||||
#define GPUREG_019D 0x019D ///< Unknown.
|
||||
#define GPUREG_019E 0x019E ///< Unknown.
|
||||
#define GPUREG_019F 0x019F ///< Unknown.
|
||||
#define GPUREG_LIGHT6_SPECULAR0 0x01A0 ///< Light 6 specular lighting.
|
||||
#define GPUREG_LIGHT6_SPECULAR1 0x01A1 ///< Light 6 specular lighting.
|
||||
#define GPUREG_LIGHT6_DIFFUSE 0x01A2 ///< Light 6 diffuse lighting.
|
||||
#define GPUREG_LIGHT6_AMBIENT 0x01A3 ///< Light 6 ambient lighting.
|
||||
#define GPUREG_LIGHT6_XY 0x01A4 ///< Light 6 X and Y.
|
||||
#define GPUREG_LIGHT6_Z 0x01A5 ///< Light 6 Z.
|
||||
#define GPUREG_LIGHT6_SPOTDIR_XY 0x01A6 ///< Light 6 spotlight direction X and Y.
|
||||
#define GPUREG_LIGHT6_SPOTDIR_Z 0x01A7 ///< Light 6 spotlight direction Z.
|
||||
#define GPUREG_01A8 0x01A8 ///< Unknown.
|
||||
#define GPUREG_LIGHT6_CONFIG 0x01A9 ///< Light 6 configuration.
|
||||
#define GPUREG_LIGHT6_ATTENUATION_BIAS 0x01AA ///< Light 6 attenuation bias.
|
||||
#define GPUREG_LIGHT6_ATTENUATION_SCALE 0x01AB ///< Light 6 attenuation scale.
|
||||
#define GPUREG_01AC 0x01AC ///< Unknown.
|
||||
#define GPUREG_01AD 0x01AD ///< Unknown.
|
||||
#define GPUREG_01AE 0x01AE ///< Unknown.
|
||||
#define GPUREG_01AF 0x01AF ///< Unknown.
|
||||
#define GPUREG_LIGHT7_SPECULAR0 0x01B0 ///< Light 7 specular lighting.
|
||||
#define GPUREG_LIGHT7_SPECULAR1 0x01B1 ///< Light 7 specular lighting.
|
||||
#define GPUREG_LIGHT7_DIFFUSE 0x01B2 ///< Light 7 diffuse lighting.
|
||||
#define GPUREG_LIGHT7_AMBIENT 0x01B3 ///< Light 7 ambient lighting.
|
||||
#define GPUREG_LIGHT7_XY 0x01B4 ///< Light 7 X and Y.
|
||||
#define GPUREG_LIGHT7_Z 0x01B5 ///< Light 7 Z.
|
||||
#define GPUREG_LIGHT7_SPOTDIR_XY 0x01B6 ///< Light 7 spotlight direction X and Y.
|
||||
#define GPUREG_LIGHT7_SPOTDIR_Z 0x01B7 ///< Light 7 spotlight direction Z.
|
||||
#define GPUREG_01B8 0x01B8 ///< Unknown.
|
||||
#define GPUREG_LIGHT7_CONFIG 0x01B9 ///< Light 7 configuration.
|
||||
#define GPUREG_LIGHT7_ATTENUATION_BIAS 0x01BA ///< Light 7 attenuation bias.
|
||||
#define GPUREG_LIGHT7_ATTENUATION_SCALE 0x01BB ///< Light 7 attenuation scale.
|
||||
#define GPUREG_01BC 0x01BC ///< Unknown.
|
||||
#define GPUREG_01BD 0x01BD ///< Unknown.
|
||||
#define GPUREG_01BE 0x01BE ///< Unknown.
|
||||
#define GPUREG_01BF 0x01BF ///< Unknown.
|
||||
#define GPUREG_LIGHTING_AMBIENT 0x01C0 ///< Ambient lighting.
|
||||
#define GPUREG_01C1 0x01C1 ///< Unknown.
|
||||
#define GPUREG_LIGHTING_NUM_LIGHTS 0x01C2 ///< Number of lights.
|
||||
#define GPUREG_LIGHTING_CONFIG0 0x01C3 ///< Lighting configuration.
|
||||
#define GPUREG_LIGHTING_CONFIG1 0x01C4 ///< Lighting configuration.
|
||||
#define GPUREG_LIGHTING_LUT_INDEX 0x01C5 ///< LUT index.
|
||||
#define GPUREG_LIGHTING_ENABLE1 0x01C6 ///< Lighting toggle.
|
||||
#define GPUREG_01C7 0x01C7 ///< Unknown.
|
||||
#define GPUREG_LIGHTING_LUT_DATA0 0x01C8 ///< LUT data 0.
|
||||
#define GPUREG_LIGHTING_LUT_DATA1 0x01C9 ///< LUT data 1.
|
||||
#define GPUREG_LIGHTING_LUT_DATA2 0x01CA ///< LUT data 2.
|
||||
#define GPUREG_LIGHTING_LUT_DATA3 0x01CB ///< LUT data 3.
|
||||
#define GPUREG_LIGHTING_LUT_DATA4 0x01CC ///< LUT data 4.
|
||||
#define GPUREG_LIGHTING_LUT_DATA5 0x01CD ///< LUT data 5.
|
||||
#define GPUREG_LIGHTING_LUT_DATA6 0x01CE ///< LUT data 6.
|
||||
#define GPUREG_LIGHTING_LUT_DATA7 0x01CF ///< LUT data 7.
|
||||
#define GPUREG_LIGHTING_LUTINPUT_ABS 0x01D0 ///< LUT input abs.
|
||||
#define GPUREG_LIGHTING_LUTINPUT_SELECT 0x01D1 ///< LUT input selector.
|
||||
#define GPUREG_LIGHTING_LUTINPUT_SCALE 0x01D2 ///< LUT input scale.
|
||||
#define GPUREG_01D3 0x01D3 ///< Unknown.
|
||||
#define GPUREG_01D4 0x01D4 ///< Unknown.
|
||||
#define GPUREG_01D5 0x01D5 ///< Unknown.
|
||||
#define GPUREG_01D6 0x01D6 ///< Unknown.
|
||||
#define GPUREG_01D7 0x01D7 ///< Unknown.
|
||||
#define GPUREG_01D8 0x01D8 ///< Unknown.
|
||||
#define GPUREG_LIGHTING_LIGHT_PERMUTATION 0x01D9 ///< Light permutation.
|
||||
#define GPUREG_01DA 0x01DA ///< Unknown.
|
||||
#define GPUREG_01DB 0x01DB ///< Unknown.
|
||||
#define GPUREG_01DC 0x01DC ///< Unknown.
|
||||
#define GPUREG_01DD 0x01DD ///< Unknown.
|
||||
#define GPUREG_01DE 0x01DE ///< Unknown.
|
||||
#define GPUREG_01DF 0x01DF ///< Unknown.
|
||||
#define GPUREG_01E0 0x01E0 ///< Unknown.
|
||||
#define GPUREG_01E1 0x01E1 ///< Unknown.
|
||||
#define GPUREG_01E2 0x01E2 ///< Unknown.
|
||||
#define GPUREG_01E3 0x01E3 ///< Unknown.
|
||||
#define GPUREG_01E4 0x01E4 ///< Unknown.
|
||||
#define GPUREG_01E5 0x01E5 ///< Unknown.
|
||||
#define GPUREG_01E6 0x01E6 ///< Unknown.
|
||||
#define GPUREG_01E7 0x01E7 ///< Unknown.
|
||||
#define GPUREG_01E8 0x01E8 ///< Unknown.
|
||||
#define GPUREG_01E9 0x01E9 ///< Unknown.
|
||||
#define GPUREG_01EA 0x01EA ///< Unknown.
|
||||
#define GPUREG_01EB 0x01EB ///< Unknown.
|
||||
#define GPUREG_01EC 0x01EC ///< Unknown.
|
||||
#define GPUREG_01ED 0x01ED ///< Unknown.
|
||||
#define GPUREG_01EE 0x01EE ///< Unknown.
|
||||
#define GPUREG_01EF 0x01EF ///< Unknown.
|
||||
#define GPUREG_01F0 0x01F0 ///< Unknown.
|
||||
#define GPUREG_01F1 0x01F1 ///< Unknown.
|
||||
#define GPUREG_01F2 0x01F2 ///< Unknown.
|
||||
#define GPUREG_01F3 0x01F3 ///< Unknown.
|
||||
#define GPUREG_01F4 0x01F4 ///< Unknown.
|
||||
#define GPUREG_01F5 0x01F5 ///< Unknown.
|
||||
#define GPUREG_01F6 0x01F6 ///< Unknown.
|
||||
#define GPUREG_01F7 0x01F7 ///< Unknown.
|
||||
#define GPUREG_01F8 0x01F8 ///< Unknown.
|
||||
#define GPUREG_01F9 0x01F9 ///< Unknown.
|
||||
#define GPUREG_01FA 0x01FA ///< Unknown.
|
||||
#define GPUREG_01FB 0x01FB ///< Unknown.
|
||||
#define GPUREG_01FC 0x01FC ///< Unknown.
|
||||
#define GPUREG_01FD 0x01FD ///< Unknown.
|
||||
#define GPUREG_01FE 0x01FE ///< Unknown.
|
||||
#define GPUREG_01FF 0x01FF ///< Unknown.
|
||||
///@}
|
||||
|
||||
///@name Geometry pipeline registers (0x200-0x27F)
|
||||
///@{
|
||||
#define GPUREG_ATTRIBBUFFERS_LOC 0x0200 ///< Attribute buffers location.
|
||||
#define GPUREG_ATTRIBBUFFERS_FORMAT_LOW 0x0201 ///< Attribute buffers format low.
|
||||
#define GPUREG_ATTRIBBUFFERS_FORMAT_HIGH 0x0202 ///< Attribute buffers format high.
|
||||
#define GPUREG_ATTRIBBUFFER0_OFFSET 0x0203 ///< Attribute buffers 0 offset.
|
||||
#define GPUREG_ATTRIBBUFFER0_CONFIG1 0x0204 ///< Attribute buffers 0 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER0_CONFIG2 0x0205 ///< Attribute buffers 0 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER1_OFFSET 0x0206 ///< Attribute buffers 1 offset.
|
||||
#define GPUREG_ATTRIBBUFFER1_CONFIG1 0x0207 ///< Attribute buffers 1 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER1_CONFIG2 0x0208 ///< Attribute buffers 1 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER2_OFFSET 0x0209 ///< Attribute buffers 2 offset.
|
||||
#define GPUREG_ATTRIBBUFFER2_CONFIG1 0x020A ///< Attribute buffers 2 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER2_CONFIG2 0x020B ///< Attribute buffers 2 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER3_OFFSET 0x020C ///< Attribute buffers 3 offset.
|
||||
#define GPUREG_ATTRIBBUFFER3_CONFIG1 0x020D ///< Attribute buffers 3 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER3_CONFIG2 0x020E ///< Attribute buffers 3 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER4_OFFSET 0x020F ///< Attribute buffers 4 offset.
|
||||
#define GPUREG_ATTRIBBUFFER4_CONFIG1 0x0210 ///< Attribute buffers 4 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER4_CONFIG2 0x0211 ///< Attribute buffers 4 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER5_OFFSET 0x0212 ///< Attribute buffers 5 offset.
|
||||
#define GPUREG_ATTRIBBUFFER5_CONFIG1 0x0213 ///< Attribute buffers 5 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER5_CONFIG2 0x0214 ///< Attribute buffers 5 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER6_OFFSET 0x0215 ///< Attribute buffers 6 offset.
|
||||
#define GPUREG_ATTRIBBUFFER6_CONFIG1 0x0216 ///< Attribute buffers 6 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER6_CONFIG2 0x0217 ///< Attribute buffers 6 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER7_OFFSET 0x0218 ///< Attribute buffers 7 offset.
|
||||
#define GPUREG_ATTRIBBUFFER7_CONFIG1 0x0219 ///< Attribute buffers 7 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER7_CONFIG2 0x021A ///< Attribute buffers 7 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER8_OFFSET 0x021B ///< Attribute buffers 8 offset.
|
||||
#define GPUREG_ATTRIBBUFFER8_CONFIG1 0x021C ///< Attribute buffers 8 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER8_CONFIG2 0x021D ///< Attribute buffers 8 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER9_OFFSET 0x021E ///< Attribute buffers 9 offset.
|
||||
#define GPUREG_ATTRIBBUFFER9_CONFIG1 0x021F ///< Attribute buffers 9 configuration.
|
||||
#define GPUREG_ATTRIBBUFFER9_CONFIG2 0x0220 ///< Attribute buffers 9 configuration.
|
||||
#define GPUREG_ATTRIBBUFFERA_OFFSET 0x0221 ///< Attribute buffers A offset.
|
||||
#define GPUREG_ATTRIBBUFFERA_CONFIG1 0x0222 ///< Attribute buffers A configuration.
|
||||
#define GPUREG_ATTRIBBUFFERA_CONFIG2 0x0223 ///< Attribute buffers A configuration.
|
||||
#define GPUREG_ATTRIBBUFFERB_OFFSET 0x0224 ///< Attribute buffers B offset.
|
||||
#define GPUREG_ATTRIBBUFFERB_CONFIG1 0x0225 ///< Attribute buffers B configuration.
|
||||
#define GPUREG_ATTRIBBUFFERB_CONFIG2 0x0226 ///< Attribute buffers B configuration.
|
||||
#define GPUREG_INDEXBUFFER_CONFIG 0x0227 ///< Index buffer configuration.
|
||||
#define GPUREG_NUMVERTICES 0x0228 ///< Number of vertices.
|
||||
#define GPUREG_GEOSTAGE_CONFIG 0x0229 ///< Geometry stage configuration.
|
||||
#define GPUREG_VERTEX_OFFSET 0x022A ///< Vertex offset.
|
||||
#define GPUREG_022B 0x022B ///< Unknown.
|
||||
#define GPUREG_022C 0x022C ///< Unknown.
|
||||
#define GPUREG_POST_VERTEX_CACHE_NUM 0x022D ///< Unknown.
|
||||
#define GPUREG_DRAWARRAYS 0x022E ///< Draw arrays trigger.
|
||||
#define GPUREG_DRAWELEMENTS 0x022F ///< Draw arrays elements.
|
||||
#define GPUREG_0230 0x0230 ///< Unknown.
|
||||
#define GPUREG_VTX_FUNC 0x0231 ///< Unknown.
|
||||
#define GPUREG_FIXEDATTRIB_INDEX 0x0232 ///< Fixed attribute index.
|
||||
#define GPUREG_FIXEDATTRIB_DATA0 0x0233 ///< Fixed attribute data 0.
|
||||
#define GPUREG_FIXEDATTRIB_DATA1 0x0234 ///< Fixed attribute data 1.
|
||||
#define GPUREG_FIXEDATTRIB_DATA2 0x0235 ///< Fixed attribute data 2.
|
||||
#define GPUREG_0236 0x0236 ///< Unknown.
|
||||
#define GPUREG_0237 0x0237 ///< Unknown.
|
||||
#define GPUREG_CMDBUF_SIZE0 0x0238 ///< Command buffer size 0.
|
||||
#define GPUREG_CMDBUF_SIZE1 0x0239 ///< Command buffer size 1.
|
||||
#define GPUREG_CMDBUF_ADDR0 0x023A ///< Command buffer address 0.
|
||||
#define GPUREG_CMDBUF_ADDR1 0x023B ///< Command buffer address 1.
|
||||
#define GPUREG_CMDBUF_JUMP0 0x023C ///< Command buffer jump 0.
|
||||
#define GPUREG_CMDBUF_JUMP1 0x023D ///< Command buffer jump 1.
|
||||
#define GPUREG_023E 0x023E ///< Unknown.
|
||||
#define GPUREG_023F 0x023F ///< Unknown.
|
||||
#define GPUREG_0240 0x0240 ///< Unknown.
|
||||
#define GPUREG_0241 0x0241 ///< Unknown.
|
||||
#define GPUREG_VSH_NUM_ATTR 0x0242 ///< Unknown.
|
||||
#define GPUREG_0243 0x0243 ///< Unknown.
|
||||
#define GPUREG_VSH_COM_MODE 0x0244 ///< Unknown.
|
||||
#define GPUREG_START_DRAW_FUNC0 0x0245 ///< Unknown.
|
||||
#define GPUREG_0246 0x0246 ///< Unknown.
|
||||
#define GPUREG_0247 0x0247 ///< Unknown.
|
||||
#define GPUREG_0248 0x0248 ///< Unknown.
|
||||
#define GPUREG_0249 0x0249 ///< Unknown.
|
||||
#define GPUREG_VSH_OUTMAP_TOTAL1 0x024A ///< Unknown.
|
||||
#define GPUREG_024B 0x024B ///< Unknown.
|
||||
#define GPUREG_024C 0x024C ///< Unknown.
|
||||
#define GPUREG_024D 0x024D ///< Unknown.
|
||||
#define GPUREG_024E 0x024E ///< Unknown.
|
||||
#define GPUREG_024F 0x024F ///< Unknown.
|
||||
#define GPUREG_0250 0x0250 ///< Unknown.
|
||||
#define GPUREG_VSH_OUTMAP_TOTAL2 0x0251 ///< Unknown.
|
||||
#define GPUREG_GSH_MISC0 0x0252 ///< Unknown.
|
||||
#define GPUREG_GEOSTAGE_CONFIG2 0x0253 ///< Unknown.
|
||||
#define GPUREG_GSH_MISC1 0x0254 ///< Unknown.
|
||||
#define GPUREG_0255 0x0255 ///< Unknown.
|
||||
#define GPUREG_0256 0x0256 ///< Unknown.
|
||||
#define GPUREG_0257 0x0257 ///< Unknown.
|
||||
#define GPUREG_0258 0x0258 ///< Unknown.
|
||||
#define GPUREG_0259 0x0259 ///< Unknown.
|
||||
#define GPUREG_025A 0x025A ///< Unknown.
|
||||
#define GPUREG_025B 0x025B ///< Unknown.
|
||||
#define GPUREG_025C 0x025C ///< Unknown.
|
||||
#define GPUREG_025D 0x025D ///< Unknown.
|
||||
#define GPUREG_PRIMITIVE_CONFIG 0x025E ///< Primitive configuration.
|
||||
#define GPUREG_RESTART_PRIMITIVE 0x025F ///< Restart primitive flag.
|
||||
#define GPUREG_0260 0x0260 ///< Unknown.
|
||||
#define GPUREG_0261 0x0261 ///< Unknown.
|
||||
#define GPUREG_0262 0x0262 ///< Unknown.
|
||||
#define GPUREG_0263 0x0263 ///< Unknown.
|
||||
#define GPUREG_0264 0x0264 ///< Unknown.
|
||||
#define GPUREG_0265 0x0265 ///< Unknown.
|
||||
#define GPUREG_0266 0x0266 ///< Unknown.
|
||||
#define GPUREG_0267 0x0267 ///< Unknown.
|
||||
#define GPUREG_0268 0x0268 ///< Unknown.
|
||||
#define GPUREG_0269 0x0269 ///< Unknown.
|
||||
#define GPUREG_026A 0x026A ///< Unknown.
|
||||
#define GPUREG_026B 0x026B ///< Unknown.
|
||||
#define GPUREG_026C 0x026C ///< Unknown.
|
||||
#define GPUREG_026D 0x026D ///< Unknown.
|
||||
#define GPUREG_026E 0x026E ///< Unknown.
|
||||
#define GPUREG_026F 0x026F ///< Unknown.
|
||||
#define GPUREG_0270 0x0270 ///< Unknown.
|
||||
#define GPUREG_0271 0x0271 ///< Unknown.
|
||||
#define GPUREG_0272 0x0272 ///< Unknown.
|
||||
#define GPUREG_0273 0x0273 ///< Unknown.
|
||||
#define GPUREG_0274 0x0274 ///< Unknown.
|
||||
#define GPUREG_0275 0x0275 ///< Unknown.
|
||||
#define GPUREG_0276 0x0276 ///< Unknown.
|
||||
#define GPUREG_0277 0x0277 ///< Unknown.
|
||||
#define GPUREG_0278 0x0278 ///< Unknown.
|
||||
#define GPUREG_0279 0x0279 ///< Unknown.
|
||||
#define GPUREG_027A 0x027A ///< Unknown.
|
||||
#define GPUREG_027B 0x027B ///< Unknown.
|
||||
#define GPUREG_027C 0x027C ///< Unknown.
|
||||
#define GPUREG_027D 0x027D ///< Unknown.
|
||||
#define GPUREG_027E 0x027E ///< Unknown.
|
||||
#define GPUREG_027F 0x027F ///< Unknown.
|
||||
///@}
|
||||
|
||||
///@name Geometry shader registers (0x280-0x2AF)
|
||||
///@{
|
||||
#define GPUREG_GSH_BOOLUNIFORM 0x0280 ///< Geometry shader bool uniforms.
|
||||
#define GPUREG_GSH_INTUNIFORM_I0 0x0281 ///< Geometry shader integer uniform 0.
|
||||
#define GPUREG_GSH_INTUNIFORM_I1 0x0282 ///< Geometry shader integer uniform 1.
|
||||
#define GPUREG_GSH_INTUNIFORM_I2 0x0283 ///< Geometry shader integer uniform 2.
|
||||
#define GPUREG_GSH_INTUNIFORM_I3 0x0284 ///< Geometry shader integer uniform 3.
|
||||
#define GPUREG_0285 0x0285 ///< Unknown.
|
||||
#define GPUREG_0286 0x0286 ///< Unknown.
|
||||
#define GPUREG_0287 0x0287 ///< Unknown.
|
||||
#define GPUREG_0288 0x0288 ///< Unknown.
|
||||
#define GPUREG_GSH_INPUTBUFFER_CONFIG 0x0289 ///< Geometry shader input buffer configuration.
|
||||
#define GPUREG_GSH_ENTRYPOINT 0x028A ///< Geometry shader entry point.
|
||||
#define GPUREG_GSH_ATTRIBUTES_PERMUTATION_LOW 0x028B ///< Geometry shader attribute permutations low.
|
||||
#define GPUREG_GSH_ATTRIBUTES_PERMUTATION_HIGH 0x028C ///< Geometry shader attribute permutations high.
|
||||
#define GPUREG_GSH_OUTMAP_MASK 0x028D ///< Geometry shader output map mask.
|
||||
#define GPUREG_028E 0x028E ///< Unknown.
|
||||
#define GPUREG_GSH_CODETRANSFER_END 0x028F ///< Geometry shader code transfer end trigger.
|
||||
#define GPUREG_GSH_FLOATUNIFORM_CONFIG 0x0290 ///< Geometry shader float uniform configuration.
|
||||
#define GPUREG_GSH_FLOATUNIFORM_DATA 0x0291 ///< Geometry shader float uniform data.
|
||||
#define GPUREG_0299 0x0299 ///< Unknown.
|
||||
#define GPUREG_029A 0x029A ///< Unknown.
|
||||
#define GPUREG_GSH_CODETRANSFER_CONFIG 0x029B ///< Geometry shader code transfer configuration.
|
||||
#define GPUREG_GSH_CODETRANSFER_DATA 0x029C ///< Geometry shader code transfer data.
|
||||
#define GPUREG_02A4 0x02A4 ///< Unknown.
|
||||
#define GPUREG_GSH_OPDESCS_CONFIG 0x02A5 ///< Geometry shader operand description configuration.
|
||||
#define GPUREG_GSH_OPDESCS_DATA 0x02A6 ///< Geometry shader operand description data.
|
||||
#define GPUREG_02AE 0x02AE ///< Unknown.
|
||||
#define GPUREG_02AF 0x02AF ///< Unknown.
|
||||
///@}
|
||||
|
||||
///@name Vertex shader registers (0x2B0-0x2DF)
|
||||
///@{
|
||||
#define GPUREG_VSH_BOOLUNIFORM 0x02B0 ///< Vertex shader bool uniforms.
|
||||
#define GPUREG_VSH_INTUNIFORM_I0 0x02B1 ///< Vertex shader integer uniform 0.
|
||||
#define GPUREG_VSH_INTUNIFORM_I1 0x02B2 ///< Vertex shader integer uniform 1.
|
||||
#define GPUREG_VSH_INTUNIFORM_I2 0x02B3 ///< Vertex shader integer uniform 2.
|
||||
#define GPUREG_VSH_INTUNIFORM_I3 0x02B4 ///< Vertex shader integer uniform 3.
|
||||
#define GPUREG_02B5 0x02B5 ///< Unknown.
|
||||
#define GPUREG_02B6 0x02B6 ///< Unknown.
|
||||
#define GPUREG_02B7 0x02B7 ///< Unknown.
|
||||
#define GPUREG_02B8 0x02B8 ///< Unknown.
|
||||
#define GPUREG_VSH_INPUTBUFFER_CONFIG 0x02B9 ///< Vertex shader input buffer configuration.
|
||||
#define GPUREG_VSH_ENTRYPOINT 0x02BA ///< Vertex shader entry point.
|
||||
#define GPUREG_VSH_ATTRIBUTES_PERMUTATION_LOW 0x02BB ///< Vertex shader attribute permutations low.
|
||||
#define GPUREG_VSH_ATTRIBUTES_PERMUTATION_HIGH 0x02BC ///< Vertex shader attribute permutations high.
|
||||
#define GPUREG_VSH_OUTMAP_MASK 0x02BD ///< Vertex shader output map mask.
|
||||
#define GPUREG_02BE 0x02BE ///< Unknown.
|
||||
#define GPUREG_VSH_CODETRANSFER_END 0x02BF ///< Vertex shader code transfer end trigger.
|
||||
#define GPUREG_VSH_FLOATUNIFORM_CONFIG 0x02C0 ///< Vertex shader float uniform configuration.
|
||||
#define GPUREG_VSH_FLOATUNIFORM_DATA 0x02C1 ///< Vertex shader float uniform data.
|
||||
#define GPUREG_02C9 0x02C9 ///< Unknown.
|
||||
#define GPUREG_02CA 0x02CA ///< Unknown.
|
||||
#define GPUREG_VSH_CODETRANSFER_CONFIG 0x02CB ///< Vertex shader code transfer configuration.
|
||||
#define GPUREG_VSH_CODETRANSFER_DATA 0x02CC ///< Vertex shader code transfer data.
|
||||
#define GPUREG_02D4 0x02D4 ///< Unknown.
|
||||
#define GPUREG_VSH_OPDESCS_CONFIG 0x02D5 ///< Vertex shader operand description configuration.
|
||||
#define GPUREG_VSH_OPDESCS_DATA 0x02D6 ///< Vertex shader operand description data.
|
||||
#define GPUREG_02DE 0x02DE ///< Unknown.
|
||||
#define GPUREG_02DF 0x02DF ///< Unknown.
|
||||
///@}
|
||||
|
||||
///@name Unknown registers (0x2E0-0x2FF)
|
||||
///@{
|
||||
#define GPUREG_02E0 0x02E0 ///< Unknown.
|
||||
#define GPUREG_02E1 0x02E1 ///< Unknown.
|
||||
#define GPUREG_02E2 0x02E2 ///< Unknown.
|
||||
#define GPUREG_02E3 0x02E3 ///< Unknown.
|
||||
#define GPUREG_02E4 0x02E4 ///< Unknown.
|
||||
#define GPUREG_02E5 0x02E5 ///< Unknown.
|
||||
#define GPUREG_02E6 0x02E6 ///< Unknown.
|
||||
#define GPUREG_02E7 0x02E7 ///< Unknown.
|
||||
#define GPUREG_02E8 0x02E8 ///< Unknown.
|
||||
#define GPUREG_02E9 0x02E9 ///< Unknown.
|
||||
#define GPUREG_02EA 0x02EA ///< Unknown.
|
||||
#define GPUREG_02EB 0x02EB ///< Unknown.
|
||||
#define GPUREG_02EC 0x02EC ///< Unknown.
|
||||
#define GPUREG_02ED 0x02ED ///< Unknown.
|
||||
#define GPUREG_02EE 0x02EE ///< Unknown.
|
||||
#define GPUREG_02EF 0x02EF ///< Unknown.
|
||||
#define GPUREG_02F0 0x02F0 ///< Unknown.
|
||||
#define GPUREG_02F1 0x02F1 ///< Unknown.
|
||||
#define GPUREG_02F2 0x02F2 ///< Unknown.
|
||||
#define GPUREG_02F3 0x02F3 ///< Unknown.
|
||||
#define GPUREG_02F4 0x02F4 ///< Unknown.
|
||||
#define GPUREG_02F5 0x02F5 ///< Unknown.
|
||||
#define GPUREG_02F6 0x02F6 ///< Unknown.
|
||||
#define GPUREG_02F7 0x02F7 ///< Unknown.
|
||||
#define GPUREG_02F8 0x02F8 ///< Unknown.
|
||||
#define GPUREG_02F9 0x02F9 ///< Unknown.
|
||||
#define GPUREG_02FA 0x02FA ///< Unknown.
|
||||
#define GPUREG_02FB 0x02FB ///< Unknown.
|
||||
#define GPUREG_02FC 0x02FC ///< Unknown.
|
||||
#define GPUREG_02FD 0x02FD ///< Unknown.
|
||||
#define GPUREG_02FE 0x02FE ///< Unknown.
|
||||
#define GPUREG_02FF 0x02FF ///< Unknown.
|
||||
///@}
|
120
libctru/include/3ds/gpu/shaderProgram.h
Normal file
120
libctru/include/3ds/gpu/shaderProgram.h
Normal file
@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @file shaderProgram.h
|
||||
* @brief Functions for working with shaders.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/gpu/shbin.h>
|
||||
|
||||
/// 24-bit float uniforms.
|
||||
typedef struct
|
||||
{
|
||||
u32 id; ///< Uniform ID.
|
||||
u32 data[3]; ///< Uniform data.
|
||||
}float24Uniform_s;
|
||||
|
||||
/// Describes an instance of either a vertex or geometry shader.
|
||||
typedef struct
|
||||
{
|
||||
DVLE_s* dvle; ///< Shader DVLE.
|
||||
u16 boolUniforms; ///< Boolean uniforms.
|
||||
u16 boolUniformMask; ///< Used boolean uniform mask.
|
||||
u32 intUniforms[4]; ///< Integer uniforms.
|
||||
float24Uniform_s* float24Uniforms; ///< 24-bit float uniforms.
|
||||
u8 intUniformMask; ///< Used integer uniform mask.
|
||||
u8 numFloat24Uniforms; ///< Float uniform count.
|
||||
}shaderInstance_s;
|
||||
|
||||
/// Describes an instance of a full shader program.
|
||||
typedef struct
|
||||
{
|
||||
shaderInstance_s* vertexShader; ///< Vertex shader.
|
||||
shaderInstance_s* geometryShader; ///< Geometry shader.
|
||||
u32 geoShaderInputPermutation[2]; ///< Geometry shader input permutation.
|
||||
u8 geoShaderInputStride; ///< Geometry shader input stride.
|
||||
}shaderProgram_s;
|
||||
|
||||
/**
|
||||
* @brief Initializes a shader instance.
|
||||
* @param si Shader instance to initialize.
|
||||
* @param dvle DVLE to initialize the shader instance with.
|
||||
*/
|
||||
Result shaderInstanceInit(shaderInstance_s* si, DVLE_s* dvle);
|
||||
|
||||
/**
|
||||
* @brief Frees a shader instance.
|
||||
* @param si Shader instance to free.
|
||||
*/
|
||||
Result shaderInstanceFree(shaderInstance_s* si);
|
||||
|
||||
/**
|
||||
* @brief Sets a bool uniform of a shader.
|
||||
* @param si Shader instance to use.
|
||||
* @param id ID of the bool uniform.
|
||||
* @param value Value to set.
|
||||
*/
|
||||
Result shaderInstanceSetBool(shaderInstance_s* si, int id, bool value);
|
||||
|
||||
/**
|
||||
* @brief Gets a bool uniform of a shader.
|
||||
* @param si Shader instance to use.
|
||||
* @param id ID of the bool uniform.
|
||||
* @param value Pointer to output the value to.
|
||||
*/
|
||||
Result shaderInstanceGetBool(shaderInstance_s* si, int id, bool* value);
|
||||
|
||||
/**
|
||||
* @brief Gets the location of a shader's uniform.
|
||||
* @param si Shader instance to use.
|
||||
* @param name Name of the uniform.
|
||||
*/
|
||||
s8 shaderInstanceGetUniformLocation(shaderInstance_s* si, const char* name);
|
||||
|
||||
/**
|
||||
* @brief Initializes a shader program.
|
||||
* @param sp Shader program to initialize.
|
||||
*/
|
||||
Result shaderProgramInit(shaderProgram_s* sp);
|
||||
|
||||
/**
|
||||
* @brief Frees a shader program.
|
||||
* @param sp Shader program to free.
|
||||
*/
|
||||
Result shaderProgramFree(shaderProgram_s* sp);
|
||||
|
||||
/**
|
||||
* @brief Sets the vertex shader of a shader program.
|
||||
* @param sp Shader program to use.
|
||||
* @param dvle Vertex shader to set.
|
||||
*/
|
||||
Result shaderProgramSetVsh(shaderProgram_s* sp, DVLE_s* dvle);
|
||||
|
||||
/**
|
||||
* @brief Sets the geometry shader of a shader program.
|
||||
* @param sp Shader program to use.
|
||||
* @param dvle Geometry shader to set.
|
||||
* @param stride Input stride of the shader (pass 0 to match the number of outputs of the vertex shader).
|
||||
*/
|
||||
Result shaderProgramSetGsh(shaderProgram_s* sp, DVLE_s* dvle, u8 stride);
|
||||
|
||||
/**
|
||||
* @brief Configures the permutation of the input attributes of the geometry shader of a shader program.
|
||||
* @param sp Shader program to use.
|
||||
* @param permutation Attribute permutation to use.
|
||||
*/
|
||||
Result shaderProgramSetGshInputPermutation(shaderProgram_s* sp, u64 permutation);
|
||||
|
||||
/**
|
||||
* @brief Configures the shader units to use the specified shader program.
|
||||
* @param sp Shader program to use.
|
||||
* @param sendVshCode When true, the vertex shader's code and operand descriptors are uploaded.
|
||||
* @param sendGshCode When true, the geometry shader's code and operand descriptors are uploaded.
|
||||
*/
|
||||
Result shaderProgramConfigure(shaderProgram_s* sp, bool sendVshCode, bool sendGshCode);
|
||||
|
||||
/**
|
||||
* @brief Same as shaderProgramConfigure, but always loading code/operand descriptors and uploading DVLE constants afterwards.
|
||||
* @param sp Shader program to use.
|
||||
*/
|
||||
Result shaderProgramUse(shaderProgram_s* sp);
|
130
libctru/include/3ds/gpu/shbin.h
Normal file
130
libctru/include/3ds/gpu/shbin.h
Normal file
@ -0,0 +1,130 @@
|
||||
/**
|
||||
* @file shbin.h
|
||||
* @brief Shader binary support.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/gpu/gpu.h>
|
||||
|
||||
/// DVLE type.
|
||||
typedef enum{
|
||||
VERTEX_SHDR=GPU_VERTEX_SHADER, ///< Vertex shader.
|
||||
GEOMETRY_SHDR=GPU_GEOMETRY_SHADER ///< Geometry shader.
|
||||
}DVLE_type;
|
||||
|
||||
/// Constant type.
|
||||
typedef enum{
|
||||
DVLE_CONST_BOOL=0x0, ///< Bool.
|
||||
DVLE_CONST_u8=0x1, ///< Unsigned 8-bit integer.
|
||||
DVLE_CONST_FLOAT24=0x2, ///< 24-bit float.
|
||||
}DVLE_constantType;
|
||||
|
||||
/// Output attribute.
|
||||
typedef enum{
|
||||
RESULT_POSITION = 0x0, ///< Position.
|
||||
RESULT_NORMALQUAT = 0x1, ///< Normal Quaternion.
|
||||
RESULT_COLOR = 0x2, ///< Color.
|
||||
RESULT_TEXCOORD0 = 0x3, ///< Texture coordinate 0.
|
||||
RESULT_TEXCOORD0W = 0x4, ///< Texture coordinate 0 W.
|
||||
RESULT_TEXCOORD1 = 0x5, ///< Texture coordinate 1.
|
||||
RESULT_TEXCOORD2 = 0x6, ///< Texture coordinate 2.
|
||||
RESULT_VIEW = 0x8, ///< View.
|
||||
RESULT_DUMMY = 0x9, ///< Dummy attribute (used as passthrough for geometry shader input).
|
||||
}DVLE_outputAttribute_t;
|
||||
|
||||
/// Geometry shader operation modes.
|
||||
typedef enum
|
||||
{
|
||||
GSH_POINT = 0, ///< Point processing mode.
|
||||
GSH_VARIABLE_PRIM = 1, ///< Variable-size primitive processing mode.
|
||||
GSH_FIXED_PRIM = 2, ///< Fixed-size primitive processing mode.
|
||||
} DVLE_geoShaderMode;
|
||||
|
||||
/// DVLP data.
|
||||
typedef struct{
|
||||
u32 codeSize; ///< Code size.
|
||||
u32* codeData; ///< Code data.
|
||||
u32 opdescSize; ///< Operand description size.
|
||||
u32* opcdescData; ///< Operand description data.
|
||||
}DVLP_s;
|
||||
|
||||
/// DVLE constant entry data.
|
||||
typedef struct{
|
||||
u16 type; ///< Constant type. See @ref DVLE_constantType
|
||||
u16 id; ///< Constant ID.
|
||||
u32 data[4]; ///< Constant data.
|
||||
}DVLE_constEntry_s;
|
||||
|
||||
/// DVLE output entry data.
|
||||
typedef struct{
|
||||
u16 type; ///< Output type. See @ref DVLE_outputAttribute_t
|
||||
u16 regID; ///< Output register ID.
|
||||
u8 mask; ///< Output mask.
|
||||
u8 unk[3]; ///< Unknown.
|
||||
}DVLE_outEntry_s;
|
||||
|
||||
/// DVLE uniform entry data.
|
||||
typedef struct{
|
||||
u32 symbolOffset; ///< Symbol offset.
|
||||
u16 startReg; ///< Start register.
|
||||
u16 endReg; ///< End register.
|
||||
}DVLE_uniformEntry_s;
|
||||
|
||||
/// DVLE data.
|
||||
typedef struct{
|
||||
DVLE_type type; ///< DVLE type.
|
||||
bool mergeOutmaps; ///< true = merge vertex/geometry shader outmaps ('dummy' output attribute is present).
|
||||
DVLE_geoShaderMode gshMode; ///< Geometry shader operation mode.
|
||||
u8 gshFixedVtxStart; ///< Starting float uniform register number for storing the fixed-size primitive vertex array.
|
||||
u8 gshVariableVtxNum; ///< Number of fully-defined vertices in the variable-size primitive vertex array.
|
||||
u8 gshFixedVtxNum; ///< Number of vertices in the fixed-size primitive vertex array.
|
||||
DVLP_s* dvlp; ///< Contained DVLPs.
|
||||
u32 mainOffset; ///< Offset of the start of the main function.
|
||||
u32 endmainOffset; ///< Offset of the end of the main function.
|
||||
u32 constTableSize; ///< Constant table size.
|
||||
DVLE_constEntry_s* constTableData; ///< Constant table data.
|
||||
u32 outTableSize; ///< Output table size.
|
||||
DVLE_outEntry_s* outTableData; ///< Output table data.
|
||||
u32 uniformTableSize; ///< Uniform table size.
|
||||
DVLE_uniformEntry_s* uniformTableData; ///< Uniform table data.
|
||||
char* symbolTableData; ///< Symbol table data.
|
||||
u8 outmapMask; ///< Output map mask.
|
||||
u32 outmapData[8]; ///< Output map data.
|
||||
u32 outmapMode; ///< Output map mode.
|
||||
u32 outmapClock; ///< Output map attribute clock.
|
||||
}DVLE_s;
|
||||
|
||||
/// DVLB data.
|
||||
typedef struct{
|
||||
u32 numDVLE; ///< DVLE count.
|
||||
DVLP_s DVLP; ///< Primary DVLP.
|
||||
DVLE_s* DVLE; ///< Contained DVLE.
|
||||
}DVLB_s;
|
||||
|
||||
/**
|
||||
* @brief Parses a shader binary.
|
||||
* @param shbinData Shader binary data.
|
||||
* @param shbinSize Shader binary size.
|
||||
* @return The parsed shader binary.
|
||||
*/
|
||||
DVLB_s* DVLB_ParseFile(u32* shbinData, u32 shbinSize);
|
||||
|
||||
/**
|
||||
* @brief Frees shader binary data.
|
||||
* @param dvlb DVLB to free.
|
||||
*/
|
||||
void DVLB_Free(DVLB_s* dvlb);
|
||||
|
||||
/**
|
||||
* @brief Gets a uniform register index from a shader.
|
||||
* @param dvle Shader to get the register from.
|
||||
* @param name Name of the register.
|
||||
* @return The uniform register index.
|
||||
*/
|
||||
s8 DVLE_GetUniformRegister(DVLE_s* dvle, const char* name);
|
||||
|
||||
/**
|
||||
* @brief Generates a shader output map.
|
||||
* @param dvle Shader to generate an output map for.
|
||||
*/
|
||||
void DVLE_GenerateOutmap(DVLE_s* dvle);
|
@ -1,68 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
typedef enum{
|
||||
VERTEX_SHDR=0x0,
|
||||
GEOMETRY_SHDR=0x1
|
||||
}SHDR_type;
|
||||
|
||||
typedef enum{
|
||||
RESULT_POSITION = 0x0,
|
||||
RESULT_COLOR = 0x2,
|
||||
RESULT_TEXCOORD0 = 0x3,
|
||||
RESULT_TEXCOORD1 = 0x5,
|
||||
RESULT_TEXCOORD2 = 0x6
|
||||
}SHDR_outType;
|
||||
|
||||
typedef struct{
|
||||
u32 codeSize;
|
||||
u32* codeData;
|
||||
u32 opdescSize;
|
||||
u32* opcdescData;
|
||||
}DVLP_s;
|
||||
|
||||
typedef struct{
|
||||
u32 header;
|
||||
u32 data[4];
|
||||
}DVLE_constEntry_s;
|
||||
|
||||
typedef struct{
|
||||
u16 type;
|
||||
u16 regID;
|
||||
u32 header;
|
||||
}DVLE_outEntry_s;
|
||||
|
||||
typedef struct{
|
||||
u32 symbolOffset;
|
||||
u16 startReg;
|
||||
u16 endReg;
|
||||
}DVLE_uniformEntry_s;
|
||||
|
||||
typedef struct{
|
||||
SHDR_type type;
|
||||
u32 mainOffset, endmainOffset;
|
||||
u32 constTableSize;
|
||||
DVLE_constEntry_s* constTableData;
|
||||
u32 outTableSize;
|
||||
DVLE_outEntry_s* outTableData;
|
||||
u32 uniformTableSize;
|
||||
DVLE_uniformEntry_s* uniformTableData;
|
||||
char* symbolTableData;
|
||||
}DVLE_s;
|
||||
|
||||
typedef struct{
|
||||
u32 numDVLE;
|
||||
DVLP_s DVLP;
|
||||
DVLE_s* DVLE;
|
||||
}DVLB_s;
|
||||
|
||||
|
||||
DVLB_s* SHDR_ParseSHBIN(u32* shbinData, u32 shbinSize);
|
||||
void SHDR_UseProgram(DVLB_s* dvlb, u8 id);
|
||||
void SHDR_FreeDVLB(DVLB_s* dvlb);
|
||||
s8 SHDR_GetUniformRegister(DVLB_s* dvlb, const char* name, u8 programID);
|
||||
|
||||
void DVLP_SendCode(DVLP_s* dvlp);
|
||||
void DVLP_SendOpDesc(DVLP_s* dvlp);
|
||||
|
||||
void DVLE_SendOutmap(DVLE_s* dvle);
|
||||
void DVLE_SendConstants(DVLE_s* dvle);
|
118
libctru/include/3ds/ipc.h
Normal file
118
libctru/include/3ds/ipc.h
Normal file
@ -0,0 +1,118 @@
|
||||
/**
|
||||
* @file ipc.h
|
||||
* @brief Inter Process Communication helpers
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
/// IPC buffer access rights.
|
||||
typedef enum
|
||||
{
|
||||
IPC_BUFFER_R = BIT(1), ///< Readable
|
||||
IPC_BUFFER_W = BIT(2), ///< Writable
|
||||
IPC_BUFFER_RW = IPC_BUFFER_R | IPC_BUFFER_W ///< Readable and Writable
|
||||
} IPC_BufferRights;
|
||||
|
||||
/**
|
||||
* @brief Creates a command header to be used for IPC
|
||||
* @param command_id ID of the command to create a header for.
|
||||
* @param normal_params Size of the normal parameters in words. Up to 63.
|
||||
* @param translate_params Size of the translate parameters in words. Up to 63.
|
||||
* @return The created IPC header.
|
||||
*
|
||||
* Normal parameters are sent directly to the process while the translate parameters might go through modifications and checks by the kernel.
|
||||
* The translate parameters are described by headers generated with the IPC_Desc_* functions.
|
||||
*
|
||||
* @note While #normal_params is equivalent to the number of normal parameters, #translate_params includes the size occupied by the translate parameters headers.
|
||||
*/
|
||||
static inline u32 IPC_MakeHeader(u16 command_id, unsigned normal_params, unsigned translate_params)
|
||||
{
|
||||
return ((u32) command_id << 16) | (((u32) normal_params & 0x3F) << 6) | (((u32) translate_params & 0x3F) << 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates a header to share handles
|
||||
* @param number The number of handles following this header. Max 64.
|
||||
* @return The created shared handles header.
|
||||
*
|
||||
* The #number next values are handles that will be shared between the two processes.
|
||||
*
|
||||
* @note Zero values will have no effect.
|
||||
*/
|
||||
static inline u32 IPC_Desc_SharedHandles(unsigned number)
|
||||
{
|
||||
return ((u32)(number - 1) << 26);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates the header to transfer handle ownership
|
||||
* @param number The number of handles following this header. Max 64.
|
||||
* @return The created handle transfer header.
|
||||
*
|
||||
* The #number next values are handles that will be duplicated and closed by the other process.
|
||||
*
|
||||
* @note Zero values will have no effect.
|
||||
*/
|
||||
static inline u32 IPC_Desc_MoveHandles(unsigned number)
|
||||
{
|
||||
return ((u32)(number - 1) << 26) | 0x10;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Returns the code to ask the kernel to fill the handle with the current process ID.
|
||||
* @return The code to request the current process ID.
|
||||
*
|
||||
* The next value is a placeholder that will be replaced by the current process ID by the kernel.
|
||||
*/
|
||||
static inline u32 IPC_Desc_CurProcessId(void)
|
||||
{
|
||||
return 0x20;
|
||||
}
|
||||
|
||||
static inline CTR_DEPRECATED u32 IPC_Desc_CurProcessHandle(void)
|
||||
{
|
||||
return IPC_Desc_CurProcessId();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates a header describing a static buffer.
|
||||
* @param size Size of the buffer. Max ?0x03FFFF?.
|
||||
* @param buffer_id The Id of the buffer. Max 0xF.
|
||||
* @return The created static buffer header.
|
||||
*
|
||||
* The next value is a pointer to the buffer. It will be copied to TLS offset 0x180 + static_buffer_id*8.
|
||||
*/
|
||||
static inline u32 IPC_Desc_StaticBuffer(size_t size, unsigned buffer_id)
|
||||
{
|
||||
return (size << 14) | ((buffer_id & 0xF) << 10) | 0x2;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates a header describing a buffer to be sent over PXI.
|
||||
* @param size Size of the buffer. Max 0x00FFFFFF.
|
||||
* @param buffer_id The Id of the buffer. Max 0xF.
|
||||
* @param is_read_only true if the buffer is read-only. If false, the buffer is considered to have read-write access.
|
||||
* @return The created PXI buffer header.
|
||||
*
|
||||
* The next value is a phys-address of a table located in the BASE memregion.
|
||||
*/
|
||||
static inline u32 IPC_Desc_PXIBuffer(size_t size, unsigned buffer_id, bool is_read_only)
|
||||
{
|
||||
u8 type = 0x4;
|
||||
if(is_read_only)type = 0x6;
|
||||
return (size << 8) | ((buffer_id & 0xF) << 4) | type;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Creates a header describing a buffer from the main memory.
|
||||
* @param size Size of the buffer. Max 0x0FFFFFFF.
|
||||
* @param rights The rights of the buffer for the destination process.
|
||||
* @return The created buffer header.
|
||||
*
|
||||
* The next value is a pointer to the buffer.
|
||||
*/
|
||||
static inline u32 IPC_Desc_Buffer(size_t size, IPC_BufferRights rights)
|
||||
{
|
||||
return (size << 4) | 0x8 | rights;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
// Functions for allocating/deallocating memory from linear heap
|
||||
void* linearAlloc(size_t size); // returns a 16-byte aligned address
|
||||
void* linearMemAlign(size_t size, size_t alignment);
|
||||
void* linearRealloc(void* mem, size_t size); // not implemented yet
|
||||
void linearFree(void* mem);
|
||||
u32 linearSpaceFree(); // get free linear space in bytes
|
159
libctru/include/3ds/mii.h
Normal file
159
libctru/include/3ds/mii.h
Normal file
@ -0,0 +1,159 @@
|
||||
/**
|
||||
* @file mii.h
|
||||
* @brief Shared Mii struct.
|
||||
*
|
||||
* @see https://www.3dbrew.org/wiki/Mii#Mii_format
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
/// Shared Mii struct
|
||||
typedef struct
|
||||
{
|
||||
u8 magic; ///< Always 3?
|
||||
|
||||
/// Mii options
|
||||
struct
|
||||
{
|
||||
bool allow_copying : 1; ///< True if copying is allowed
|
||||
bool is_private_name : 1; ///< Private name?
|
||||
u8 region_lock : 2; ///< Region lock (0=no lock, 1=JPN, 2=USA, 3=EUR)
|
||||
u8 char_set : 2; ///< Character set (0=JPN+USA+EUR, 1=CHN, 2=KOR, 3=TWN)
|
||||
} mii_options;
|
||||
|
||||
/// Mii position in Mii selector or Mii maker
|
||||
struct
|
||||
{
|
||||
u8 page_index : 4; ///< Page index of Mii
|
||||
u8 slot_index : 4; ///< Slot offset of Mii on its Page
|
||||
} mii_pos;
|
||||
|
||||
/// Console Identity
|
||||
struct
|
||||
{
|
||||
u8 unknown0 : 4; ///< Mabye padding (always seems to be 0)?
|
||||
u8 origin_console : 3; ///< Console that the Mii was created on (1=WII, 2=DSI, 3=3DS)
|
||||
} console_identity;
|
||||
|
||||
u64 system_id; ///< Identifies the system that the Mii was created on (Determines pants)
|
||||
u32 mii_id; ///< ID of Mii
|
||||
u8 mac[6]; ///< Creator's system's full MAC address
|
||||
u8 pad[2]; ///< Padding
|
||||
|
||||
/// Mii details
|
||||
struct {
|
||||
bool sex : 1; ///< Sex of Mii (False=Male, True=Female)
|
||||
u16 bday_month : 4; ///< Month of Mii's birthday
|
||||
u16 bday_day : 5; ///< Day of Mii's birthday
|
||||
u16 shirt_color : 4; ///< Color of Mii's shirt
|
||||
bool favorite : 1; ///< Whether the Mii is one of your 10 favorite Mii's
|
||||
} mii_details;
|
||||
|
||||
u16 mii_name[10]; ///< Name of Mii (Encoded using UTF16)
|
||||
u8 height; ///< How tall the Mii is
|
||||
u8 width; ///< How wide the Mii is
|
||||
|
||||
/// Face style
|
||||
struct
|
||||
{
|
||||
bool disable_sharing : 1; ///< Whether or not Sharing of the Mii is allowed
|
||||
u8 shape : 4; ///< Face shape
|
||||
u8 skinColor : 3; ///< Color of skin
|
||||
} face_style;
|
||||
|
||||
/// Face details
|
||||
struct
|
||||
{
|
||||
u8 wrinkles : 4;
|
||||
u8 makeup : 4;
|
||||
} face_details;
|
||||
|
||||
u8 hair_style;
|
||||
|
||||
/// Hair details
|
||||
struct
|
||||
{
|
||||
u8 color : 3;
|
||||
bool flip : 1;
|
||||
} hair_details;
|
||||
|
||||
/// Eye details
|
||||
struct
|
||||
{
|
||||
u32 style : 6;
|
||||
u32 color : 3;
|
||||
u32 scale : 4;
|
||||
u32 yscale : 3;
|
||||
u32 rotation : 5;
|
||||
u32 xspacing : 4;
|
||||
u32 yposition : 5;
|
||||
} eye_details;
|
||||
|
||||
/// Eyebrow details
|
||||
struct
|
||||
{
|
||||
u32 style : 5;
|
||||
u32 color : 3;
|
||||
u32 scale : 4;
|
||||
u32 yscale : 3;
|
||||
u32 pad : 1;
|
||||
u32 rotation : 5;
|
||||
u32 xspacing : 4;
|
||||
u32 yposition : 5;
|
||||
} eyebrow_details;
|
||||
|
||||
/// Nose details
|
||||
struct
|
||||
{
|
||||
u16 style : 5;
|
||||
u16 scale : 4;
|
||||
u16 yposition : 5;
|
||||
} nose_details;
|
||||
|
||||
/// Mouth details
|
||||
struct
|
||||
{
|
||||
u16 style : 6;
|
||||
u16 color : 3;
|
||||
u16 scale : 4;
|
||||
u16 yscale : 3;
|
||||
} mouth_details;
|
||||
|
||||
/// Mustache details
|
||||
struct
|
||||
{
|
||||
u16 mouth_yposition : 5;
|
||||
u16 mustach_style : 3;
|
||||
u16 pad : 2;
|
||||
} mustache_details;
|
||||
|
||||
/// Beard details
|
||||
struct
|
||||
{
|
||||
u16 style : 3;
|
||||
u16 color : 3;
|
||||
u16 scale : 4;
|
||||
u16 ypos : 5;
|
||||
} beard_details;
|
||||
|
||||
/// Glasses details
|
||||
struct
|
||||
{
|
||||
u16 style : 4;
|
||||
u16 color : 3;
|
||||
u16 scale : 4;
|
||||
u16 ypos : 5;
|
||||
} glasses_details;
|
||||
|
||||
/// Mole details
|
||||
struct
|
||||
{
|
||||
bool enable : 1;
|
||||
u16 scale : 5;
|
||||
u16 xpos : 5;
|
||||
u16 ypos : 5;
|
||||
} mole_details;
|
||||
|
||||
u16 author_name[10]; ///< Name of Mii's author (Encoded using UTF16)
|
||||
} CTR_PACKED MiiData;
|
264
libctru/include/3ds/ndsp/channel.h
Normal file
264
libctru/include/3ds/ndsp/channel.h
Normal file
@ -0,0 +1,264 @@
|
||||
/**
|
||||
* @file channel.h
|
||||
* @brief Functions for interacting with DSP audio channels.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
///@name Data types
|
||||
///@{
|
||||
/// Supported sample encodings.
|
||||
enum
|
||||
{
|
||||
NDSP_ENCODING_PCM8 = 0, ///< PCM8
|
||||
NDSP_ENCODING_PCM16, ///< PCM16
|
||||
NDSP_ENCODING_ADPCM, ///< DSPADPCM (GameCube format)
|
||||
};
|
||||
|
||||
/// Specifies the number of channels used in a sample.
|
||||
#define NDSP_CHANNELS(n) ((u32)(n) & 3)
|
||||
/// Specifies the encoding used in a sample.
|
||||
#define NDSP_ENCODING(n) (((u32)(n) & 3) << 2)
|
||||
|
||||
/// Channel format flags for use with ndspChnSetFormat.
|
||||
enum
|
||||
{
|
||||
NDSP_FORMAT_MONO_PCM8 = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_PCM8), ///< Buffer contains Mono PCM8.
|
||||
NDSP_FORMAT_MONO_PCM16 = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_PCM16), ///< Buffer contains Mono PCM16.
|
||||
NDSP_FORMAT_MONO_ADPCM = NDSP_CHANNELS(1) | NDSP_ENCODING(NDSP_ENCODING_ADPCM), ///< Buffer contains Mono ADPCM.
|
||||
NDSP_FORMAT_STEREO_PCM8 = NDSP_CHANNELS(2) | NDSP_ENCODING(NDSP_ENCODING_PCM8), ///< Buffer contains Stereo PCM8.
|
||||
NDSP_FORMAT_STEREO_PCM16 = NDSP_CHANNELS(2) | NDSP_ENCODING(NDSP_ENCODING_PCM16), ///< Buffer contains Stereo PCM16.
|
||||
|
||||
NDSP_FORMAT_PCM8 = NDSP_FORMAT_MONO_PCM8, ///< (Alias) Buffer contains Mono PCM8.
|
||||
NDSP_FORMAT_PCM16 = NDSP_FORMAT_MONO_PCM16, ///< (Alias) Buffer contains Mono PCM16.
|
||||
NDSP_FORMAT_ADPCM = NDSP_FORMAT_MONO_ADPCM, ///< (Alias) Buffer contains Mono ADPCM.
|
||||
|
||||
// Flags
|
||||
NDSP_FRONT_BYPASS = BIT(4), ///< Front bypass.
|
||||
NDSP_3D_SURROUND_PREPROCESSED = BIT(6), ///< (?) Unknown, under research
|
||||
};
|
||||
|
||||
/// Interpolation types.
|
||||
typedef enum
|
||||
{
|
||||
NDSP_INTERP_POLYPHASE = 0, ///< Polyphase interpolation
|
||||
NDSP_INTERP_LINEAR = 1, ///< Linear interpolation
|
||||
NDSP_INTERP_NONE = 2, ///< No interpolation
|
||||
} ndspInterpType;
|
||||
|
||||
///@}
|
||||
|
||||
///@name Basic channel operation
|
||||
///@{
|
||||
/**
|
||||
* @brief Resets a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
*/
|
||||
void ndspChnReset(int id);
|
||||
|
||||
/**
|
||||
* @brief Initializes the parameters of a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
*/
|
||||
void ndspChnInitParams(int id);
|
||||
|
||||
/**
|
||||
* @brief Checks whether a channel is currently playing.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @return Whether the channel is currently playing.
|
||||
*/
|
||||
bool ndspChnIsPlaying(int id);
|
||||
|
||||
/**
|
||||
* @brief Gets the current sample position of a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @return The channel's sample position.
|
||||
*/
|
||||
u32 ndspChnGetSamplePos(int id);
|
||||
|
||||
/**
|
||||
* @brief Gets the sequence ID of the wave buffer that is currently playing in a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @return The sequence ID of the wave buffer.
|
||||
*/
|
||||
u16 ndspChnGetWaveBufSeq(int id);
|
||||
|
||||
/**
|
||||
* @brief Checks whether a channel is currently paused.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @return Whether the channel is currently paused.
|
||||
*/
|
||||
bool ndspChnIsPaused(int id);
|
||||
|
||||
/**
|
||||
* @brief Sets the pause status of a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param paused Whether the channel is to be paused (true) or unpaused (false).
|
||||
*/
|
||||
void ndspChnSetPaused(int id, bool paused);
|
||||
|
||||
///@}
|
||||
|
||||
///@name Configuration
|
||||
///@{
|
||||
/**
|
||||
* @brief Sets the format of a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param format Format to use.
|
||||
*/
|
||||
void ndspChnSetFormat(int id, u16 format);
|
||||
|
||||
/**
|
||||
*
|
||||
* @brief Gets the format of a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @return The format of the channel.
|
||||
*/
|
||||
u16 ndspChnGetFormat(int id);
|
||||
|
||||
/**
|
||||
* @brief Sets the interpolation type of a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param type Interpolation type to use.
|
||||
*/
|
||||
void ndspChnSetInterp(int id, ndspInterpType type);
|
||||
|
||||
/**
|
||||
* @brief Gets the interpolation type of a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @return The interpolation type of the channel.
|
||||
*/
|
||||
ndspInterpType ndspChnGetInterp(int id);
|
||||
|
||||
/**
|
||||
* @brief Sets the sample rate of a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param rate Sample rate to use.
|
||||
*/
|
||||
void ndspChnSetRate(int id, float rate);
|
||||
|
||||
/**
|
||||
* @brief Gets the sample rate of a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @return The sample rate of the channel.
|
||||
*/
|
||||
float ndspChnGetRate(int id);
|
||||
|
||||
/**
|
||||
* @brief Sets the mix parameters (volumes) of a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param mix Mix parameters to use. Working hypothesis:
|
||||
* - 0: Front left volume.
|
||||
* - 1: Front right volume.
|
||||
* - 2: Back left volume:
|
||||
* - 3: Back right volume:
|
||||
* - 4..7: Same as 0..3, but for auxiliary output 0.
|
||||
* - 8..11: Same as 0..3, but for auxiliary output 1.
|
||||
*/
|
||||
void ndspChnSetMix(int id, float mix[12]);
|
||||
|
||||
/**
|
||||
* @brief Gets the mix parameters (volumes) of a channel.
|
||||
* @param id ID of the channel (0..23)
|
||||
* @param mix Mix parameters to write out to. See \ref ndspChnSetMix.
|
||||
*/
|
||||
void ndspChnGetMix(int id, float mix[12]);
|
||||
|
||||
/**
|
||||
* @brief Sets the DSPADPCM coefficients of a channel.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param coefs DSPADPCM coefficients to use.
|
||||
*/
|
||||
void ndspChnSetAdpcmCoefs(int id, u16 coefs[16]);
|
||||
///@}
|
||||
|
||||
///@name Wave buffers
|
||||
///@{
|
||||
/**
|
||||
* @brief Clears the wave buffer queue of a channel and stops playback.
|
||||
* @param id ID of the channel (0..23).
|
||||
*/
|
||||
void ndspChnWaveBufClear(int id);
|
||||
|
||||
/**
|
||||
* @brief Adds a wave buffer to the wave buffer queue of a channel.
|
||||
* @remark If the channel's wave buffer queue was empty before the use of this function, playback is started.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param buf Wave buffer to add.
|
||||
*/
|
||||
void ndspChnWaveBufAdd(int id, ndspWaveBuf* buf);
|
||||
///@}
|
||||
|
||||
///@name IIR filters
|
||||
///@{
|
||||
/**
|
||||
* @brief Configures whether the IIR monopole filter of a channel is enabled.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param enable Whether to enable the IIR monopole filter.
|
||||
*/
|
||||
void ndspChnIirMonoSetEnable(int id, bool enable);
|
||||
/**
|
||||
* @brief Manually sets up the parameters on monopole filter
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param enable Whether to enable the IIR monopole filter.
|
||||
*/
|
||||
bool ndspChnIirMonoSetParamsCustomFilter(int id, float a0, float a1, float b0);
|
||||
/**
|
||||
* @brief Sets the monopole to be a low pass filter. (Note: This is a lower-quality filter than the biquad one.)
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param f0 Low pass cut-off frequency.
|
||||
*/
|
||||
bool ndspChnIirMonoSetParamsLowPassFilter(int id, float f0);
|
||||
/**
|
||||
* @brief Sets the monopole to be a high pass filter. (Note: This is a lower-quality filter than the biquad one.)
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param f0 High pass cut-off frequency.
|
||||
*/
|
||||
bool ndspChnIirMonoSetParamsHighPassFilter(int id, float f0);
|
||||
/**
|
||||
* @brief Configures whether the IIR biquad filter of a channel is enabled.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param enable Whether to enable the IIR biquad filter.
|
||||
*/
|
||||
void ndspChnIirBiquadSetEnable(int id, bool enable);
|
||||
/**
|
||||
* @brief Manually sets up the parameters of the biquad filter
|
||||
* @param id ID of the channel (0..23).
|
||||
*/
|
||||
bool ndspChnIirBiquadSetParamsCustomFilter(int id, float a0, float a1, float a2, float b0, float b1, float b2);
|
||||
/**
|
||||
* @brief Sets the biquad to be a low pass filter.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param f0 Low pass cut-off frequency.
|
||||
* @param Q "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071).
|
||||
*/
|
||||
bool ndspChnIirBiquadSetParamsLowPassFilter(int id, float f0, float Q);
|
||||
/**
|
||||
* @brief Sets the biquad to be a high pass filter.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param f0 High pass cut-off frequency.
|
||||
* @param Q "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071).
|
||||
*/
|
||||
bool ndspChnIirBiquadSetParamsHighPassFilter(int id, float f0, float Q);
|
||||
/**
|
||||
* @brief Sets the biquad to be a band pass filter.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param f0 Mid-frequency.
|
||||
* @param Q "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071).
|
||||
*/
|
||||
bool ndspChnIirBiquadSetParamsBandPassFilter(int id, float f0, float Q);
|
||||
/**
|
||||
* @brief Sets the biquad to be a notch filter.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param f0 Notch frequency.
|
||||
* @param Q "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071).
|
||||
*/
|
||||
bool ndspChnIirBiquadSetParamsNotchFilter(int id, float f0, float Q);
|
||||
/**
|
||||
* @brief Sets the biquad to be a peaking equalizer.
|
||||
* @param id ID of the channel (0..23).
|
||||
* @param f0 Central frequency.
|
||||
* @param Q "Quality factor", typically should be sqrt(2)/2 (i.e. 0.7071).
|
||||
* @param gain Amount of gain (raw value = 10 ^ dB/40)
|
||||
*/
|
||||
bool ndspChnIirBiquadSetParamsPeakingEqualizer(int id, float f0, float Q, float gain);
|
||||
///@}
|
267
libctru/include/3ds/ndsp/ndsp.h
Normal file
267
libctru/include/3ds/ndsp/ndsp.h
Normal file
@ -0,0 +1,267 @@
|
||||
/**
|
||||
* @file ndsp.h
|
||||
* @brief Interface for Nintendo's default DSP component.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/os.h>
|
||||
|
||||
#define NDSP_SAMPLE_RATE (SYSCLOCK_SOC / 512.0)
|
||||
|
||||
///@name Data types
|
||||
///@{
|
||||
/// Sound output modes.
|
||||
typedef enum
|
||||
{
|
||||
NDSP_OUTPUT_MONO = 0, ///< Mono sound
|
||||
NDSP_OUTPUT_STEREO = 1, ///< Stereo sound
|
||||
NDSP_OUTPUT_SURROUND = 2, ///< 3D Surround sound
|
||||
} ndspOutputMode;
|
||||
|
||||
// Clipping modes.
|
||||
typedef enum
|
||||
{
|
||||
NDSP_CLIP_NORMAL = 0, ///< "Normal" clipping mode (?)
|
||||
NDSP_CLIP_SOFT = 1, ///< "Soft" clipping mode (?)
|
||||
} ndspClippingMode;
|
||||
|
||||
// Surround speaker positions.
|
||||
typedef enum
|
||||
{
|
||||
NDSP_SPKPOS_SQUARE = 0, ///<?
|
||||
NDSP_SPKPOS_WIDE = 1, ///<?
|
||||
NDSP_SPKPOS_NUM = 2, ///<?
|
||||
} ndspSpeakerPos;
|
||||
|
||||
/// ADPCM data.
|
||||
typedef struct
|
||||
{
|
||||
u16 index; ///< Current predictor index
|
||||
s16 history0; ///< Last outputted PCM16 sample.
|
||||
s16 history1; ///< Second to last outputted PCM16 sample.
|
||||
} ndspAdpcmData;
|
||||
|
||||
/// Wave buffer type.
|
||||
typedef struct tag_ndspWaveBuf ndspWaveBuf;
|
||||
|
||||
/// Wave buffer status.
|
||||
enum
|
||||
{
|
||||
NDSP_WBUF_FREE = 0, ///< The wave buffer is not queued.
|
||||
NDSP_WBUF_QUEUED = 1, ///< The wave buffer is queued and has not been played yet.
|
||||
NDSP_WBUF_PLAYING = 2, ///< The wave buffer is playing right now.
|
||||
NDSP_WBUF_DONE = 3, ///< The wave buffer has finished being played.
|
||||
};
|
||||
|
||||
/// Wave buffer struct.
|
||||
struct tag_ndspWaveBuf
|
||||
{
|
||||
union
|
||||
{
|
||||
s8* data_pcm8; ///< Pointer to PCM8 sample data.
|
||||
s16* data_pcm16; ///< Pointer to PCM16 sample data.
|
||||
u8* data_adpcm; ///< Pointer to DSPADPCM sample data.
|
||||
const void* data_vaddr; ///< Data virtual address.
|
||||
};
|
||||
u32 nsamples; ///< Total number of samples (PCM8=bytes, PCM16=halfwords, DSPADPCM=nibbles without frame headers)
|
||||
ndspAdpcmData* adpcm_data; ///< ADPCM data.
|
||||
|
||||
u32 offset; ///< Buffer offset. Only used for capture.
|
||||
bool looping; ///< Whether to loop the buffer.
|
||||
u8 status; ///< Queuing/playback status.
|
||||
|
||||
u16 sequence_id; ///< Sequence ID. Assigned automatically by ndspChnWaveBufAdd.
|
||||
ndspWaveBuf* next; ///< Next buffer to play. Used internally, do not modify.
|
||||
};
|
||||
|
||||
/// Sound frame callback function. (data = User provided data)
|
||||
typedef void (*ndspCallback)(void* data);
|
||||
/// Auxiliary output callback function. (data = User provided data, nsamples = Number of samples, samples = Sample data)
|
||||
typedef void (*ndspAuxCallback)(void* data, int nsamples, void* samples[4]);
|
||||
///@}
|
||||
|
||||
///@name Initialization and basic operations
|
||||
///@{
|
||||
/**
|
||||
* @brief Sets up the DSP component.
|
||||
* @param binary DSP binary to load.
|
||||
* @param size Size of the DSP binary.
|
||||
* @param progMask Program RAM block mask to load the binary to.
|
||||
* @param dataMask Data RAM block mask to load the binary to.
|
||||
*/
|
||||
void ndspUseComponent(const void* binary, u32 size, u16 progMask, u16 dataMask);
|
||||
|
||||
/// Initializes NDSP.
|
||||
Result ndspInit(void);
|
||||
|
||||
/// Exits NDSP.
|
||||
void ndspExit(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the number of dropped sound frames.
|
||||
* @return The number of dropped sound frames.
|
||||
*/
|
||||
u32 ndspGetDroppedFrames(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the total sound frame count.
|
||||
* @return The total sound frame count.
|
||||
*/
|
||||
u32 ndspGetFrameCount(void);
|
||||
///@}
|
||||
|
||||
///@name General parameters
|
||||
///@{
|
||||
/**
|
||||
* @brief Sets the master volume.
|
||||
* @param volume Volume to set. Defaults to 1.0f.
|
||||
*/
|
||||
void ndspSetMasterVol(float volume);
|
||||
|
||||
/**
|
||||
* @brief Gets the master volume.
|
||||
* @return The master volume.
|
||||
*/
|
||||
float ndspGetMasterVol(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the output mode.
|
||||
* @param mode Output mode to set. Defaults to NDSP_OUTPUT_STEREO.
|
||||
*/
|
||||
void ndspSetOutputMode(ndspOutputMode mode);
|
||||
|
||||
/**
|
||||
* @brief Gets the output mode.
|
||||
* @return The output mode.
|
||||
*/
|
||||
ndspOutputMode ndspGetOutputMode(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the clipping mode.
|
||||
* @param mode Clipping mode to set. Defaults to NDSP_CLIP_SOFT.
|
||||
*/
|
||||
void ndspSetClippingMode(ndspClippingMode mode);
|
||||
|
||||
/**
|
||||
* @brief Gets the clipping mode.
|
||||
* @return The clipping mode.
|
||||
*/
|
||||
ndspClippingMode ndspGetClippingMode(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the output count.
|
||||
* @param count Output count to set. Defaults to 2.
|
||||
*/
|
||||
void ndspSetOutputCount(int count);
|
||||
|
||||
/**
|
||||
* @brief Gets the output count.
|
||||
* @return The output count.
|
||||
*/
|
||||
int ndspGetOutputCount(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the wave buffer to capture audio to.
|
||||
* @param capture Wave buffer to capture to.
|
||||
*/
|
||||
void ndspSetCapture(ndspWaveBuf* capture);
|
||||
|
||||
/**
|
||||
* @brief Sets the sound frame callback.
|
||||
* @param callback Callback to set.
|
||||
* @param data User-defined data to pass to the callback.
|
||||
*/
|
||||
void ndspSetCallback(ndspCallback callback, void* data);
|
||||
///@}
|
||||
|
||||
///@name Surround
|
||||
///@{
|
||||
/**
|
||||
* @brief Sets the surround sound depth.
|
||||
* @param depth Depth to set. Defaults to 0x7FFF.
|
||||
*/
|
||||
void ndspSurroundSetDepth(u16 depth);
|
||||
|
||||
/**
|
||||
* @brief Gets the surround sound depth.
|
||||
* @return The surround sound depth.
|
||||
*/
|
||||
u16 ndspSurroundGetDepth(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the surround sound position.
|
||||
* @param pos Position to set. Defaults to NDSP_SPKPOS_SQUARE.
|
||||
*/
|
||||
void ndspSurroundSetPos(ndspSpeakerPos pos);
|
||||
|
||||
/**
|
||||
* @brief Gets the surround sound position.
|
||||
* @return The surround sound speaker position.
|
||||
*/
|
||||
ndspSpeakerPos ndspSurroundGetPos(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the surround sound rear ratio.
|
||||
* @param ratio Rear ratio to set. Defaults to 0x8000.
|
||||
*/
|
||||
void ndspSurroundSetRearRatio(u16 ratio);
|
||||
|
||||
/**
|
||||
* @brief Gets the surround sound rear ratio.
|
||||
* @return The rear ratio.
|
||||
*/
|
||||
u16 ndspSurroundGetRearRatio(void);
|
||||
///@}
|
||||
|
||||
///@name Auxiliary output
|
||||
///@{
|
||||
/**
|
||||
* @brief Configures whether an auxiliary output is enabled.
|
||||
* @param id ID of the auxiliary output.
|
||||
* @param enable Whether to enable the auxiliary output.
|
||||
*/
|
||||
void ndspAuxSetEnable(int id, bool enable);
|
||||
|
||||
/**
|
||||
* @brief Gets whether auxiliary output is enabled.
|
||||
* @param id ID of the auxiliary output.
|
||||
* @return Whether auxiliary output is enabled.
|
||||
*/
|
||||
bool ndspAuxIsEnabled(int id);
|
||||
|
||||
/**
|
||||
* @brief Configures whether an auxiliary output should use front bypass.
|
||||
* @param id ID of the auxiliary output.
|
||||
* @param bypass Whether to use front bypass.
|
||||
*/
|
||||
void ndspAuxSetFrontBypass(int id, bool bypass);
|
||||
|
||||
/**
|
||||
* @brief Gets whether auxiliary output front bypass is enabled.
|
||||
* @param id ID of the auxiliary output.
|
||||
* @return Whether auxiliary output front bypass is enabled.
|
||||
*/
|
||||
bool ndspAuxGetFrontBypass(int id);
|
||||
|
||||
/**
|
||||
* @brief Sets the volume of an auxiliary output.
|
||||
* @param id ID of the auxiliary output.
|
||||
* @param volume Volume to set.
|
||||
*/
|
||||
void ndspAuxSetVolume(int id, float volume);
|
||||
|
||||
/**
|
||||
* @brief Gets the volume of an auxiliary output.
|
||||
* @param id ID of the auxiliary output.
|
||||
* @return Volume of the auxiliary output.
|
||||
*/
|
||||
float ndspAuxGetVolume(int id);
|
||||
|
||||
/**
|
||||
* @brief Sets the callback of an auxiliary output.
|
||||
* @param id ID of the auxiliary output.
|
||||
* @param callback Callback to set.
|
||||
* @param data User-defined data to pass to the callback.
|
||||
*/
|
||||
void ndspAuxSetCallback(int id, ndspAuxCallback callback, void* data);
|
||||
///@}
|
@ -1,11 +1,349 @@
|
||||
/**
|
||||
* @file os.h
|
||||
* @brief OS related stuff.
|
||||
*/
|
||||
#pragma once
|
||||
#include "svc.h"
|
||||
|
||||
///< The external clock rate for the SoC.
|
||||
#define SYSCLOCK_SOC (16756991u)
|
||||
///< The base system clock rate (for I2C, NDMA, etc.).
|
||||
#define SYSCLOCK_SYS (SYSCLOCK_SOC * 2)
|
||||
///< The base clock rate for the SDMMC controller (and some other peripherals).
|
||||
#define SYSCLOCK_SDMMC (SYSCLOCK_SYS * 2)
|
||||
///< The clock rate for the Arm9.
|
||||
#define SYSCLOCK_ARM9 (SYSCLOCK_SYS * 4)
|
||||
///< The clock rate for the Arm11 in CTR mode and in \ref svcGetSystemTick.
|
||||
#define SYSCLOCK_ARM11 (SYSCLOCK_ARM9 * 2)
|
||||
///< The clock rate for the Arm11 in LGR1 mode.
|
||||
#define SYSCLOCK_ARM11_LGR1 (SYSCLOCK_ARM11 * 2)
|
||||
///< The clock rate for the Arm11 in LGR2 mode.
|
||||
#define SYSCLOCK_ARM11_LGR2 (SYSCLOCK_ARM11 * 3)
|
||||
///< The highest possible clock rate for the Arm11 on known New 3DS units.
|
||||
#define SYSCLOCK_ARM11_NEW SYSCLOCK_ARM11_LGR2
|
||||
|
||||
#define CPU_TICKS_PER_MSEC (SYSCLOCK_ARM11 / 1000.0)
|
||||
#define CPU_TICKS_PER_USEC (SYSCLOCK_ARM11 / 1000000.0)
|
||||
|
||||
/// Packs a system version from its components.
|
||||
#define SYSTEM_VERSION(major, minor, revision) \
|
||||
(((major)<<24)|((minor)<<16)|((revision)<<8))
|
||||
|
||||
u32 osConvertVirtToPhys(u32 vaddr);
|
||||
u32 osConvertOldLINEARMemToNew(u32 addr);//Converts 0x14* vmem to 0x30*. Returns the input addr when it's already within the new vmem. Returns 0 when outside of either LINEAR mem areas.
|
||||
const char* osStrError(u32 error);
|
||||
u32 osGetFirmVersion();
|
||||
u32 osGetKernelVersion();
|
||||
u64 osGetTime();
|
||||
/// Retrieves the major version from a packed system version.
|
||||
#define GET_VERSION_MAJOR(version) ((version) >>24)
|
||||
|
||||
/// Retrieves the minor version from a packed system version.
|
||||
#define GET_VERSION_MINOR(version) (((version)>>16)&0xFF)
|
||||
|
||||
/// Retrieves the revision version from a packed system version.
|
||||
#define GET_VERSION_REVISION(version) (((version)>> 8)&0xFF)
|
||||
|
||||
#define OS_HEAP_AREA_BEGIN 0x08000000 ///< Start of the heap area in the virtual address space
|
||||
#define OS_HEAP_AREA_END 0x0E000000 ///< End of the heap area in the virtual address space
|
||||
|
||||
#define OS_MAP_AREA_BEGIN 0x10000000 ///< Start of the mappable area in the virtual address space
|
||||
#define OS_MAP_AREA_END 0x14000000 ///< End of the mappable area in the virtual address space
|
||||
|
||||
#define OS_OLD_FCRAM_VADDR 0x14000000 ///< Old pre-8.x linear FCRAM mapping virtual address
|
||||
#define OS_OLD_FCRAM_PADDR 0x20000000 ///< Old pre-8.x linear FCRAM mapping physical address
|
||||
#define OS_OLD_FCRAM_SIZE 0x8000000 ///< Old pre-8.x linear FCRAM mapping size (128 MiB)
|
||||
|
||||
#define OS_QTMRAM_VADDR 0x1E800000 ///< New3DS QTM memory virtual address
|
||||
#define OS_QTMRAM_PADDR 0x1F000000 ///< New3DS QTM memory physical address
|
||||
#define OS_QTMRAM_SIZE 0x400000 ///< New3DS QTM memory size (4 MiB; last 128 KiB reserved by kernel)
|
||||
|
||||
#define OS_MMIO_VADDR 0x1EC00000 ///< Memory mapped IO range virtual address
|
||||
#define OS_MMIO_PADDR 0x10100000 ///< Memory mapped IO range physical address
|
||||
#define OS_MMIO_SIZE 0x400000 ///< Memory mapped IO range size (4 MiB)
|
||||
|
||||
#define OS_VRAM_VADDR 0x1F000000 ///< VRAM virtual address
|
||||
#define OS_VRAM_PADDR 0x18000000 ///< VRAM physical address
|
||||
#define OS_VRAM_SIZE 0x600000 ///< VRAM size (6 MiB)
|
||||
|
||||
#define OS_DSPRAM_VADDR 0x1FF00000 ///< DSP memory virtual address
|
||||
#define OS_DSPRAM_PADDR 0x1FF00000 ///< DSP memory physical address
|
||||
#define OS_DSPRAM_SIZE 0x80000 ///< DSP memory size (512 KiB)
|
||||
|
||||
#define OS_KERNELCFG_VADDR 0x1FF80000 ///< Kernel configuration page virtual address
|
||||
#define OS_SHAREDCFG_VADDR 0x1FF81000 ///< Shared system configuration page virtual address
|
||||
|
||||
#define OS_FCRAM_VADDR 0x30000000 ///< Linear FCRAM mapping virtual address
|
||||
#define OS_FCRAM_PADDR 0x20000000 ///< Linear FCRAM mapping physical address
|
||||
#define OS_FCRAM_SIZE 0x10000000 ///< Linear FCRAM mapping size (256 MiB)
|
||||
|
||||
#define OS_KernelConfig ((osKernelConfig_s const*)OS_KERNELCFG_VADDR) ///< Pointer to the kernel configuration page (see \ref osKernelConfig_s)
|
||||
#define OS_SharedConfig ((osSharedConfig_s*)OS_SHAREDCFG_VADDR) ///< Pointer to the shared system configuration page (see \ref osSharedConfig_s)
|
||||
|
||||
/// Kernel configuration page (read-only).
|
||||
typedef struct
|
||||
{
|
||||
u32 kernel_ver;
|
||||
u32 update_flag;
|
||||
u64 ns_tid;
|
||||
u32 kernel_syscore_ver;
|
||||
u8 env_info;
|
||||
u8 unit_info;
|
||||
u8 boot_env;
|
||||
u8 unk_0x17;
|
||||
u32 kernel_ctrsdk_ver;
|
||||
u32 unk_0x1c;
|
||||
u32 firmlaunch_flags;
|
||||
u8 unk_0x24[0xc];
|
||||
u32 app_memtype;
|
||||
u8 unk_0x34[0xc];
|
||||
u32 memregion_sz[3];
|
||||
u8 unk_0x4c[0x14];
|
||||
u32 firm_ver;
|
||||
u32 firm_syscore_ver;
|
||||
u32 firm_ctrsdk_ver;
|
||||
} osKernelConfig_s;
|
||||
|
||||
/// Time reference information struct (filled in by PTM).
|
||||
typedef struct
|
||||
{
|
||||
u64 value_ms; ///< Milliseconds elapsed since January 1900 when this structure was last updated
|
||||
u64 value_tick; ///< System ticks elapsed since boot when this structure was last updated
|
||||
s64 sysclock_hz;///< System clock frequency in Hz adjusted using RTC measurements (usually around \ref SYSCLOCK_ARM11)
|
||||
s64 drift_ms; ///< Measured time drift of the system clock (according to the RTC) in milliseconds since the last update
|
||||
} osTimeRef_s;
|
||||
|
||||
/// Shared system configuration page structure (read-only or read-write depending on exheader).
|
||||
typedef struct
|
||||
{
|
||||
vu32 timeref_cnt;
|
||||
u8 running_hw;
|
||||
u8 mcu_hwinfo;
|
||||
u8 unk_0x06[0x1A];
|
||||
volatile osTimeRef_s timeref[2];
|
||||
u8 wifi_macaddr[6];
|
||||
vu8 wifi_strength;
|
||||
vu8 network_state;
|
||||
u8 unk_0x68[0x18];
|
||||
volatile float slider_3d;
|
||||
vu8 led_3d;
|
||||
vu8 led_battery;
|
||||
vu8 unk_flag;
|
||||
u8 unk_0x87;
|
||||
u8 unk_0x88[0x18];
|
||||
vu64 menu_tid;
|
||||
vu64 cur_menu_tid;
|
||||
u8 unk_0xB0[0x10];
|
||||
vu8 headset_connected;
|
||||
} osSharedConfig_s;
|
||||
|
||||
/// Tick counter.
|
||||
typedef struct
|
||||
{
|
||||
u64 elapsed; ///< Elapsed CPU ticks between measurements.
|
||||
u64 reference; ///< Point in time used as reference.
|
||||
} TickCounter;
|
||||
|
||||
/// OS_VersionBin. Format of the system version: "<major>.<minor>.<build>-<nupver><region>"
|
||||
typedef struct
|
||||
{
|
||||
u8 build;
|
||||
u8 minor;
|
||||
u8 mainver;//"major" in CVER, NUP version in NVer.
|
||||
u8 reserved_x3;
|
||||
char region;//"ASCII character for the system version region"
|
||||
u8 reserved_x5[0x3];
|
||||
} OS_VersionBin;
|
||||
|
||||
/**
|
||||
* @brief Converts an address from virtual (process) memory to physical memory.
|
||||
* @param vaddr Input virtual address.
|
||||
* @return The corresponding physical address.
|
||||
* It is sometimes required by services or when using the GPU command buffer.
|
||||
*/
|
||||
u32 osConvertVirtToPhys(const void* vaddr);
|
||||
|
||||
/**
|
||||
* @brief Converts 0x14* vmem to 0x30*.
|
||||
* @param vaddr Input virtual address.
|
||||
* @return The corresponding address in the 0x30* range, the input address if it's already within the new vmem, or 0 if it's outside of both ranges.
|
||||
*/
|
||||
void* osConvertOldLINEARMemToNew(const void* vaddr);
|
||||
|
||||
/**
|
||||
* @brief Retrieves basic information about a service error.
|
||||
* @param error Error to retrieve information about.
|
||||
* @return A string containing a summary of an error.
|
||||
*
|
||||
* This can be used to get some details about an error returned by a service call.
|
||||
*/
|
||||
const char* osStrError(Result error);
|
||||
|
||||
/**
|
||||
* @brief Gets the system's FIRM version.
|
||||
* @return The system's FIRM version.
|
||||
*
|
||||
* This can be used to compare system versions easily with @ref SYSTEM_VERSION.
|
||||
*/
|
||||
static inline u32 osGetFirmVersion(void)
|
||||
{
|
||||
return OS_KernelConfig->firm_ver &~ 0xFF;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the system's kernel version.
|
||||
* @return The system's kernel version.
|
||||
*
|
||||
* This can be used to compare system versions easily with @ref SYSTEM_VERSION.
|
||||
*
|
||||
* @code
|
||||
* if(osGetKernelVersion() > SYSTEM_VERSION(2,46,0)) printf("You are running 9.0 or higher\n");
|
||||
* @endcode
|
||||
*/
|
||||
static inline u32 osGetKernelVersion(void)
|
||||
{
|
||||
return OS_KernelConfig->kernel_ver &~ 0xFF;
|
||||
}
|
||||
|
||||
/// Gets the system's "core version" (2 on NATIVE_FIRM, 3 on SAFE_FIRM, etc.)
|
||||
static inline u32 osGetSystemCoreVersion(void)
|
||||
{
|
||||
return OS_KernelConfig->kernel_syscore_ver;
|
||||
}
|
||||
|
||||
/// Gets the system's memory layout ID (0-5 on Old 3DS, 6-8 on New 3DS)
|
||||
static inline u32 osGetApplicationMemType(void)
|
||||
{
|
||||
return OS_KernelConfig->app_memtype;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the size of the specified memory region.
|
||||
* @param region Memory region to check.
|
||||
* @return The size of the memory region, in bytes.
|
||||
*/
|
||||
static inline u32 osGetMemRegionSize(MemRegion region)
|
||||
{
|
||||
if(region == MEMREGION_ALL) {
|
||||
return osGetMemRegionSize(MEMREGION_APPLICATION) + osGetMemRegionSize(MEMREGION_SYSTEM) + osGetMemRegionSize(MEMREGION_BASE);
|
||||
} else {
|
||||
return OS_KernelConfig->memregion_sz[region-1];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the number of used bytes within the specified memory region.
|
||||
* @param region Memory region to check.
|
||||
* @return The number of used bytes of memory.
|
||||
*/
|
||||
static inline u32 osGetMemRegionUsed(MemRegion region)
|
||||
{
|
||||
s64 mem_used;
|
||||
svcGetSystemInfo(&mem_used, 0, region);
|
||||
return mem_used;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the number of free bytes within the specified memory region.
|
||||
* @param region Memory region to check.
|
||||
* @return The number of free bytes of memory.
|
||||
*/
|
||||
static inline u32 osGetMemRegionFree(MemRegion region)
|
||||
{
|
||||
return osGetMemRegionSize(region) - osGetMemRegionUsed(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads the latest reference timepoint published by PTM.
|
||||
* @return Structure (see \ref osTimeRef_s).
|
||||
*/
|
||||
osTimeRef_s osGetTimeRef(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the current time.
|
||||
* @return The number of milliseconds since 1st Jan 1900 00:00.
|
||||
*/
|
||||
u64 osGetTime(void);
|
||||
|
||||
/**
|
||||
* @brief Starts a tick counter.
|
||||
* @param cnt The tick counter.
|
||||
*/
|
||||
static inline void osTickCounterStart(TickCounter* cnt)
|
||||
{
|
||||
cnt->reference = svcGetSystemTick();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Updates the elapsed time in a tick counter.
|
||||
* @param cnt The tick counter.
|
||||
*/
|
||||
static inline void osTickCounterUpdate(TickCounter* cnt)
|
||||
{
|
||||
u64 now = svcGetSystemTick();
|
||||
cnt->elapsed = now - cnt->reference;
|
||||
cnt->reference = now;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Reads the elapsed time in a tick counter.
|
||||
* @param cnt The tick counter.
|
||||
* @return The number of milliseconds elapsed.
|
||||
*/
|
||||
double osTickCounterRead(const TickCounter* cnt);
|
||||
|
||||
/**
|
||||
* @brief Gets the current Wifi signal strength.
|
||||
* @return The current Wifi signal strength.
|
||||
*
|
||||
* Valid values are 0-3:
|
||||
* - 0 means the signal strength is terrible or the 3DS is disconnected from
|
||||
* all networks.
|
||||
* - 1 means the signal strength is bad.
|
||||
* - 2 means the signal strength is decent.
|
||||
* - 3 means the signal strength is good.
|
||||
*
|
||||
* Values outside the range of 0-3 should never be returned.
|
||||
*
|
||||
* These values correspond with the number of wifi bars displayed by Home Menu.
|
||||
*/
|
||||
static inline u8 osGetWifiStrength(void)
|
||||
{
|
||||
return OS_SharedConfig->wifi_strength;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets the state of the 3D slider.
|
||||
* @return The state of the 3D slider (0.0~1.0)
|
||||
*/
|
||||
static inline float osGet3DSliderState(void)
|
||||
{
|
||||
return OS_SharedConfig->slider_3d;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Checks whether a headset is connected.
|
||||
* @return true or false.
|
||||
*/
|
||||
static inline bool osIsHeadsetConnected(void)
|
||||
{
|
||||
return OS_SharedConfig->headset_connected != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Configures the New 3DS speedup.
|
||||
* @param enable Specifies whether to enable or disable the speedup.
|
||||
*/
|
||||
void osSetSpeedupEnable(bool enable);
|
||||
|
||||
/**
|
||||
* @brief Gets the NAND system-version stored in NVer/CVer.
|
||||
* @param nver_versionbin Output OS_VersionBin structure for the data read from NVer.
|
||||
* @param cver_versionbin Output OS_VersionBin structure for the data read from CVer.
|
||||
* @return The result-code. This value can be positive if opening "romfs:/version.bin" fails with stdio, since errno would be returned in that case. In some cases the error can be special negative values as well.
|
||||
*/
|
||||
Result osGetSystemVersionData(OS_VersionBin *nver_versionbin, OS_VersionBin *cver_versionbin);
|
||||
|
||||
/**
|
||||
* @brief This is a wrapper for osGetSystemVersionData.
|
||||
* @param nver_versionbin Optional output OS_VersionBin structure for the data read from NVer, can be NULL.
|
||||
* @param cver_versionbin Optional output OS_VersionBin structure for the data read from CVer, can be NULL.
|
||||
* @param sysverstr Output string where the printed system-version will be written, in the same format displayed by the System Settings title.
|
||||
* @param sysverstr_maxsize Max size of the above string buffer, *including* NULL-terminator.
|
||||
* @return See osGetSystemVersionData.
|
||||
*/
|
||||
Result osGetSystemVersionDataString(OS_VersionBin *nver_versionbin, OS_VersionBin *cver_versionbin, char *sysverstr, u32 sysverstr_maxsize);
|
||||
|
191
libctru/include/3ds/result.h
Normal file
191
libctru/include/3ds/result.h
Normal file
@ -0,0 +1,191 @@
|
||||
/**
|
||||
* @file result.h
|
||||
* @brief 3DS result code tools
|
||||
*/
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
|
||||
/// Checks whether a result code indicates success.
|
||||
#define R_SUCCEEDED(res) ((res)>=0)
|
||||
/// Checks whether a result code indicates failure.
|
||||
#define R_FAILED(res) ((res)<0)
|
||||
/// Returns the level of a result code.
|
||||
#define R_LEVEL(res) (((res)>>27)&0x1F)
|
||||
/// Returns the summary of a result code.
|
||||
#define R_SUMMARY(res) (((res)>>21)&0x3F)
|
||||
/// Returns the module ID of a result code.
|
||||
#define R_MODULE(res) (((res)>>10)&0xFF)
|
||||
/// Returns the description of a result code.
|
||||
#define R_DESCRIPTION(res) ((res)&0x3FF)
|
||||
|
||||
/// Builds a result code from its constituent components.
|
||||
#define MAKERESULT(level,summary,module,description) \
|
||||
((((level)&0x1F)<<27) | (((summary)&0x3F)<<21) | (((module)&0xFF)<<10) | ((description)&0x3FF))
|
||||
|
||||
/// Result code level values.
|
||||
enum
|
||||
{
|
||||
// >= 0
|
||||
RL_SUCCESS = 0,
|
||||
RL_INFO = 1,
|
||||
|
||||
// < 0
|
||||
RL_FATAL = 0x1F,
|
||||
RL_RESET = RL_FATAL - 1,
|
||||
RL_REINITIALIZE = RL_FATAL - 2,
|
||||
RL_USAGE = RL_FATAL - 3,
|
||||
RL_PERMANENT = RL_FATAL - 4,
|
||||
RL_TEMPORARY = RL_FATAL - 5,
|
||||
RL_STATUS = RL_FATAL - 6,
|
||||
};
|
||||
|
||||
/// Result code summary values.
|
||||
enum
|
||||
{
|
||||
RS_SUCCESS = 0,
|
||||
RS_NOP = 1,
|
||||
RS_WOULDBLOCK = 2,
|
||||
RS_OUTOFRESOURCE = 3,
|
||||
RS_NOTFOUND = 4,
|
||||
RS_INVALIDSTATE = 5,
|
||||
RS_NOTSUPPORTED = 6,
|
||||
RS_INVALIDARG = 7,
|
||||
RS_WRONGARG = 8,
|
||||
RS_CANCELED = 9,
|
||||
RS_STATUSCHANGED = 10,
|
||||
RS_INTERNAL = 11,
|
||||
RS_INVALIDRESVAL = 63,
|
||||
};
|
||||
|
||||
/// Result code module values.
|
||||
enum
|
||||
{
|
||||
RM_COMMON = 0,
|
||||
RM_KERNEL = 1,
|
||||
RM_UTIL = 2,
|
||||
RM_FILE_SERVER = 3,
|
||||
RM_LOADER_SERVER = 4,
|
||||
RM_TCB = 5,
|
||||
RM_OS = 6,
|
||||
RM_DBG = 7,
|
||||
RM_DMNT = 8,
|
||||
RM_PDN = 9,
|
||||
RM_GSP = 10,
|
||||
RM_I2C = 11,
|
||||
RM_GPIO = 12,
|
||||
RM_DD = 13,
|
||||
RM_CODEC = 14,
|
||||
RM_SPI = 15,
|
||||
RM_PXI = 16,
|
||||
RM_FS = 17,
|
||||
RM_DI = 18,
|
||||
RM_HID = 19,
|
||||
RM_CAM = 20,
|
||||
RM_PI = 21,
|
||||
RM_PM = 22,
|
||||
RM_PM_LOW = 23,
|
||||
RM_FSI = 24,
|
||||
RM_SRV = 25,
|
||||
RM_NDM = 26,
|
||||
RM_NWM = 27,
|
||||
RM_SOC = 28,
|
||||
RM_LDR = 29,
|
||||
RM_ACC = 30,
|
||||
RM_ROMFS = 31,
|
||||
RM_AM = 32,
|
||||
RM_HIO = 33,
|
||||
RM_UPDATER = 34,
|
||||
RM_MIC = 35,
|
||||
RM_FND = 36,
|
||||
RM_MP = 37,
|
||||
RM_MPWL = 38,
|
||||
RM_AC = 39,
|
||||
RM_HTTP = 40,
|
||||
RM_DSP = 41,
|
||||
RM_SND = 42,
|
||||
RM_DLP = 43,
|
||||
RM_HIO_LOW = 44,
|
||||
RM_CSND = 45,
|
||||
RM_SSL = 46,
|
||||
RM_AM_LOW = 47,
|
||||
RM_NEX = 48,
|
||||
RM_FRIENDS = 49,
|
||||
RM_RDT = 50,
|
||||
RM_APPLET = 51,
|
||||
RM_NIM = 52,
|
||||
RM_PTM = 53,
|
||||
RM_MIDI = 54,
|
||||
RM_MC = 55,
|
||||
RM_SWC = 56,
|
||||
RM_FATFS = 57,
|
||||
RM_NGC = 58,
|
||||
RM_CARD = 59,
|
||||
RM_CARDNOR = 60,
|
||||
RM_SDMC = 61,
|
||||
RM_BOSS = 62,
|
||||
RM_DBM = 63,
|
||||
RM_CONFIG = 64,
|
||||
RM_PS = 65,
|
||||
RM_CEC = 66,
|
||||
RM_IR = 67,
|
||||
RM_UDS = 68,
|
||||
RM_PL = 69,
|
||||
RM_CUP = 70,
|
||||
RM_GYROSCOPE = 71,
|
||||
RM_MCU = 72,
|
||||
RM_NS = 73,
|
||||
RM_NEWS = 74,
|
||||
RM_RO = 75,
|
||||
RM_GD = 76,
|
||||
RM_CARD_SPI = 77,
|
||||
RM_EC = 78,
|
||||
RM_WEB_BROWSER = 79,
|
||||
RM_TEST = 80,
|
||||
RM_ENC = 81,
|
||||
RM_PIA = 82,
|
||||
RM_ACT = 83,
|
||||
RM_VCTL = 84,
|
||||
RM_OLV = 85,
|
||||
RM_NEIA = 86,
|
||||
RM_NPNS = 87,
|
||||
RM_AVD = 90,
|
||||
RM_L2B = 91,
|
||||
RM_MVD = 92,
|
||||
RM_NFC = 93,
|
||||
RM_UART = 94,
|
||||
RM_SPM = 95,
|
||||
RM_QTM = 96,
|
||||
RM_NFP = 97,
|
||||
RM_APPLICATION = 254,
|
||||
RM_INVALIDRESVAL = 255,
|
||||
};
|
||||
|
||||
/// Result code generic description values.
|
||||
enum
|
||||
{
|
||||
RD_SUCCESS = 0,
|
||||
RD_INVALID_RESULT_VALUE = 0x3FF,
|
||||
RD_TIMEOUT = RD_INVALID_RESULT_VALUE - 1,
|
||||
RD_OUT_OF_RANGE = RD_INVALID_RESULT_VALUE - 2,
|
||||
RD_ALREADY_EXISTS = RD_INVALID_RESULT_VALUE - 3,
|
||||
RD_CANCEL_REQUESTED = RD_INVALID_RESULT_VALUE - 4,
|
||||
RD_NOT_FOUND = RD_INVALID_RESULT_VALUE - 5,
|
||||
RD_ALREADY_INITIALIZED = RD_INVALID_RESULT_VALUE - 6,
|
||||
RD_NOT_INITIALIZED = RD_INVALID_RESULT_VALUE - 7,
|
||||
RD_INVALID_HANDLE = RD_INVALID_RESULT_VALUE - 8,
|
||||
RD_INVALID_POINTER = RD_INVALID_RESULT_VALUE - 9,
|
||||
RD_INVALID_ADDRESS = RD_INVALID_RESULT_VALUE - 10,
|
||||
RD_NOT_IMPLEMENTED = RD_INVALID_RESULT_VALUE - 11,
|
||||
RD_OUT_OF_MEMORY = RD_INVALID_RESULT_VALUE - 12,
|
||||
RD_MISALIGNED_SIZE = RD_INVALID_RESULT_VALUE - 13,
|
||||
RD_MISALIGNED_ADDRESS = RD_INVALID_RESULT_VALUE - 14,
|
||||
RD_BUSY = RD_INVALID_RESULT_VALUE - 15,
|
||||
RD_NO_DATA = RD_INVALID_RESULT_VALUE - 16,
|
||||
RD_INVALID_COMBINATION = RD_INVALID_RESULT_VALUE - 17,
|
||||
RD_INVALID_ENUM_VALUE = RD_INVALID_RESULT_VALUE - 18,
|
||||
RD_INVALID_SIZE = RD_INVALID_RESULT_VALUE - 19,
|
||||
RD_ALREADY_DONE = RD_INVALID_RESULT_VALUE - 20,
|
||||
RD_NOT_AUTHORIZED = RD_INVALID_RESULT_VALUE - 21,
|
||||
RD_TOO_LARGE = RD_INVALID_RESULT_VALUE - 22,
|
||||
RD_INVALID_SELECTION = RD_INVALID_RESULT_VALUE - 23,
|
||||
};
|
93
libctru/include/3ds/romfs.h
Normal file
93
libctru/include/3ds/romfs.h
Normal file
@ -0,0 +1,93 @@
|
||||
/**
|
||||
* @file romfs.h
|
||||
* @brief RomFS driver.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
#include <3ds/services/fs.h>
|
||||
|
||||
/// RomFS header.
|
||||
typedef struct
|
||||
{
|
||||
u32 headerSize; ///< Size of the header.
|
||||
u32 dirHashTableOff; ///< Offset of the directory hash table.
|
||||
u32 dirHashTableSize; ///< Size of the directory hash table.
|
||||
u32 dirTableOff; ///< Offset of the directory table.
|
||||
u32 dirTableSize; ///< Size of the directory table.
|
||||
u32 fileHashTableOff; ///< Offset of the file hash table.
|
||||
u32 fileHashTableSize; ///< Size of the file hash table.
|
||||
u32 fileTableOff; ///< Offset of the file table.
|
||||
u32 fileTableSize; ///< Size of the file table.
|
||||
u32 fileDataOff; ///< Offset of the file data.
|
||||
} romfs_header;
|
||||
|
||||
/// RomFS directory.
|
||||
typedef struct
|
||||
{
|
||||
u32 parent; ///< Offset of the parent directory.
|
||||
u32 sibling; ///< Offset of the next sibling directory.
|
||||
u32 childDir; ///< Offset of the first child directory.
|
||||
u32 childFile; ///< Offset of the first file.
|
||||
u32 nextHash; ///< Directory hash table pointer.
|
||||
u32 nameLen; ///< Name length.
|
||||
u16 name[]; ///< Name. (UTF-16)
|
||||
} romfs_dir;
|
||||
|
||||
/// RomFS file.
|
||||
typedef struct
|
||||
{
|
||||
u32 parent; ///< Offset of the parent directory.
|
||||
u32 sibling; ///< Offset of the next sibling file.
|
||||
u64 dataOff; ///< Offset of the file's data.
|
||||
u64 dataSize; ///< Length of the file's data.
|
||||
u32 nextHash; ///< File hash table pointer.
|
||||
u32 nameLen; ///< Name length.
|
||||
u16 name[]; ///< Name. (UTF-16)
|
||||
} romfs_file;
|
||||
|
||||
/**
|
||||
* @brief Mounts the Application's RomFS.
|
||||
* @param name Device mount name.
|
||||
* @remark This function is intended to be used to access one's own RomFS.
|
||||
* If the application is running as 3DSX, it mounts the embedded RomFS section inside the 3DSX.
|
||||
* If on the other hand it's an NCCH, it behaves identically to \ref romfsMountFromCurrentProcess.
|
||||
*/
|
||||
Result romfsMountSelf(const char *name);
|
||||
|
||||
/**
|
||||
* @brief Mounts RomFS from an open file.
|
||||
* @param fd FSFILE handle of the RomFS image.
|
||||
* @param offset Offset of the RomFS within the file.
|
||||
* @param name Device mount name.
|
||||
*/
|
||||
Result romfsMountFromFile(Handle fd, u32 offset, const char *name);
|
||||
|
||||
/**
|
||||
* @brief Mounts RomFS using the current process host program RomFS.
|
||||
* @param name Device mount name.
|
||||
*/
|
||||
Result romfsMountFromCurrentProcess(const char *name);
|
||||
|
||||
/**
|
||||
* @brief Mounts RomFS from the specified title.
|
||||
* @param tid Title ID
|
||||
* @param mediatype Mediatype
|
||||
* @param name Device mount name.
|
||||
*/
|
||||
Result romfsMountFromTitle(u64 tid, FS_MediaType mediatype, const char* name);
|
||||
|
||||
/// Unmounts the RomFS device.
|
||||
Result romfsUnmount(const char *name);
|
||||
|
||||
/// Wrapper for \ref romfsMountSelf with the default "romfs" device name.
|
||||
static inline Result romfsInit(void)
|
||||
{
|
||||
return romfsMountSelf("romfs");
|
||||
}
|
||||
|
||||
/// Wrapper for \ref romfsUnmount with the default "romfs" device name.
|
||||
static inline Result romfsExit(void)
|
||||
{
|
||||
return romfsUnmount("romfs");
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <3ds/types.h>
|
||||
|
||||
Result sdmcInit(void);
|
||||
Result sdmcExit(void);
|
@ -1,7 +1,157 @@
|
||||
/**
|
||||
* @file ac.h
|
||||
* @brief AC service.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
Result acInit();
|
||||
Result acExit();
|
||||
#include <3ds/types.h>
|
||||
|
||||
Result ACU_GetWifiStatus(Handle* servhandle, u32 *out);
|
||||
Result ACU_WaitInternetConnection();
|
||||
/// Wifi security modes.
|
||||
typedef enum {
|
||||
AC_OPEN = 0, ///< Open authentication.
|
||||
AC_WEP_40BIT = 1, ///< WEP 40-bit authentication.
|
||||
AC_WEP_104BIT = 2, ///< WEP 104-bit authentication.
|
||||
AC_WEP_128BIT = 3, ///< WEP 128-bit authentication.
|
||||
AC_WPA_TKIP = 4, ///< WPA TKIP authentication.
|
||||
AC_WPA2_TKIP = 5, ///< WPA2 TKIP authentication.
|
||||
AC_WPA_AES = 6, ///< WPA AES authentication.
|
||||
AC_WPA2_AES = 7, ///< WPA2 AES authentication.
|
||||
} acSecurityMode;
|
||||
|
||||
/// Wifi access point types (bitfield).
|
||||
enum {
|
||||
AC_AP_TYPE_NONE = 0, ///< No access point/none allowed.
|
||||
AC_AP_TYPE_SLOT1 = BIT(1), ///< Slot 1 in System Settings.
|
||||
AC_AP_TYPE_SLOT2 = BIT(2), ///< Slot 2 in System Settings.
|
||||
AC_AP_TYPE_SLOT3 = BIT(3), ///< Slot 3 in System Settings.
|
||||
|
||||
AC_AP_TYPE_ALL = 0x7FFFFFFF, ///< All access point types allowed.
|
||||
};
|
||||
|
||||
/// Struct to contain the data for connecting to a Wifi network from a stored slot.
|
||||
typedef struct {
|
||||
u8 reserved[0x200];
|
||||
} acuConfig;
|
||||
|
||||
/// Initializes AC.
|
||||
Result acInit(void);
|
||||
|
||||
/// Exits AC.
|
||||
void acExit(void);
|
||||
|
||||
/// Gets the current AC session handle.
|
||||
Handle *acGetSessionHandle(void);
|
||||
|
||||
/// Waits for the system to connect to the internet.
|
||||
Result acWaitInternetConnection(void);
|
||||
|
||||
/**
|
||||
* @brief Describes the access point the console is currently connected to with AC_AP_TYPE_* flags.
|
||||
* @param out Pointer to output the combination of AC_AP_TYPE_* flags describing the AP to.
|
||||
*/
|
||||
Result ACU_GetWifiStatus(u32 *out);
|
||||
|
||||
/**
|
||||
* @brief Gets the connected Wifi status.
|
||||
* @param out Pointer to output the connected Wifi status to. (1 = not connected, 3 = connected)
|
||||
*/
|
||||
Result ACU_GetStatus(u32 *out);
|
||||
|
||||
/**
|
||||
* @brief Gets the connected Wifi security mode.
|
||||
* @param mode Pointer to output the connected Wifi security mode to. (0 = Open Authentication, 1 = WEP 40-bit, 2 = WEP 104-bit, 3 = WEP 128-bit, 4 = WPA TKIP, 5 = WPA2 TKIP, 6 = WPA AES, 7 = WPA2 AES)
|
||||
*/
|
||||
Result ACU_GetSecurityMode(acSecurityMode *mode);
|
||||
|
||||
/**
|
||||
* @brief Gets the connected Wifi SSID.
|
||||
* @param SSID Pointer to output the connected Wifi SSID to.
|
||||
*/
|
||||
Result ACU_GetSSID(char *SSID);
|
||||
|
||||
/**
|
||||
* @brief Gets the connected Wifi SSID length.
|
||||
* @param out Pointer to output the connected Wifi SSID length to.
|
||||
*/
|
||||
Result ACU_GetSSIDLength(u32 *out);
|
||||
|
||||
/**
|
||||
* @brief Determines whether proxy is enabled for the connected network.
|
||||
* @param enable Pointer to output the proxy status to.
|
||||
*/
|
||||
Result ACU_GetProxyEnable(bool *enable);
|
||||
|
||||
/**
|
||||
* @brief Gets the connected network's proxy port.
|
||||
* @param out Pointer to output the proxy port to.
|
||||
*/
|
||||
Result ACU_GetProxyPort(u32 *out);
|
||||
|
||||
/**
|
||||
* @brief Gets the connected network's proxy username.
|
||||
* @param username Pointer to output the proxy username to. (The size must be at least 0x20-bytes)
|
||||
*/
|
||||
Result ACU_GetProxyUserName(char *username);
|
||||
|
||||
/**
|
||||
* @brief Gets the connected network's proxy password.
|
||||
* @param password Pointer to output the proxy password to. (The size must be at least 0x20-bytes)
|
||||
*/
|
||||
Result ACU_GetProxyPassword(char *password);
|
||||
|
||||
/**
|
||||
* @brief Gets the last error to occur during a connection.
|
||||
* @param errorCode Pointer to output the error code to.
|
||||
*/
|
||||
Result ACU_GetLastErrorCode(u32* errorCode);
|
||||
|
||||
/**
|
||||
* @brief Gets the last detailed error to occur during a connection.
|
||||
* @param errorCode Pointer to output the error code to.
|
||||
*/
|
||||
Result ACU_GetLastDetailErrorCode(u32* errorCode);
|
||||
|
||||
/**
|
||||
* @brief Prepares a buffer to hold the configuration data to start a connection.
|
||||
* @param config Pointer to an acuConfig struct to contain the data.
|
||||
*/
|
||||
Result ACU_CreateDefaultConfig(acuConfig* config);
|
||||
|
||||
/**
|
||||
* @brief Sets something that makes the connection reliable.
|
||||
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
|
||||
* @param area Always 2 ?
|
||||
*/
|
||||
Result ACU_SetNetworkArea(acuConfig* config, u8 area);
|
||||
|
||||
/**
|
||||
* @brief Sets the slot to use when connecting.
|
||||
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
|
||||
* @param type Allowed AP types bitmask, a combination of AC_AP_TYPE_* flags.
|
||||
*/
|
||||
Result ACU_SetAllowApType(acuConfig* config, u8 type);
|
||||
|
||||
/**
|
||||
* @brief Sets something that makes the connection reliable.
|
||||
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
|
||||
*/
|
||||
Result ACU_SetRequestEulaVersion(acuConfig* config);
|
||||
|
||||
/**
|
||||
* @brief Starts the connection procedure.
|
||||
* @param config Pointer to an acuConfig struct used with ACU_CreateDefaultConfig previously.
|
||||
* @param connectionHandle Handle created with svcCreateEvent to wait on until the connection succeeds or fails.
|
||||
*/
|
||||
Result ACU_ConnectAsync(const acuConfig* config, Handle connectionHandle);
|
||||
|
||||
/**
|
||||
* @brief Selects the WiFi configuration slot for further ac:i operations.
|
||||
* @param slot WiFi slot (0, 1 or 2).
|
||||
*/
|
||||
Result ACI_LoadNetworkSetting(u32 slot);
|
||||
|
||||
/**
|
||||
* @brief Fetches the SSID of the previously selected WiFi configuration slot.
|
||||
* @param[out] ssid Pointer to the output buffer of size 32B the SSID will be stored in.
|
||||
*/
|
||||
Result ACI_GetNetworkWirelessEssidSecuritySsid(void *ssid);
|
||||
|
@ -1,93 +1,538 @@
|
||||
/**
|
||||
* @file am.h
|
||||
* @brief AM (Application Manager) service.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/*
|
||||
Requires access to "am:net" or "am:u" service
|
||||
*/
|
||||
#include <3ds/services/fs.h>
|
||||
|
||||
Result amInit();
|
||||
Result amExit();
|
||||
/// Contains basic information about a title.
|
||||
typedef struct
|
||||
{
|
||||
u64 titleID; ///< The title's ID.
|
||||
u64 size; ///< The title's installed size.
|
||||
u16 version; ///< The title's version.
|
||||
u8 unk[6]; ///< Unknown title data.
|
||||
} AM_TitleEntry;
|
||||
|
||||
/* AM_GetTitleCount()
|
||||
About: Gets the number of titles for a given mediatype
|
||||
/// Pending title status mask values.
|
||||
enum
|
||||
{
|
||||
AM_STATUS_MASK_INSTALLING = BIT(0), ///< Titles currently installing.
|
||||
AM_STATUS_MASK_AWAITING_FINALIZATION = BIT(1) ///< Titles awaiting finalization.
|
||||
};
|
||||
|
||||
mediatype mediatype to get titles from
|
||||
count ptr to store title count
|
||||
*/
|
||||
Result AM_GetTitleCount(u8 mediatype, u32 *count);
|
||||
/// Pending title status values.
|
||||
typedef enum
|
||||
{
|
||||
AM_STATUS_ABORTED = 0x0002, ///< Install aborted.
|
||||
AM_STATUS_SAVED = 0x0003, ///< Title saved, but not installed.
|
||||
AM_STATUS_INSTALL_IN_PROGRESS = 0x0802, ///< Install in progress.
|
||||
AM_STATUS_AWAITING_FINALIZATION = 0x0803 ///< Awaiting finalization.
|
||||
} AM_InstallStatus;
|
||||
|
||||
/* AM_GetTitleList()
|
||||
About: Writes a titleid list for a mediatype to a buffer
|
||||
// Contains basic information about a pending title.
|
||||
typedef struct
|
||||
{
|
||||
u64 titleId; ///< Title ID
|
||||
u16 version; ///< Version
|
||||
u16 status; ///< @ref AM_InstallStatus
|
||||
u32 titleType; ///< Title Type
|
||||
u8 unk[0x8]; ///< Unknown
|
||||
} AM_PendingTitleEntry;
|
||||
|
||||
mediatype mediatype to get list from
|
||||
count number of titleids to get
|
||||
buffer buffer to write titleids to
|
||||
*/
|
||||
Result AM_GetTitleList(u8 mediatype, u32 count, void *buffer);
|
||||
/// Pending title deletion flags.
|
||||
enum
|
||||
{
|
||||
AM_DELETE_PENDING_NON_SYSTEM = BIT(0), ///< Non-system titles.
|
||||
AM_DELETE_PENDING_SYSTEM = BIT(1) ///< System titles.
|
||||
};
|
||||
|
||||
/* AM_GetDeviceId()
|
||||
About: Gets a 32bit device id, it's used for some key slot inits
|
||||
/// Information about the TWL NAND partition.
|
||||
typedef struct {
|
||||
u64 capacity; ///< Total capacity.
|
||||
u64 freeSpace; ///< Total free space.
|
||||
u64 titlesCapacity; ///< Capacity for titles.
|
||||
u64 titlesFreeSpace; ///< Free space for titles.
|
||||
} AM_TWLPartitionInfo;
|
||||
|
||||
device_id ptr to where the device id is written to
|
||||
*/
|
||||
Result AM_GetDeviceId(u32 *deviceid);
|
||||
/// Contains information about a title's content.
|
||||
typedef struct {
|
||||
u16 index; ///< Index of the content in the title.
|
||||
u16 type; ///< ?
|
||||
u32 contentId; ///< ID of the content in the title.
|
||||
u64 size; ///< Size of the content in the title.
|
||||
u8 flags; ///< @ref AM_ContentInfoFlags
|
||||
u8 padding[7]; ///< Padding
|
||||
} AM_ContentInfo;
|
||||
|
||||
/**** Title Install Methods ****/
|
||||
/* AM_StartCiaInstall()
|
||||
About: Inits CIA install process, the returned ciahandle is where the data for CIA should be written to
|
||||
/// Title ContentInfo flags.
|
||||
typedef enum
|
||||
{
|
||||
AM_CONTENT_DOWNLOADED = BIT(0), ///< ?
|
||||
AM_CONTENT_OWNED = BIT(1) ///< ?
|
||||
} AM_ContentInfoFlags;
|
||||
|
||||
mediatype mediatype to install CIA to
|
||||
ciahandle ptr to where the handle should be written to
|
||||
*/
|
||||
Result AM_StartCiaInstall(u8 mediatype, Handle *ciahandle);
|
||||
/// Initializes AM. This doesn't initialize with "am:app", see amAppInit().
|
||||
Result amInit(void);
|
||||
|
||||
/* AM_StartDlpChildCiaInstall()
|
||||
About: Inits CIA install process, the returned ciahandle is where the data for CIA should be written to
|
||||
Note: This is for installing DLP CIAs only, mediatype is hardcoded to be NAND
|
||||
/// Initializes AM with a service which has access to the amapp-commands. This should only be used when using the amapp commands, not non-amapp AM commands.
|
||||
Result amAppInit(void);
|
||||
|
||||
ciahandle ptr to where the handle should be written to
|
||||
*/
|
||||
Result AM_StartDlpChildCiaInstall(Handle *ciahandle);
|
||||
/// Exits AM.
|
||||
void amExit(void);
|
||||
|
||||
/* AM_CancelCIAInstall()
|
||||
About: Abort CIA install process
|
||||
/// Gets the current AM session handle.
|
||||
Handle *amGetSessionHandle(void);
|
||||
|
||||
ciahandle ptr to cia Handle provided by AM
|
||||
*/
|
||||
Result AM_CancelCIAInstall(Handle *ciahandle);
|
||||
/**
|
||||
* @brief Gets the number of titles for a given media type.
|
||||
* @param mediatype Media type to get titles from.
|
||||
* @param[out] count Pointer to write the title count to.
|
||||
*/
|
||||
Result AM_GetTitleCount(FS_MediaType mediatype, u32 *count);
|
||||
|
||||
/* AM_FinishCiaInstall()
|
||||
About: Once all data is written to the cia handle, this command signals AM to proceed with CIA install.
|
||||
Note: AM closes the cia handle provided here
|
||||
/**
|
||||
* @brief Gets a list of title IDs present in a mediatype.
|
||||
* @param[out] titlesRead Pointer to output the number of read titles to.
|
||||
* @param mediatype Media type to get titles from.
|
||||
* @param titleCount Number of title IDs to get.
|
||||
* @param titleIds Buffer to output the retrieved title IDs to.
|
||||
*/
|
||||
Result AM_GetTitleList(u32* titlesRead, FS_MediaType mediatype, u32 titleCount, u64 *titleIds);
|
||||
|
||||
mediatype same mediatype specified ciahandle was obtained
|
||||
ciahandle ptr to cia Handle provided by AM
|
||||
*/
|
||||
Result AM_FinishCiaInstall(u8 mediatype, Handle *ciahandle);
|
||||
/**
|
||||
* @brief Gets a list of details about installed titles.
|
||||
* @param mediatype Media type to get titles from.
|
||||
* @param titleCount Number of titles to list.
|
||||
* @param titleIds List of title IDs to retrieve details for.
|
||||
* @param titleInfo Buffer to write AM_TitleEntry's to.
|
||||
*/
|
||||
Result AM_GetTitleInfo(FS_MediaType mediatype, u32 titleCount, u64 *titleIds, AM_TitleEntry *titleInfo);
|
||||
|
||||
/**** Title Delete Methods ****/
|
||||
/* AM_DeleteTitle()
|
||||
About: Deletes any title on NAND/SDMC
|
||||
Note: AM closes the cia handle provided here
|
||||
/**
|
||||
* @brief Gets the number of tickets installed on the system.
|
||||
* @param[out] count Pointer to output the ticket count to.
|
||||
*/
|
||||
Result AM_GetTicketCount(u32 *count);
|
||||
|
||||
mediatype mediatype of title
|
||||
titleid title id of title
|
||||
*/
|
||||
Result AM_DeleteTitle(u8 mediatype, u64 titleid);
|
||||
/**
|
||||
* @brief Gets a list of tickets installed on the system.
|
||||
* @param[out] ticketsRead Pointer to output the number of read tickets to.
|
||||
* @param ticketCount Number of tickets to read.
|
||||
* @param skip Number of tickets to skip.
|
||||
* @param ticketIds Buffer to output the retrieved ticket IDs to.
|
||||
*/
|
||||
Result AM_GetTicketList(u32 *ticketsRead, u32 ticketCount, u32 skip, u64 *ticketIds);
|
||||
|
||||
/* AM_DeleteAppTitle()
|
||||
About: Deletes any title on NAND/SDMC
|
||||
Note: If the title has the system category bit set, this will fail
|
||||
/**
|
||||
* @brief Gets the number of pending titles on this system.
|
||||
* @param[out] count Pointer to output the pending title count to.
|
||||
* @param mediatype Media type of pending titles to count.
|
||||
* @param statusMask Bit mask of status values to include.
|
||||
*/
|
||||
Result AM_GetPendingTitleCount(u32 *count, FS_MediaType mediatype, u32 statusMask);
|
||||
|
||||
mediatype mediatype of title
|
||||
titleid title id of title
|
||||
*/
|
||||
Result AM_DeleteAppTitle(u8 mediatype, u64 titleid);
|
||||
/**
|
||||
* @brief Gets a list of pending titles on this system.
|
||||
* @param[out] titlesRead Pointer to output the number of read pending titles to.
|
||||
* @param titleCount Number of pending titles to read.
|
||||
* @param mediatype Media type of pending titles to list.
|
||||
* @param statusMask Bit mask of status values to include.
|
||||
* @param titleIds Buffer to output the retrieved pending title IDs to.
|
||||
*/
|
||||
Result AM_GetPendingTitleList(u32 *titlesRead, u32 titleCount, FS_MediaType mediatype, u32 statusMask, u64 *titleIds);
|
||||
|
||||
/* AM_InstallFIRM()
|
||||
About: Installs FIRM to NAND (firm0:/ & firm1:/) from a CXI
|
||||
Note: The title must have the uniqueid: 0x00000, otherwise this will fail.
|
||||
/**
|
||||
* @brief Gets information about pending titles on this system.
|
||||
* @param titleCount Number of pending titles to read.
|
||||
* @param mediatype Media type of pending titles to get information on.
|
||||
* @param titleIds IDs of the titles to get information about.
|
||||
* @param titleInfo Buffer to output the retrieved pending title info to.
|
||||
*/
|
||||
Result AM_GetPendingTitleInfo(u32 titleCount, FS_MediaType mediatype, u64 *titleIds, AM_PendingTitleEntry *titleInfo);
|
||||
|
||||
mediatype mediatype of title
|
||||
titleid title id of title
|
||||
*/
|
||||
Result AM_InstallFIRM(u8 mediatype, u64 titleid);
|
||||
/**
|
||||
* @brief Gets a 32-bit device-specific ID.
|
||||
* @param deviceID Pointer to write the device ID to.
|
||||
*/
|
||||
Result AM_GetDeviceId(u32 *deviceID);
|
||||
|
||||
/**
|
||||
* @brief Exports DSiWare to the specified filepath.
|
||||
* @param titleID TWL titleID.
|
||||
* @param operation DSiWare operation type.
|
||||
* @param workbuf Work buffer.
|
||||
* @param workbuf_size Work buffer size, must be >=0x20000.
|
||||
* @param filepath UTF-8 filepath(converted to UTF-16 internally).
|
||||
*/
|
||||
Result AM_ExportTwlBackup(u64 titleID, u8 operation, void* workbuf, u32 workbuf_size, const char *filepath);
|
||||
|
||||
/**
|
||||
* @brief Imports DSiWare from the specified file.
|
||||
* @param filehandle FSUSER file handle.
|
||||
* @param operation DSiWare operation type.
|
||||
* @param buffer Work buffer.
|
||||
* @param size Buffer size, must be >=0x20000.
|
||||
*/
|
||||
Result AM_ImportTwlBackup(Handle filehandle, u8 operation, void* buffer, u32 size);
|
||||
|
||||
/**
|
||||
* @brief Reads info from the specified DSiWare export file. This can only be used with DSiWare exported with certain operation value(s).
|
||||
* @param filehandle FSUSER file handle.
|
||||
* @param outinfo Output info buffer.
|
||||
* @param outinfo_size Output info buffer size.
|
||||
* @param workbuf Work buffer.
|
||||
* @param workbuf_size Work buffer size.
|
||||
* @param banner Output banner buffer.
|
||||
* @param banner_size Output banner buffer size.
|
||||
*/
|
||||
Result AM_ReadTwlBackupInfo(Handle filehandle, void* outinfo, u32 outinfo_size, void* workbuf, u32 workbuf_size, void* banner, u32 banner_size);
|
||||
|
||||
/**
|
||||
* @brief Retrieves information about the NAND TWL partition.
|
||||
* @param[out] info Pointer to output the TWL partition info to.
|
||||
*/
|
||||
Result AM_GetTWLPartitionInfo(AM_TWLPartitionInfo *info);
|
||||
|
||||
/**
|
||||
* @brief Initializes the CIA install process, returning a handle to write CIA data to.
|
||||
* @param mediatype Media type to install the CIA to.
|
||||
* @param[out] ciaHandle Pointer to write the CIA handle to.
|
||||
*/
|
||||
Result AM_StartCiaInstall(FS_MediaType mediatype, Handle *ciaHandle);
|
||||
|
||||
/**
|
||||
* @brief Initializes the CIA install process for Download Play CIAs, returning a handle to write CIA data to.
|
||||
* @param[out] ciaHandle Pointer to write the CIA handle to.
|
||||
*/
|
||||
Result AM_StartDlpChildCiaInstall(Handle *ciaHandle);
|
||||
|
||||
/**
|
||||
* @brief Aborts the CIA install process.
|
||||
* @param ciaHandle CIA handle to cancel.
|
||||
*/
|
||||
Result AM_CancelCIAInstall(Handle ciaHandle);
|
||||
|
||||
/**
|
||||
* @brief Finalizes the CIA install process.
|
||||
* @param ciaHandle CIA handle to finalize.
|
||||
*/
|
||||
Result AM_FinishCiaInstall(Handle ciaHandle);
|
||||
|
||||
/**
|
||||
* @brief Finalizes the CIA install process without committing the title to title.db or tmp*.db.
|
||||
* @param ciaHandle CIA handle to finalize.
|
||||
*/
|
||||
Result AM_FinishCiaInstallWithoutCommit(Handle ciaHandle);
|
||||
|
||||
/**
|
||||
* @brief Commits installed CIAs.
|
||||
* @param mediaType Location of the titles to finalize.
|
||||
* @param titleCount Number of titles to finalize.
|
||||
* @param temp Whether the titles being finalized are in the temporary database.
|
||||
* @param titleIds Title IDs to finalize.
|
||||
*/
|
||||
Result AM_CommitImportPrograms(FS_MediaType mediaType, u32 titleCount, bool temp, const u64* titleIds);
|
||||
|
||||
/**
|
||||
* @brief Deletes a title.
|
||||
* @param mediatype Media type to delete from.
|
||||
* @param titleID ID of the title to delete.
|
||||
*/
|
||||
Result AM_DeleteTitle(FS_MediaType mediatype, u64 titleID);
|
||||
|
||||
/**
|
||||
* @brief Deletes a title, provided that it is not a system title.
|
||||
* @param mediatype Media type to delete from.
|
||||
* @param titleID ID of the title to delete.
|
||||
*/
|
||||
Result AM_DeleteAppTitle(FS_MediaType mediatype, u64 titleID);
|
||||
|
||||
/**
|
||||
* @brief Deletes a ticket.
|
||||
* @param titleID ID of the ticket to delete.
|
||||
*/
|
||||
Result AM_DeleteTicket(u64 ticketId);
|
||||
|
||||
/**
|
||||
* @brief Deletes a pending title.
|
||||
* @param mediatype Media type to delete from.
|
||||
* @param titleId ID of the pending title to delete.
|
||||
*/
|
||||
Result AM_DeletePendingTitle(FS_MediaType mediatype, u64 titleId);
|
||||
|
||||
/**
|
||||
* @brief Deletes pending titles.
|
||||
* @param mediatype Media type to delete from.
|
||||
* @param flags Flags used to select pending titles.
|
||||
*/
|
||||
Result AM_DeletePendingTitles(FS_MediaType mediatype, u32 flags);
|
||||
|
||||
/**
|
||||
* @brief Deletes all pending titles.
|
||||
* @param mediatype Media type to delete from.
|
||||
*/
|
||||
Result AM_DeleteAllPendingTitles(FS_MediaType mediatype);
|
||||
|
||||
/// Installs the current NATIVE_FIRM title to NAND (firm0:/ & firm1:/)
|
||||
Result AM_InstallNativeFirm(void);
|
||||
|
||||
/**
|
||||
* @brief Installs a NATIVE_FIRM title to NAND. Accepts 0004013800000002 or 0004013820000002 (N3DS).
|
||||
* @param titleID Title ID of the NATIVE_FIRM to install.
|
||||
*/
|
||||
Result AM_InstallFirm(u64 titleID);
|
||||
|
||||
/**
|
||||
* @brief Gets the product code of a title.
|
||||
* @param mediatype Media type of the title.
|
||||
* @param titleID ID of the title.
|
||||
* @param[out] productCode Pointer to output the product code to. (length = 16)
|
||||
*/
|
||||
Result AM_GetTitleProductCode(FS_MediaType mediatype, u64 titleId, char *productCode);
|
||||
|
||||
/**
|
||||
* @brief Gets the ext data ID of a title.
|
||||
* @param[out] extDataId Pointer to output the ext data ID to.
|
||||
* @param mediatype Media type of the title.
|
||||
* @param titleID ID of the title.
|
||||
*/
|
||||
Result AM_GetTitleExtDataId(u64 *extDataId, FS_MediaType mediatype, u64 titleId);
|
||||
|
||||
/**
|
||||
* @brief Gets an AM_TitleEntry instance for a CIA file.
|
||||
* @param mediatype Media type that this CIA would be installed to.
|
||||
* @param[out] titleEntry Pointer to write the AM_TitleEntry instance to.
|
||||
* @param fileHandle Handle of the CIA file.
|
||||
*/
|
||||
Result AM_GetCiaFileInfo(FS_MediaType mediatype, AM_TitleEntry *titleEntry, Handle fileHandle);
|
||||
|
||||
/**
|
||||
* @brief Gets the SMDH icon data of a CIA file.
|
||||
* @param icon Buffer to store the icon data in. Must be of size 0x36C0 bytes.
|
||||
* @param fileHandle Handle of the CIA file.
|
||||
*/
|
||||
Result AM_GetCiaIcon(void *icon, Handle fileHandle);
|
||||
|
||||
/**
|
||||
* @brief Gets the title ID dependency list of a CIA file.
|
||||
* @param dependencies Buffer to store dependency title IDs in. Must be of size 0x300 bytes.
|
||||
* @param fileHandle Handle of the CIA file.
|
||||
*/
|
||||
Result AM_GetCiaDependencies(u64 *dependencies, Handle fileHandle);
|
||||
|
||||
/**
|
||||
* @brief Gets the meta section offset of a CIA file.
|
||||
* @param[out] metaOffset Pointer to output the meta section offset to.
|
||||
* @param fileHandle Handle of the CIA file.
|
||||
*/
|
||||
Result AM_GetCiaMetaOffset(u64 *metaOffset, Handle fileHandle);
|
||||
|
||||
/**
|
||||
* @brief Gets the core version of a CIA file.
|
||||
* @param[out] coreVersion Pointer to output the core version to.
|
||||
* @param fileHandle Handle of the CIA file.
|
||||
*/
|
||||
Result AM_GetCiaCoreVersion(u32 *coreVersion, Handle fileHandle);
|
||||
|
||||
/**
|
||||
* @brief Gets the free space, in bytes, required to install a CIA file.
|
||||
* @param[out] requiredSpace Pointer to output the required free space to.
|
||||
* @param mediaType Media type to check free space needed to install to.
|
||||
* @param fileHandle Handle of the CIA file.
|
||||
*/
|
||||
Result AM_GetCiaRequiredSpace(u64 *requiredSpace, FS_MediaType mediaType, Handle fileHandle);
|
||||
|
||||
/**
|
||||
* @brief Gets the full meta section of a CIA file.
|
||||
* @param meta Buffer to store the meta section in.
|
||||
* @param size Size of the buffer. Must be greater than or equal to the actual section data's size.
|
||||
* @param fileHandle Handle of the CIA file.
|
||||
*/
|
||||
Result AM_GetCiaMetaSection(void *meta, u32 size, Handle fileHandle);
|
||||
|
||||
/**
|
||||
* @brief Initializes the external (SD) title database.
|
||||
* @param overwrite Overwrites the database if it already exists.
|
||||
*/
|
||||
Result AM_InitializeExternalTitleDatabase(bool overwrite);
|
||||
|
||||
/**
|
||||
* @brief Queries whether the external title database is available.
|
||||
* @param[out] available Pointer to output the availability status to.
|
||||
*/
|
||||
Result AM_QueryAvailableExternalTitleDatabase(bool* available);
|
||||
|
||||
/**
|
||||
* @brief Begins installing a ticket.
|
||||
* @param[out] ticketHandle Pointer to output a handle to write ticket data to.
|
||||
*/
|
||||
Result AM_InstallTicketBegin(Handle *ticketHandle);
|
||||
|
||||
/**
|
||||
* @brief Aborts installing a ticket.
|
||||
* @param ticketHandle Handle of the installation to abort.
|
||||
*/
|
||||
Result AM_InstallTicketAbort(Handle ticketHandle);
|
||||
|
||||
/**
|
||||
* @brief Finishes installing a ticket.
|
||||
* @param ticketHandle Handle of the installation to finalize.
|
||||
*/
|
||||
Result AM_InstallTicketFinish(Handle ticketHandle);
|
||||
|
||||
/**
|
||||
* @brief Begins installing a title.
|
||||
* @param mediaType Destination to install to.
|
||||
* @param titleId ID of the title to install.
|
||||
* @param unk Unknown. (usually false)
|
||||
*/
|
||||
Result AM_InstallTitleBegin(FS_MediaType mediaType, u64 titleId, bool unk);
|
||||
|
||||
/// Stops installing a title, generally to be resumed later.
|
||||
Result AM_InstallTitleStop(void);
|
||||
|
||||
/**
|
||||
* @brief Resumes installing a title.
|
||||
* @param mediaType Destination to install to.
|
||||
* @param titleId ID of the title to install.
|
||||
*/
|
||||
Result AM_InstallTitleResume(FS_MediaType mediaType, u64 titleId);
|
||||
|
||||
/// Aborts installing a title.
|
||||
Result AM_InstallTitleAbort(void);
|
||||
|
||||
/// Finishes installing a title.
|
||||
Result AM_InstallTitleFinish(void);
|
||||
|
||||
/**
|
||||
* @brief Commits installed titles.
|
||||
* @param mediaType Location of the titles to finalize.
|
||||
* @param titleCount Number of titles to finalize.
|
||||
* @param temp Whether the titles being finalized are in the temporary database.
|
||||
* @param titleIds Title IDs to finalize.
|
||||
*/
|
||||
Result AM_CommitImportTitles(FS_MediaType mediaType, u32 titleCount, bool temp, const u64* titleIds);
|
||||
|
||||
/**
|
||||
* @brief Begins installing a TMD.
|
||||
* @param[out] tmdHandle Pointer to output a handle to write TMD data to.
|
||||
*/
|
||||
Result AM_InstallTmdBegin(Handle *tmdHandle);
|
||||
|
||||
/**
|
||||
* @brief Aborts installing a TMD.
|
||||
* @param tmdHandle Handle of the installation to abort.
|
||||
*/
|
||||
Result AM_InstallTmdAbort(Handle tmdHandle);
|
||||
|
||||
/**
|
||||
* @brief Finishes installing a TMD.
|
||||
* @param tmdHandle Handle of the installation to finalize.
|
||||
* @param unk Unknown. (usually true)
|
||||
*/
|
||||
Result AM_InstallTmdFinish(Handle tmdHandle, bool unk);
|
||||
|
||||
/**
|
||||
* @brief Prepares to import title contents.
|
||||
* @param contentCount Number of contents to be imported.
|
||||
* @param contentIndices Indices of the contents to be imported.
|
||||
*/
|
||||
Result AM_CreateImportContentContexts(u32 contentCount, u16* contentIndices);
|
||||
|
||||
/**
|
||||
* @brief Begins installing title content.
|
||||
* @param[out] contentHandle Pointer to output a handle to write content data to.
|
||||
* @param index Index of the content to install.
|
||||
*/
|
||||
Result AM_InstallContentBegin(Handle *contentHandle, u16 index);
|
||||
|
||||
/**
|
||||
* @brief Stops installing title content, generally to be resumed later.
|
||||
* @param contentHandle Handle of the installation to abort.
|
||||
*/
|
||||
Result AM_InstallContentStop(Handle contentHandle);
|
||||
|
||||
/**
|
||||
* @brief Resumes installing title content.
|
||||
* @param[out] contentHandle Pointer to output a handle to write content data to.
|
||||
* @param[out] resumeOffset Pointer to write the offset to resume content installation at to.
|
||||
* @param index Index of the content to install.
|
||||
*/
|
||||
Result AM_InstallContentResume(Handle *contentHandle, u64* resumeOffset, u16 index);
|
||||
|
||||
/**
|
||||
* @brief Cancels installing title content.
|
||||
* @param contentHandle Handle of the installation to finalize.
|
||||
*/
|
||||
Result AM_InstallContentCancel(Handle contentHandle);
|
||||
|
||||
/**
|
||||
* @brief Finishes installing title content.
|
||||
* @param contentHandle Handle of the installation to finalize.
|
||||
*/
|
||||
Result AM_InstallContentFinish(Handle contentHandle);
|
||||
|
||||
/**
|
||||
* @brief Imports up to four certificates into the ticket certificate chain.
|
||||
* @param cert1Size Size of the first certificate.
|
||||
* @param cert1 Data of the first certificate.
|
||||
* @param cert2Size Size of the second certificate.
|
||||
* @param cert2 Data of the second certificate.
|
||||
* @param cert3Size Size of the third certificate.
|
||||
* @param cert3 Data of the third certificate.
|
||||
* @param cert4Size Size of the fourth certificate.
|
||||
* @param cert4 Data of the fourth certificate.
|
||||
*/
|
||||
Result AM_ImportCertificates(u32 cert1Size, void* cert1, u32 cert2Size, void* cert2, u32 cert3Size, void* cert3, u32 cert4Size, void* cert4);
|
||||
|
||||
/**
|
||||
* @brief Imports a certificate into the ticket certificate chain.
|
||||
* @param certSize Size of the certificate.
|
||||
* @param cert Data of the certificate.
|
||||
*/
|
||||
Result AM_ImportCertificate(u32 certSize, void* cert);
|
||||
|
||||
/**
|
||||
* @brief Commits installed titles, and updates FIRM if necessary.
|
||||
* @param mediaType Location of the titles to finalize.
|
||||
* @param titleCount Number of titles to finalize.
|
||||
* @param temp Whether the titles being finalized are in the temporary database.
|
||||
* @param titleIds Title IDs to finalize.
|
||||
*/
|
||||
Result AM_CommitImportTitlesAndUpdateFirmwareAuto(FS_MediaType mediaType, u32 titleCount, bool temp, u64* titleIds);
|
||||
|
||||
/// Resets play count of all installed demos by deleting their launch info.
|
||||
Result AM_DeleteAllDemoLaunchInfos(void);
|
||||
|
||||
/// Deletes temporary titles.
|
||||
Result AM_DeleteAllTemporaryTitles(void);
|
||||
|
||||
/**
|
||||
* @brief Deletes all expired titles.
|
||||
* @param mediatype Media type to delete from.
|
||||
*/
|
||||
Result AM_DeleteAllExpiredTitles(FS_MediaType mediatype);
|
||||
|
||||
/// Deletes all TWL titles.
|
||||
Result AM_DeleteAllTwlTitles(void);
|
||||
|
||||
/**
|
||||
* @brief Gets the number of content index installed under the specified DLC title.
|
||||
* @param[out] count Pointer to output the number of content indices to.
|
||||
* @param mediatype Media type of the title.
|
||||
* @param titleID Title ID to retrieve the count for (high-id is 0x0004008C).
|
||||
*/
|
||||
Result AMAPP_GetDLCContentInfoCount(u32* count, FS_MediaType mediatype, u64 titleID);
|
||||
|
||||
/**
|
||||
* @brief Gets content infos installed under the specified DLC title.
|
||||
* @param[out] contentInfoRead Pointer to output the number of content infos read to.
|
||||
* @param mediatype Media type of the title.
|
||||
* @param titleID Title ID to retrieve the content infos for (high-id is 0x0004008C).
|
||||
* @param contentInfoCount Number of content infos to retrieve.
|
||||
* @param offset Offset from the first content index the count starts at.
|
||||
* @param[out] contentInfos Pointer to output the content infos read to.
|
||||
*/
|
||||
Result AMAPP_ListDLCContentInfos(u32* contentInfoRead, FS_MediaType mediatype, u64 titleID, u32 contentInfoCount, u32 offset, AM_ContentInfo* contentInfos);
|
||||
|
35
libctru/include/3ds/services/ampxi.h
Normal file
35
libctru/include/3ds/services/ampxi.h
Normal file
@ -0,0 +1,35 @@
|
||||
/**
|
||||
* @file ampxi.h
|
||||
* @brief AMPXI service. This is normally not accessible to userland apps. https://3dbrew.org/wiki/Application_Manager_Services_PXI
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* @brief Initializes AMPXI.
|
||||
* @param servhandle Optional service session handle to use for AMPXI, if zero srvGetServiceHandle() will be used.
|
||||
*/
|
||||
Result ampxiInit(Handle servhandle);
|
||||
|
||||
/// Exits AMPXI.
|
||||
void ampxiExit(void);
|
||||
|
||||
/**
|
||||
* @brief Writes a TWL save-file to NAND. https://www.3dbrew.org/wiki/AMPXI:WriteTWLSavedata
|
||||
* @param titleid ID of the TWL title.
|
||||
* @param buffer Savedata buffer ptr.
|
||||
* @param size Size of the savedata buffer.
|
||||
* @param image_filepos Filepos to use for writing the data to the NAND savedata file.
|
||||
* @param section_type https://www.3dbrew.org/wiki/AMPXI:WriteTWLSavedata
|
||||
* @param operation https://3dbrew.org/wiki/AM:ImportDSiWare
|
||||
*/
|
||||
Result AMPXI_WriteTWLSavedata(u64 titleid, u8 *buffer, u32 size, u32 image_filepos, u8 section_type, u8 operation);
|
||||
|
||||
/**
|
||||
* @brief Finalizes title installation. https://3dbrew.org/wiki/AMPXI:InstallTitlesFinish
|
||||
* @param mediaType Mediatype of the titles to finalize.
|
||||
* @param db Which title database to use.
|
||||
* @param size Size of the savedata buffer.
|
||||
* @param titlecount Total titles.
|
||||
* @param tidlist List of titleIDs.
|
||||
*/
|
||||
Result AMPXI_InstallTitlesFinish(FS_MediaType mediaType, u8 db, u32 titlecount, u64 *tidlist);
|
@ -1,85 +1,581 @@
|
||||
/**
|
||||
* @file apt.h
|
||||
* @brief APT (Applet) service.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
// TODO : find a better place to put this
|
||||
#define RUNFLAG_APTWORKAROUND (BIT(0))
|
||||
/**
|
||||
* @brief NS Application IDs.
|
||||
*
|
||||
* Retrieved from http://3dbrew.org/wiki/NS_and_APT_Services#AppIDs
|
||||
*/
|
||||
typedef enum {
|
||||
APPID_NONE = 0,
|
||||
APPID_HOMEMENU = 0x101, ///< Home Menu
|
||||
APPID_CAMERA = 0x110, ///< Camera applet
|
||||
APPID_FRIENDS_LIST = 0x112, ///< Friends List applet
|
||||
APPID_GAME_NOTES = 0x113, ///< Game Notes applet
|
||||
APPID_WEB = 0x114, ///< Internet Browser
|
||||
APPID_INSTRUCTION_MANUAL = 0x115, ///< Instruction Manual applet
|
||||
APPID_NOTIFICATIONS = 0x116, ///< Notifications applet
|
||||
APPID_MIIVERSE = 0x117, ///< Miiverse applet (olv)
|
||||
APPID_MIIVERSE_POSTING = 0x118, ///< Miiverse posting applet (solv3)
|
||||
APPID_AMIIBO_SETTINGS = 0x119, ///< Amiibo settings applet (cabinet)
|
||||
APPID_APPLICATION = 0x300, ///< Application
|
||||
APPID_ESHOP = 0x301, ///< eShop (tiger)
|
||||
APPID_SOFTWARE_KEYBOARD = 0x401, ///< Software Keyboard
|
||||
APPID_APPLETED = 0x402, ///< appletEd
|
||||
APPID_PNOTE_AP = 0x404, ///< PNOTE_AP
|
||||
APPID_SNOTE_AP = 0x405, ///< SNOTE_AP
|
||||
APPID_ERROR = 0x406, ///< error
|
||||
APPID_MINT = 0x407, ///< mint
|
||||
APPID_EXTRAPAD = 0x408, ///< extrapad
|
||||
APPID_MEMOLIB = 0x409, ///< memolib
|
||||
} NS_APPID;
|
||||
|
||||
typedef enum{
|
||||
APPID_HOMEMENU = 0x101, // Home Menu
|
||||
APPID_CAMERA = 0x110, // Camera applet
|
||||
APPID_WEB = 0x114, // Internet Browser
|
||||
APPID_APPLICATION = 0x300, // Application
|
||||
}NS_APPID; // cf http://3dbrew.org/wiki/NS#AppIDs
|
||||
/// APT applet position.
|
||||
typedef enum {
|
||||
APTPOS_NONE = -1, ///< No position specified.
|
||||
APTPOS_APP = 0, ///< Application.
|
||||
APTPOS_APPLIB = 1, ///< Application library (?).
|
||||
APTPOS_SYS = 2, ///< System applet.
|
||||
APTPOS_SYSLIB = 3, ///< System library (?).
|
||||
APTPOS_RESIDENT = 4, ///< Resident applet.
|
||||
} APT_AppletPos;
|
||||
|
||||
typedef enum{
|
||||
APP_NOTINITIALIZED,
|
||||
APP_RUNNING,
|
||||
APP_SUSPENDED,
|
||||
APP_EXITING,
|
||||
APP_SUSPENDING,
|
||||
APP_SLEEPMODE,
|
||||
APP_PREPARE_SLEEPMODE,
|
||||
APP_APPLETSTARTED,
|
||||
APP_APPLETCLOSED
|
||||
}APP_STATUS;
|
||||
typedef u8 APT_AppletAttr;
|
||||
|
||||
enum {
|
||||
APTSIGNAL_HOMEBUTTON = 1,
|
||||
// 2: sleep-mode related?
|
||||
APTSIGNAL_PREPARESLEEP = 3,
|
||||
// 4: triggered when ptm:s GetShellStatus() returns 5.
|
||||
APTSIGNAL_ENTERSLEEP = 5,
|
||||
APTSIGNAL_WAKEUP = 6,
|
||||
APTSIGNAL_ENABLE = 7,
|
||||
APTSIGNAL_POWERBUTTON = 8,
|
||||
APTSIGNAL_UTILITY = 9,
|
||||
APTSIGNAL_SLEEPSYSTEM = 10,
|
||||
APTSIGNAL_ERROR = 11
|
||||
};
|
||||
struct PtmWakeEvents;
|
||||
|
||||
/// Create an APT_AppletAttr bitfield from its components.
|
||||
static inline APT_AppletAttr aptMakeAppletAttr(APT_AppletPos pos, bool manualGpuRights, bool manualDspRights)
|
||||
{
|
||||
return (pos&7) | (manualGpuRights ? BIT(3) : 0) | (manualDspRights ? BIT(4) : 0);
|
||||
}
|
||||
|
||||
extern Handle aptEvents[3];
|
||||
/// APT query reply.
|
||||
typedef enum {
|
||||
APTREPLY_REJECT = 0,
|
||||
APTREPLY_ACCEPT = 1,
|
||||
APTREPLY_LATER = 2,
|
||||
} APT_QueryReply;
|
||||
|
||||
Result aptInit();
|
||||
void aptExit();
|
||||
void aptOpenSession();
|
||||
void aptCloseSession();
|
||||
void aptSetStatus(APP_STATUS status);
|
||||
APP_STATUS aptGetStatus();
|
||||
u32 aptGetStatusPower();//This can be used when the status is APP_SUSPEND* to check how the return-to-menu was triggered: 0 = home-button, 1 = power-button.
|
||||
void aptSetStatusPower(u32 status);
|
||||
void aptReturnToMenu();//This should be called by the user application when aptGetStatus() returns APP_SUSPENDING, not calling this will result in return-to-menu being disabled with the status left at APP_SUSPENDING. This function will not return until the system returns to the application, or when the status was changed to APP_EXITING.
|
||||
void aptWaitStatusEvent();
|
||||
void aptSignalReadyForSleep();
|
||||
NS_APPID aptGetMenuAppID();
|
||||
bool aptMainLoop(); // Use like this in your main(): while (aptMainLoop()) { your code here... }
|
||||
/// APT signals.
|
||||
typedef enum {
|
||||
APTSIGNAL_NONE = 0, ///< No signal received.
|
||||
APTSIGNAL_HOMEBUTTON = 1, ///< HOME button pressed.
|
||||
APTSIGNAL_HOMEBUTTON2 = 2, ///< HOME button pressed (again?).
|
||||
APTSIGNAL_SLEEP_QUERY = 3, ///< Prepare to enter sleep mode.
|
||||
APTSIGNAL_SLEEP_CANCEL = 4, ///< Triggered when ptm:s GetShellStatus() returns 5.
|
||||
APTSIGNAL_SLEEP_ENTER = 5, ///< Enter sleep mode.
|
||||
APTSIGNAL_SLEEP_WAKEUP = 6, ///< Wake from sleep mode.
|
||||
APTSIGNAL_SHUTDOWN = 7, ///< Shutdown.
|
||||
APTSIGNAL_POWERBUTTON = 8, ///< POWER button pressed.
|
||||
APTSIGNAL_POWERBUTTON2 = 9, ///< POWER button cleared (?).
|
||||
APTSIGNAL_TRY_SLEEP = 10, ///< System sleeping (?).
|
||||
APTSIGNAL_ORDERTOCLOSE = 11, ///< Order to close (such as when an error happens?).
|
||||
} APT_Signal;
|
||||
|
||||
Result APT_GetLockHandle(Handle* handle, u16 flags, Handle* lockHandle);
|
||||
Result APT_Initialize(Handle* handle, NS_APPID appId, Handle* eventHandle1, Handle* eventHandle2);
|
||||
Result APT_HardwareResetAsync(Handle* handle);
|
||||
Result APT_Enable(Handle* handle, u32 a);
|
||||
Result APT_GetAppletManInfo(Handle* handle, u8 inval, u8 *outval8, u32 *outval32, NS_APPID *menu_appid, NS_APPID *active_appid);
|
||||
Result APT_PrepareToJumpToHomeMenu(Handle* handle);
|
||||
Result APT_JumpToHomeMenu(Handle* handle, u32 a, u32 b, u32 c);
|
||||
Result APT_IsRegistered(Handle* handle, NS_APPID appID, u8* out);
|
||||
Result APT_InquireNotification(Handle* handle, u32 appID, u8* signalType);
|
||||
Result APT_NotifyToWait(Handle* handle, NS_APPID appID);
|
||||
Result APT_AppletUtility(Handle* handle, u32* out, u32 a, u32 size1, u8* buf1, u32 size2, u8* buf2);
|
||||
Result APT_GlanceParameter(Handle* handle, NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
|
||||
Result APT_ReceiveParameter(Handle* handle, NS_APPID appID, u32 bufferSize, u32* buffer, u32* actualSize, u8* signalType);
|
||||
Result APT_SendParameter(Handle* handle, NS_APPID src_appID, NS_APPID dst_appID, u32 bufferSize, u32* buffer, Handle paramhandle, u8 signalType);
|
||||
Result APT_SendCaptureBufferInfo(Handle* handle, u32 bufferSize, u32* buffer);
|
||||
Result APT_ReplySleepQuery(Handle* handle, NS_APPID appID, u32 a);
|
||||
Result APT_ReplySleepNotificationComplete(Handle* handle, NS_APPID appID);
|
||||
Result APT_PrepareToCloseApplication(Handle* handle, u8 a);
|
||||
Result APT_CloseApplication(Handle* handle, u32 a, u32 b, u32 c);
|
||||
Result APT_SetAppCpuTimeLimit(Handle* handle, u32 percent);
|
||||
Result APT_GetAppCpuTimeLimit(Handle* handle, u32 *percent);
|
||||
Result APT_CheckNew3DS_Application(Handle* handle, u8 *out);//*Application and *System use APT commands 0x01010000 and 0x01020000. Using APT_CheckNew3DS() is recommended, this determines which of those two funcs to use automatically. When this is first called(this calls aptOpenSession/aptCloseSession internally), this initializes an internal flag, which is then used for the out val for all future calls.
|
||||
Result APT_CheckNew3DS_System(Handle* handle, u8 *out);
|
||||
Result APT_CheckNew3DS(Handle* handle, u8 *out);
|
||||
Result APT_PrepareToDoAppJump(Handle* handle, u8 flags, u64 programID, u8 mediatype);
|
||||
Result APT_DoAppJump(Handle* handle, u32 NSbuf0Size, u32 NSbuf1Size, u8 *NSbuf0Ptr, u8 *NSbuf1Ptr);
|
||||
Result APT_PrepareToStartLibraryApplet(Handle* handle, NS_APPID appID);
|
||||
Result APT_StartLibraryApplet(Handle* handle, NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize);
|
||||
Result APT_LaunchLibraryApplet(NS_APPID appID, Handle inhandle, u32 *parambuf, u32 parambufsize);//This should be used for launching library applets, this uses the above APT_StartLibraryApplet/APT_PrepareToStartLibraryApplet funcs + apt*Session(). parambuf is used for APT params input, when the applet closes the output param block is copied here. This is not usable from the homebrew launcher. This is broken: when the applet does get launched at all, the applet process doesn't actually get terminated when the applet gets closed.
|
||||
/// APT commands.
|
||||
typedef enum {
|
||||
APTCMD_NONE = 0, ///< No command received.
|
||||
APTCMD_WAKEUP = 1, ///< Applet should wake up.
|
||||
APTCMD_REQUEST = 2, ///< Source applet sent us a parameter.
|
||||
APTCMD_RESPONSE = 3, ///< Target applet replied to our parameter.
|
||||
APTCMD_EXIT = 4, ///< Exit (??)
|
||||
APTCMD_MESSAGE = 5, ///< Message (??)
|
||||
APTCMD_HOMEBUTTON_ONCE = 6, ///< HOME button pressed once.
|
||||
APTCMD_HOMEBUTTON_TWICE = 7, ///< HOME button pressed twice (double-pressed).
|
||||
APTCMD_DSP_SLEEP = 8, ///< DSP should sleep (manual DSP rights related?).
|
||||
APTCMD_DSP_WAKEUP = 9, ///< DSP should wake up (manual DSP rights related?).
|
||||
APTCMD_WAKEUP_EXIT = 10, ///< Applet wakes up due to a different applet exiting.
|
||||
APTCMD_WAKEUP_PAUSE = 11, ///< Applet wakes up after being paused through HOME menu.
|
||||
APTCMD_WAKEUP_CANCEL = 12, ///< Applet wakes up due to being cancelled.
|
||||
APTCMD_WAKEUP_CANCELALL = 13, ///< Applet wakes up due to all applets being cancelled.
|
||||
APTCMD_WAKEUP_POWERBUTTON = 14, ///< Applet wakes up due to POWER button being pressed (?).
|
||||
APTCMD_WAKEUP_JUMPTOHOME = 15, ///< Applet wakes up and is instructed to jump to HOME menu (?).
|
||||
APTCMD_SYSAPPLET_REQUEST = 16, ///< Request for sysapplet (?).
|
||||
APTCMD_WAKEUP_LAUNCHAPP = 17, ///< Applet wakes up and is instructed to launch another applet (?).
|
||||
} APT_Command;
|
||||
|
||||
/// APT capture buffer information.
|
||||
typedef struct
|
||||
{
|
||||
u32 size;
|
||||
u32 is3D;
|
||||
struct
|
||||
{
|
||||
u32 leftOffset;
|
||||
u32 rightOffset;
|
||||
u32 format;
|
||||
} top, bottom;
|
||||
} aptCaptureBufInfo;
|
||||
|
||||
/// APT hook types.
|
||||
typedef enum {
|
||||
APTHOOK_ONSUSPEND = 0, ///< App suspended.
|
||||
APTHOOK_ONRESTORE, ///< App restored.
|
||||
APTHOOK_ONSLEEP, ///< App sleeping.
|
||||
APTHOOK_ONWAKEUP, ///< App waking up.
|
||||
APTHOOK_ONEXIT, ///< App exiting.
|
||||
|
||||
APTHOOK_COUNT, ///< Number of APT hook types.
|
||||
} APT_HookType;
|
||||
|
||||
/// APT hook function.
|
||||
typedef void (*aptHookFn)(APT_HookType hook, void* param);
|
||||
|
||||
/// APT hook cookie.
|
||||
typedef struct tag_aptHookCookie
|
||||
{
|
||||
struct tag_aptHookCookie* next; ///< Next cookie.
|
||||
aptHookFn callback; ///< Hook callback.
|
||||
void* param; ///< Callback parameter.
|
||||
} aptHookCookie;
|
||||
|
||||
/// APT message callback.
|
||||
typedef void (*aptMessageCb)(void* user, NS_APPID sender, void* msg, size_t msgsize);
|
||||
|
||||
/// Initializes APT.
|
||||
Result aptInit(void);
|
||||
|
||||
/// Exits APT.
|
||||
void aptExit(void);
|
||||
|
||||
/**
|
||||
* @brief Sends an APT command through IPC, taking care of locking, opening and closing an APT session.
|
||||
* @param aptcmdbuf Pointer to command buffer (should have capacity for at least 16 words).
|
||||
*/
|
||||
Result aptSendCommand(u32* aptcmdbuf);
|
||||
|
||||
/// Returns true if the application is currently in the foreground.
|
||||
bool aptIsActive(void);
|
||||
|
||||
/// Returns true if the system has told the application to close.
|
||||
bool aptShouldClose(void);
|
||||
|
||||
/// Returns true if the system can enter sleep mode while the application is active.
|
||||
bool aptIsSleepAllowed(void);
|
||||
|
||||
/// Configures whether the system can enter sleep mode while the application is active.
|
||||
void aptSetSleepAllowed(bool allowed);
|
||||
|
||||
/// Handles incoming sleep mode requests.
|
||||
void aptHandleSleep(void);
|
||||
|
||||
/// Returns true if the user can press the HOME button to jump back to the HOME menu while the application is active.
|
||||
bool aptIsHomeAllowed(void);
|
||||
|
||||
/// Configures whether the user can press the HOME button to jump back to the HOME menu while the application is active.
|
||||
void aptSetHomeAllowed(bool allowed);
|
||||
|
||||
/// Returns true if the system requires the application to jump back to the HOME menu.
|
||||
bool aptShouldJumpToHome(void);
|
||||
|
||||
/// Returns true if there is an incoming HOME button press rejected by the policy set by \ref aptSetHomeAllowed (use this to show a "no HOME allowed" icon).
|
||||
bool aptCheckHomePressRejected(void);
|
||||
|
||||
/// \deprecated Alias for \ref aptCheckHomePressRejected.
|
||||
static inline CTR_DEPRECATED bool aptIsHomePressed(void)
|
||||
{
|
||||
return aptCheckHomePressRejected();
|
||||
}
|
||||
|
||||
/// Jumps back to the HOME menu.
|
||||
void aptJumpToHomeMenu(void);
|
||||
|
||||
/// Handles incoming jump-to-HOME requests.
|
||||
static inline void aptHandleJumpToHome(void)
|
||||
{
|
||||
if (aptShouldJumpToHome())
|
||||
aptJumpToHomeMenu();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Main function which handles sleep mode and HOME/power buttons - call this at the beginning of every frame.
|
||||
* @return true if the application should keep running, false otherwise (see \ref aptShouldClose).
|
||||
*/
|
||||
bool aptMainLoop(void);
|
||||
|
||||
/**
|
||||
* @brief Sets up an APT status hook.
|
||||
* @param cookie Hook cookie to use.
|
||||
* @param callback Function to call when APT's status changes.
|
||||
* @param param User-defined parameter to pass to the callback.
|
||||
*/
|
||||
void aptHook(aptHookCookie* cookie, aptHookFn callback, void* param);
|
||||
|
||||
/**
|
||||
* @brief Removes an APT status hook.
|
||||
* @param cookie Hook cookie to remove.
|
||||
*/
|
||||
void aptUnhook(aptHookCookie* cookie);
|
||||
|
||||
/**
|
||||
* @brief Sets the function to be called when an APT message from another applet is received.
|
||||
* @param callback Callback function.
|
||||
* @param user User-defined data to be passed to the callback.
|
||||
*/
|
||||
void aptSetMessageCallback(aptMessageCb callback, void* user);
|
||||
|
||||
/**
|
||||
* @brief Launches a library applet.
|
||||
* @param appId ID of the applet to launch.
|
||||
* @param buf Input/output buffer that contains launch parameters on entry and result data on exit.
|
||||
* @param bufsize Size of the buffer.
|
||||
* @param handle Handle to pass to the library applet.
|
||||
*/
|
||||
void aptLaunchLibraryApplet(NS_APPID appId, void* buf, size_t bufsize, Handle handle);
|
||||
|
||||
/// Clears the chainloader state.
|
||||
void aptClearChainloader(void);
|
||||
|
||||
/**
|
||||
* @brief Configures the chainloader to launch a specific application.
|
||||
* @param programID ID of the program to chainload to.
|
||||
* @param mediatype Media type of the program to chainload to.
|
||||
*/
|
||||
void aptSetChainloader(u64 programID, u8 mediatype);
|
||||
|
||||
/// Configures the chainloader to launch the previous application.
|
||||
void aptSetChainloaderToCaller(void);
|
||||
|
||||
/// Configures the chainloader to relaunch the current application (i.e. soft-reset)
|
||||
void aptSetChainloaderToSelf(void);
|
||||
|
||||
/**
|
||||
* @brief Sets the "deliver arg" and HMAC for the chainloader, which will
|
||||
* be passed to the target 3DS/DS(i) application. The meaning of each
|
||||
* parameter varies on a per-application basis.
|
||||
* @param deliverArg Deliver arg to pass to the target application.
|
||||
* @param deliverArgSize Size of the deliver arg, maximum 0x300 bytes.
|
||||
* @param hmac HMAC buffer, 32 bytes. Use NULL to pass an all-zero dummy HMAC.
|
||||
*/
|
||||
void aptSetChainloaderArgs(const void *deliverArg, size_t deliverArgSize, const void *hmac);
|
||||
|
||||
/**
|
||||
* @brief Gets an APT lock handle.
|
||||
* @param flags Flags to use.
|
||||
* @param lockHandle Pointer to output the lock handle to.
|
||||
*/
|
||||
Result APT_GetLockHandle(u16 flags, Handle* lockHandle);
|
||||
|
||||
/**
|
||||
* @brief Initializes an application's registration with APT.
|
||||
* @param appId ID of the application.
|
||||
* @param attr Attributes of the application.
|
||||
* @param signalEvent Pointer to output the signal event handle to.
|
||||
* @param resumeEvent Pointer to output the resume event handle to.
|
||||
*/
|
||||
Result APT_Initialize(NS_APPID appId, APT_AppletAttr attr, Handle* signalEvent, Handle* resumeEvent);
|
||||
|
||||
/**
|
||||
* @brief Terminates an application's registration with APT.
|
||||
* @param appID ID of the application.
|
||||
*/
|
||||
Result APT_Finalize(NS_APPID appId);
|
||||
|
||||
/// Asynchronously resets the hardware.
|
||||
Result APT_HardwareResetAsync(void);
|
||||
|
||||
/**
|
||||
* @brief Enables APT.
|
||||
* @param attr Attributes of the application.
|
||||
*/
|
||||
Result APT_Enable(APT_AppletAttr attr);
|
||||
|
||||
/**
|
||||
* @brief Gets applet management info.
|
||||
* @param inpos Requested applet position.
|
||||
* @param outpos Pointer to output the position of the current applet to.
|
||||
* @param req_appid Pointer to output the AppID of the applet at the requested position to.
|
||||
* @param menu_appid Pointer to output the HOME menu AppID to.
|
||||
* @param active_appid Pointer to output the AppID of the currently active applet to.
|
||||
*/
|
||||
Result APT_GetAppletManInfo(APT_AppletPos inpos, APT_AppletPos* outpos, NS_APPID* req_appid, NS_APPID* menu_appid, NS_APPID* active_appid);
|
||||
|
||||
/**
|
||||
* @brief Gets the menu's app ID.
|
||||
* @return The menu's app ID.
|
||||
*/
|
||||
static inline NS_APPID aptGetMenuAppID(void)
|
||||
{
|
||||
NS_APPID menu_appid = APPID_NONE;
|
||||
APT_GetAppletManInfo(APTPOS_NONE, NULL, NULL, &menu_appid, NULL);
|
||||
return menu_appid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gets an applet's information.
|
||||
* @param appID AppID of the applet.
|
||||
* @param pProgramID Pointer to output the program ID to.
|
||||
* @param pMediaType Pointer to output the media type to.
|
||||
* @param pRegistered Pointer to output the registration status to.
|
||||
* @param pLoadState Pointer to output the load state to.
|
||||
* @param pAttributes Pointer to output the applet atrributes to.
|
||||
*/
|
||||
Result APT_GetAppletInfo(NS_APPID appID, u64* pProgramID, u8* pMediaType, bool* pRegistered, bool* pLoadState, APT_AppletAttr* pAttributes);
|
||||
|
||||
/**
|
||||
* @brief Gets an applet's program information.
|
||||
* @param id ID of the applet.
|
||||
* @param flags Flags to use when retreiving the information.
|
||||
* @param titleversion Pointer to output the applet's title version to.
|
||||
*
|
||||
* Flags:
|
||||
* - 0x01: Use AM_ListTitles with NAND media type.
|
||||
* - 0x02: Use AM_ListTitles with SDMC media type.
|
||||
* - 0x04: Use AM_ListTitles with GAMECARD media type.
|
||||
* - 0x10: Input ID is an app ID. Must be set if 0x20 is not.
|
||||
* - 0x20: Input ID is a program ID. Must be set if 0x10 is not.
|
||||
* - 0x100: Sets program ID high to 0x00040000, else it is 0x00040010. Only used when 0x20 is set.
|
||||
*/
|
||||
Result APT_GetAppletProgramInfo(u32 id, u32 flags, u16 *titleversion);
|
||||
|
||||
/**
|
||||
* @brief Gets the current application's program ID.
|
||||
* @param pProgramID Pointer to output the program ID to.
|
||||
*/
|
||||
Result APT_GetProgramID(u64* pProgramID);
|
||||
|
||||
/// Prepares to jump to the home menu.
|
||||
Result APT_PrepareToJumpToHomeMenu(void);
|
||||
|
||||
/**
|
||||
* @brief Jumps to the home menu.
|
||||
* @param param Parameters to jump with.
|
||||
* @param Size of the parameter buffer.
|
||||
* @param handle Handle to pass.
|
||||
*/
|
||||
Result APT_JumpToHomeMenu(const void* param, size_t paramSize, Handle handle);
|
||||
|
||||
/**
|
||||
* @brief Prepares to jump to an application.
|
||||
* @param exiting Specifies whether the applet is exiting.
|
||||
*/
|
||||
Result APT_PrepareToJumpToApplication(bool exiting);
|
||||
|
||||
/**
|
||||
* @brief Jumps to an application.
|
||||
* @param param Parameters to jump with.
|
||||
* @param Size of the parameter buffer.
|
||||
* @param handle Handle to pass.
|
||||
*/
|
||||
Result APT_JumpToApplication(const void* param, size_t paramSize, Handle handle);
|
||||
|
||||
/**
|
||||
* @brief Gets whether an application is registered.
|
||||
* @param appID ID of the application.
|
||||
* @param out Pointer to output the registration state to.
|
||||
*/
|
||||
Result APT_IsRegistered(NS_APPID appID, bool* out);
|
||||
|
||||
/**
|
||||
* @brief Inquires as to whether a signal has been received.
|
||||
* @param appID ID of the application.
|
||||
* @param signalType Pointer to output the signal type to.
|
||||
*/
|
||||
Result APT_InquireNotification(u32 appID, APT_Signal* signalType);
|
||||
|
||||
/**
|
||||
* @brief Requests to enter sleep mode, and later sets wake events if allowed to.
|
||||
* @param wakeEvents The wake events. Limited to "shell" (bit 1) for the PDN wake events part
|
||||
* and "shell opened", "shell closed" and "HOME button pressed" for the MCU interrupts part.
|
||||
*/
|
||||
Result APT_SleepSystem(const struct PtmWakeEvents *wakeEvents);
|
||||
|
||||
/**
|
||||
* @brief Notifies an application to wait.
|
||||
* @param appID ID of the application.
|
||||
*/
|
||||
Result APT_NotifyToWait(NS_APPID appID);
|
||||
|
||||
/**
|
||||
* @brief Calls an applet utility function.
|
||||
* @param id Utility function to call.
|
||||
* @param out Pointer to write output data to.
|
||||
* @param outSize Size of the output buffer.
|
||||
* @param in Pointer to the input data.
|
||||
* @param inSize Size of the input buffer.
|
||||
*/
|
||||
Result APT_AppletUtility(int id, void* out, size_t outSize, const void* in, size_t inSize);
|
||||
|
||||
/// Sleeps if shell is closed (?).
|
||||
Result APT_SleepIfShellClosed(void);
|
||||
|
||||
/**
|
||||
* @brief Locks a transition (?).
|
||||
* @param transition Transition ID.
|
||||
* @param flag Flag (?)
|
||||
*/
|
||||
Result APT_LockTransition(u32 transition, bool flag);
|
||||
|
||||
/**
|
||||
* @brief Tries to lock a transition (?).
|
||||
* @param transition Transition ID.
|
||||
* @param succeeded Pointer to output whether the lock was successfully applied.
|
||||
*/
|
||||
Result APT_TryLockTransition(u32 transition, bool* succeeded);
|
||||
|
||||
/**
|
||||
* @brief Unlocks a transition (?).
|
||||
* @param transition Transition ID.
|
||||
*/
|
||||
Result APT_UnlockTransition(u32 transition);
|
||||
|
||||
/**
|
||||
* @brief Glances at a receieved parameter without removing it from the queue.
|
||||
* @param appID AppID of the application.
|
||||
* @param buffer Buffer to receive to.
|
||||
* @param bufferSize Size of the buffer.
|
||||
* @param sender Pointer to output the sender's AppID to.
|
||||
* @param command Pointer to output the command ID to.
|
||||
* @param actualSize Pointer to output the actual received data size to.
|
||||
* @param parameter Pointer to output the parameter handle to.
|
||||
*/
|
||||
Result APT_GlanceParameter(NS_APPID appID, void* buffer, size_t bufferSize, NS_APPID* sender, APT_Command* command, size_t* actualSize, Handle* parameter);
|
||||
|
||||
/**
|
||||
* @brief Receives a parameter.
|
||||
* @param appID AppID of the application.
|
||||
* @param buffer Buffer to receive to.
|
||||
* @param bufferSize Size of the buffer.
|
||||
* @param sender Pointer to output the sender's AppID to.
|
||||
* @param command Pointer to output the command ID to.
|
||||
* @param actualSize Pointer to output the actual received data size to.
|
||||
* @param parameter Pointer to output the parameter handle to.
|
||||
*/
|
||||
Result APT_ReceiveParameter(NS_APPID appID, void* buffer, size_t bufferSize, NS_APPID* sender, APT_Command* command, size_t* actualSize, Handle* parameter);
|
||||
|
||||
/**
|
||||
* @brief Sends a parameter.
|
||||
* @param source AppID of the source application.
|
||||
* @param dest AppID of the destination application.
|
||||
* @param command Command to send.
|
||||
* @param buffer Buffer to send.
|
||||
* @param bufferSize Size of the buffer.
|
||||
* @param parameter Parameter handle to pass.
|
||||
*/
|
||||
Result APT_SendParameter(NS_APPID source, NS_APPID dest, APT_Command command, const void* buffer, u32 bufferSize, Handle parameter);
|
||||
|
||||
/**
|
||||
* @brief Cancels a parameter which matches the specified source and dest AppIDs.
|
||||
* @param source AppID of the source application (use APPID_NONE to disable the check).
|
||||
* @param dest AppID of the destination application (use APPID_NONE to disable the check).
|
||||
* @param success Pointer to output true if a parameter was cancelled, or false otherwise.
|
||||
*/
|
||||
Result APT_CancelParameter(NS_APPID source, NS_APPID dest, bool* success);
|
||||
|
||||
/**
|
||||
* @brief Sends capture buffer information.
|
||||
* @param captureBuf Capture buffer information to send.
|
||||
*/
|
||||
Result APT_SendCaptureBufferInfo(const aptCaptureBufInfo* captureBuf);
|
||||
|
||||
/**
|
||||
* @brief Replies to a sleep query.
|
||||
* @param appID ID of the application.
|
||||
* @param reply Query reply value.
|
||||
*/
|
||||
Result APT_ReplySleepQuery(NS_APPID appID, APT_QueryReply reply);
|
||||
|
||||
/**
|
||||
* @brief Replies that a sleep notification has been completed.
|
||||
* @param appID ID of the application.
|
||||
*/
|
||||
Result APT_ReplySleepNotificationComplete(NS_APPID appID);
|
||||
|
||||
/**
|
||||
* @brief Prepares to close the application.
|
||||
* @param cancelPreload Whether applet preloads should be cancelled.
|
||||
*/
|
||||
Result APT_PrepareToCloseApplication(bool cancelPreload);
|
||||
|
||||
/**
|
||||
* @brief Closes the application.
|
||||
* @param param Parameters to close with.
|
||||
* @param paramSize Size of param.
|
||||
* @param handle Handle to pass.
|
||||
*/
|
||||
Result APT_CloseApplication(const void* param, size_t paramSize, Handle handle);
|
||||
|
||||
/**
|
||||
* @brief Sets the application's CPU time limit.
|
||||
* @param percent CPU time limit percentage to set.
|
||||
*/
|
||||
Result APT_SetAppCpuTimeLimit(u32 percent);
|
||||
|
||||
/**
|
||||
* @brief Gets the application's CPU time limit.
|
||||
* @param percent Pointer to output the CPU time limit percentage to.
|
||||
*/
|
||||
Result APT_GetAppCpuTimeLimit(u32 *percent);
|
||||
|
||||
/**
|
||||
* @brief Checks whether the system is a New 3DS.
|
||||
* @param out Pointer to write the New 3DS flag to.
|
||||
*/
|
||||
Result APT_CheckNew3DS(bool* out);
|
||||
|
||||
/**
|
||||
* @brief Prepares for an applicaton jump.
|
||||
* @param flags Flags to use.
|
||||
* @param programID ID of the program to jump to.
|
||||
* @param mediatype Media type of the program to jump to.
|
||||
*/
|
||||
Result APT_PrepareToDoApplicationJump(u8 flags, u64 programID, u8 mediatype);
|
||||
|
||||
/**
|
||||
* @brief Performs an application jump.
|
||||
* @param param Parameter buffer.
|
||||
* @param paramSize Size of parameter buffer.
|
||||
* @param hmac HMAC buffer (should be 0x20 bytes long).
|
||||
*/
|
||||
Result APT_DoApplicationJump(const void* param, size_t paramSize, const void* hmac);
|
||||
|
||||
/**
|
||||
* @brief Prepares to start a library applet.
|
||||
* @param appID AppID of the applet to start.
|
||||
*/
|
||||
Result APT_PrepareToStartLibraryApplet(NS_APPID appID);
|
||||
|
||||
/**
|
||||
* @brief Starts a library applet.
|
||||
* @param appID AppID of the applet to launch.
|
||||
* @param param Buffer containing applet parameters.
|
||||
* @param paramsize Size of the buffer.
|
||||
* @param handle Handle to pass to the applet.
|
||||
*/
|
||||
Result APT_StartLibraryApplet(NS_APPID appID, const void* param, size_t paramSize, Handle handle);
|
||||
|
||||
/**
|
||||
* @brief Prepares to start a system applet.
|
||||
* @param appID AppID of the applet to start.
|
||||
*/
|
||||
Result APT_PrepareToStartSystemApplet(NS_APPID appID);
|
||||
|
||||
/**
|
||||
* @brief Starts a system applet.
|
||||
* @param appID AppID of the applet to launch.
|
||||
* @param param Buffer containing applet parameters.
|
||||
* @param paramSize Size of the parameter buffer.
|
||||
* @param handle Handle to pass to the applet.
|
||||
*/
|
||||
Result APT_StartSystemApplet(NS_APPID appID, const void* param, size_t paramSize, Handle handle);
|
||||
|
||||
/**
|
||||
* @brief Retrieves the shared system font.
|
||||
* @brief fontHandle Pointer to write the handle of the system font memory block to.
|
||||
* @brief mapAddr Pointer to write the mapping address of the system font memory block to.
|
||||
*/
|
||||
Result APT_GetSharedFont(Handle* fontHandle, u32* mapAddr);
|
||||
|
||||
/**
|
||||
* @brief Receives the deliver (launch) argument
|
||||
* @param param Parameter buffer.
|
||||
* @param paramSize Size of parameter buffer.
|
||||
* @param hmac HMAC buffer (should be 0x20 bytes long).
|
||||
* @param sender Pointer to output the sender's AppID to.
|
||||
* @param received Pointer to output whether an argument was received to.
|
||||
*/
|
||||
Result APT_ReceiveDeliverArg(void* param, size_t paramSize, void* hmac, u64* sender, bool* received);
|
||||
|
180
libctru/include/3ds/services/boss.h
Normal file
180
libctru/include/3ds/services/boss.h
Normal file
@ -0,0 +1,180 @@
|
||||
/**
|
||||
* @file boss.h
|
||||
* @brief BOSS service, see also: https://www.3dbrew.org/wiki/BOSS_Services
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/// BOSS context.
|
||||
typedef struct
|
||||
{
|
||||
u32 property[0x7];
|
||||
|
||||
char url[0x200];
|
||||
|
||||
u32 property_x8;
|
||||
u8 property_x9;
|
||||
|
||||
u8 property_xa[0x100];
|
||||
|
||||
u8 property_xb[0x200];
|
||||
|
||||
char property_xd[0x360];//Additonal optional HTTP request headers.
|
||||
|
||||
u32 property_xe;
|
||||
|
||||
u32 property_xf[0xc>>2];
|
||||
|
||||
u8 property_x10;
|
||||
u8 property_x11;
|
||||
u8 property_x12;
|
||||
u32 property_x13;
|
||||
u32 property_x14;
|
||||
|
||||
u8 property_x15[0x40];
|
||||
|
||||
u32 property_x16;
|
||||
|
||||
u32 property_x3b;
|
||||
|
||||
u8 property_x3e[0x200];
|
||||
} bossContext;
|
||||
|
||||
/// BOSS task status.
|
||||
typedef enum {
|
||||
BOSSTASKSTATUS_STARTED = 0x2,
|
||||
BOSSTASKSTATUS_ERROR = 0x7,
|
||||
} bossTaskStatus;
|
||||
|
||||
/// Type values for bossGetNsDataHeaderInfo().
|
||||
typedef enum {
|
||||
bossNsDataHeaderInfoType_ContentSize = 0x3 /// Size of the content.
|
||||
} bossNsDataHeaderInfoTypes;
|
||||
|
||||
/// Size of the output data for bossGetNsDataHeaderInfo().
|
||||
typedef enum {
|
||||
bossNsDataHeaderInfoTypeSize_ContentSize = 0x4 ///Type2
|
||||
} bossNsDataHeaderInfoTypeSizes;
|
||||
|
||||
/**
|
||||
* @brief Initializes BOSS.
|
||||
* @param programID programID to use, 0 for the current process. Only used when BOSSP is available without *hax payload.
|
||||
* @param force_user When true, just use bossU instead of trying to initialize with bossP first.
|
||||
*/
|
||||
Result bossInit(u64 programID, bool force_user);
|
||||
|
||||
/**
|
||||
* @brief Run the InitializeSession service cmd. This is mainly for changing the programID associated with the current BOSS session.
|
||||
* @param programID programID to use, 0 for the current process.
|
||||
*/
|
||||
Result bossReinit(u64 programID);
|
||||
|
||||
/// Exits BOSS.
|
||||
void bossExit(void);
|
||||
|
||||
/// Returns the BOSS session handle.
|
||||
Handle bossGetSessionHandle(void);
|
||||
|
||||
/**
|
||||
* @brief Set the content data storage location.
|
||||
* @param extdataID u64 extdataID, must have the high word set to the shared-extdata value when it's for NAND.
|
||||
* @param boss_size Probably the max size in the extdata which BOSS can use.
|
||||
* @param mediaType Roughly the same as FS mediatype.
|
||||
*/
|
||||
Result bossSetStorageInfo(u64 extdataID, u32 boss_size, u8 mediaType);
|
||||
|
||||
/**
|
||||
* @brief Unregister the content data storage location, which includes unregistering the BOSS-session programID with BOSS.
|
||||
*/
|
||||
Result bossUnregisterStorage(void);
|
||||
|
||||
/**
|
||||
* @brief Register a task.
|
||||
* @param taskID BOSS taskID.
|
||||
* @param unk0 Unknown, usually zero.
|
||||
* @param unk1 Unknown, usually zero.
|
||||
*/
|
||||
Result bossRegisterTask(const char *taskID, u8 unk0, u8 unk1);
|
||||
|
||||
/**
|
||||
* @brief Send a property.
|
||||
* @param PropertyID PropertyID
|
||||
* @param buf Input buffer data.
|
||||
* @param size Buffer size.
|
||||
*/
|
||||
Result bossSendProperty(u16 PropertyID, const void* buf, u32 size);
|
||||
|
||||
/**
|
||||
* @brief Deletes the content file for the specified NsDataId.
|
||||
* @param NsDataId NsDataId
|
||||
*/
|
||||
Result bossDeleteNsData(u32 NsDataId);
|
||||
|
||||
/**
|
||||
* @brief Gets header info for the specified NsDataId.
|
||||
* @param NsDataId NsDataId
|
||||
* @param type Type of data to load.
|
||||
* @param buffer Output buffer.
|
||||
* @param size Output buffer size.
|
||||
*/
|
||||
Result bossGetNsDataHeaderInfo(u32 NsDataId, u8 type, void* buffer, u32 size);
|
||||
|
||||
/**
|
||||
* @brief Reads data from the content for the specified NsDataId.
|
||||
* @param NsDataId NsDataId
|
||||
* @param offset Offset in the content.
|
||||
* @param buffer Output buffer.
|
||||
* @param size Output buffer size.
|
||||
* @param transfer_total Optional output actual read size, can be NULL.
|
||||
* @param unk_out Optional unknown output, can be NULL.
|
||||
*/
|
||||
Result bossReadNsData(u32 NsDataId, u64 offset, void* buffer, u32 size, u32 *transfer_total, u32 *unk_out);
|
||||
|
||||
/**
|
||||
* @brief Starts a task soon after running this command.
|
||||
* @param taskID BOSS taskID.
|
||||
*/
|
||||
Result bossStartTaskImmediate(const char *taskID);
|
||||
|
||||
/**
|
||||
* @brief Similar to bossStartTaskImmediate?
|
||||
* @param taskID BOSS taskID.
|
||||
*/
|
||||
Result bossStartBgImmediate(const char *taskID);
|
||||
|
||||
/**
|
||||
* @brief Deletes a task by using CancelTask and UnregisterTask internally.
|
||||
* @param taskID BOSS taskID.
|
||||
* @param unk Unknown, usually zero?
|
||||
*/
|
||||
Result bossDeleteTask(const char *taskID, u32 unk);
|
||||
|
||||
/**
|
||||
* @brief Returns task state.
|
||||
* @param taskID BOSS taskID.
|
||||
* @param inval Unknown, normally 0?
|
||||
* @param status Output status, see bossTaskStatus.
|
||||
* @param out1 Output field.
|
||||
* @param out2 Output field.
|
||||
*/
|
||||
Result bossGetTaskState(const char *taskID, s8 inval, u8 *status, u32 *out1, u8 *out2);
|
||||
|
||||
/**
|
||||
* @brief This loads the current state of PropertyID 0x0 for the specified task.
|
||||
* @param taskID BOSS taskID.
|
||||
*/
|
||||
Result bossGetTaskProperty0(const char *taskID, u8 *out);
|
||||
|
||||
/**
|
||||
* @brief Setup a BOSS context with the default config.
|
||||
* @param bossContext BOSS context.
|
||||
* @param seconds_interval Interval in seconds for running the task automatically.
|
||||
* @param url Task URL.
|
||||
*/
|
||||
void bossSetupContextDefault(bossContext *ctx, u32 seconds_interval, const char *url);
|
||||
|
||||
/**
|
||||
* @brief Sends the config stored in the context. Used before registering a task.
|
||||
* @param bossContext BOSS context.
|
||||
*/
|
||||
Result bossSendContextConfig(bossContext *ctx);
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user