mirror of
https://github.com/flyinghead/flycast.git
synced 2026-11-07 17:11:09 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
966ff3767d | ||
|
|
056a02357d | ||
|
|
6115a918b2 | ||
|
|
3ffb09ec72 | ||
|
|
de89d8cfed | ||
|
|
c7d6525c51 | ||
|
|
5ce1f92e5c | ||
|
|
464defe0d7 | ||
|
|
d323490d1f | ||
|
|
d8c15de030 | ||
|
|
b55054249f | ||
|
|
0aa8910742 | ||
|
|
43bb7c83f7 | ||
|
|
391da7023f | ||
|
|
960b8134c1 | ||
|
|
5a51749daa | ||
|
|
d2dc60ec00 | ||
|
|
33bcf4443f | ||
|
|
f63a82afc4 | ||
|
|
c052822fd4 | ||
|
|
2846b3002b | ||
|
|
19a240503d | ||
|
|
c9d3096e41 | ||
|
|
d6ae47d0f7 | ||
|
|
40a7c08d14 | ||
|
|
6f8a588794 | ||
|
|
156aafe95b | ||
|
|
1017d3eb95 | ||
|
|
3059b43121 | ||
|
|
93789e2a63 | ||
|
|
6639d6b167 | ||
|
|
daef33cea5 | ||
|
|
a7c89701fe | ||
|
|
9a119e7646 | ||
|
|
c8462e1f78 | ||
|
|
50944772b7 | ||
|
|
952a785bf0 | ||
|
|
f9eed1ed3f | ||
|
|
b7df183c7c | ||
|
|
13edf858e3 | ||
|
|
d45de9e8a9 | ||
|
|
81cbf45bdb | ||
|
|
d340b620c3 | ||
|
|
443d5a2ba6 | ||
|
|
894a38fb71 | ||
|
|
aea37b3bd8 | ||
|
|
bc51aefa9c | ||
|
|
67c4e62c51 | ||
|
|
44fa364f36 | ||
|
|
7029e1615a | ||
|
|
3469b7fca7 | ||
|
|
c146a92f83 | ||
|
|
d4fa3c441e | ||
|
|
47eeab9985 | ||
|
|
be8c559b2f | ||
|
|
51d25bb49b | ||
|
|
6d69598800 | ||
|
|
36684bf82c | ||
|
|
cdaaeb5b27 | ||
|
|
4220c0d64f | ||
|
|
e286f98f72 | ||
|
|
e714e94510 | ||
|
|
8715e5a5e9 | ||
|
|
1153238e2c | ||
|
|
617d82f5a2 | ||
|
|
471e0a7786 | ||
|
|
887e616f76 | ||
|
|
aa2fa1f611 | ||
|
|
57c88e07c4 | ||
|
|
593b3205bd | ||
|
|
ecce9157bd | ||
|
|
b2d96d77d7 | ||
|
|
e1537ddbda | ||
|
|
4c7e57ebd6 | ||
|
|
116dc0e1ed | ||
|
|
10d3ffdf09 | ||
|
|
cbd01fba38 | ||
|
|
88fd2641d9 | ||
|
|
70a69cf48d | ||
|
|
f8d5517b8e | ||
|
|
16b2f59a47 | ||
|
|
07d6ca6c84 | ||
|
|
c9c015976a | ||
|
|
2615cc13f1 | ||
|
|
599dc92d11 | ||
|
|
e26302ef03 | ||
|
|
fd3e74e224 | ||
|
|
5b5d7b01eb | ||
|
|
f6b01aba0c | ||
|
|
19bb4a6e5d | ||
|
|
bc70d9118d | ||
|
|
393c3dbfd9 | ||
|
|
8fd6fefda7 | ||
|
|
a620a432c9 | ||
|
|
9e37d1e726 | ||
|
|
c1b087df83 | ||
|
|
2add951f70 | ||
|
|
070ac717d3 | ||
|
|
cfb7ff3054 | ||
|
|
e03c37b013 | ||
|
|
0b0904cdc5 | ||
|
|
195f401044 | ||
|
|
552e5b7d7a | ||
|
|
2a48049216 | ||
|
|
c001240797 | ||
|
|
e7d0a5f2f9 | ||
|
|
032cc17659 | ||
|
|
c0c6f206bf | ||
|
|
6aa59c54a5 | ||
|
|
9c964ac955 | ||
|
|
5734556440 | ||
|
|
e76b76dcc4 | ||
|
|
cab19ad54b | ||
|
|
a7702c622a | ||
|
|
9f9b29b833 | ||
|
|
06529b63f7 | ||
|
|
0d36154618 | ||
|
|
c7b6f22e10 | ||
|
|
d069b45bff | ||
|
|
4a0ace5de2 | ||
|
|
57c2dcd961 | ||
|
|
790f5b1ad2 | ||
|
|
54ac9c6361 | ||
|
|
449b871e0c | ||
|
|
e057370e97 | ||
|
|
c938f7b0df | ||
|
|
99dc278ad2 | ||
|
|
bccdc6600a | ||
|
|
ba1a68a69f | ||
|
|
363c2c4c3f | ||
|
|
fe429ec01e | ||
|
|
192838b9c1 | ||
|
|
2a19ccf945 | ||
|
|
00954f1b60 | ||
|
|
bf4346c849 | ||
|
|
32502e7459 | ||
|
|
99031e23d3 | ||
|
|
f4f087a6ea | ||
|
|
0433fd824c | ||
|
|
9137ff998f | ||
|
|
7cc77b10ed | ||
|
|
07f208d2a2 | ||
|
|
05cd7ee8d3 | ||
|
|
d8e61520af | ||
|
|
e9beea484d | ||
|
|
4aecdbbb25 | ||
|
|
d7c28a4805 | ||
|
|
939e2bc68f | ||
|
|
ce4a3a7147 | ||
|
|
5fde889d7c | ||
|
|
fd2a87fca2 | ||
|
|
153dbb0c56 | ||
|
|
e53433e6f5 | ||
|
|
db7895cea5 | ||
|
|
f3a774ab4e | ||
|
|
bd25c14cfd | ||
|
|
035ea0b0c0 | ||
|
|
d6593b9c6e | ||
|
|
105ab95efa | ||
|
|
2c711e46fe | ||
|
|
923be3899d | ||
|
|
cb518b5481 | ||
|
|
a18e3701c6 | ||
|
|
2ed4b4a984 | ||
|
|
f11a5981fe | ||
|
|
ea83b08f89 | ||
|
|
b785944560 | ||
|
|
8f3124d14e | ||
|
|
14f3507b86 | ||
|
|
4efacd7d71 | ||
|
|
a9d5b77053 | ||
|
|
bc28c7ccb3 | ||
|
|
f14c29fd04 | ||
|
|
3303ecbbd1 | ||
|
|
c4c4c2fde0 | ||
|
|
78a874d20e | ||
|
|
ef321d81a4 | ||
|
|
df83ca436c | ||
|
|
665ef86cf0 | ||
|
|
b9601d26e3 | ||
|
|
038df0d923 | ||
|
|
73cbd7a183 | ||
|
|
ab25cc73a9 | ||
|
|
a0014bc810 | ||
|
|
6de5879cb4 | ||
|
|
32ecb141df | ||
|
|
4cd90d8ebb | ||
|
|
46eab502e4 | ||
|
|
535fbe29f8 | ||
|
|
41723a831f | ||
|
|
abe1d4fd27 | ||
|
|
dda04e63fa | ||
|
|
e60f30b357 | ||
|
|
f0f27558af | ||
|
|
0f6a92caad | ||
|
|
9a60cd7ded | ||
|
|
926877397c | ||
|
|
b92277ac58 | ||
|
|
9a7bf75e4e | ||
|
|
1253e1199d | ||
|
|
51508dcdc6 | ||
|
|
f6b3577de5 | ||
|
|
a4ec706c79 | ||
|
|
cb890c7b6f | ||
|
|
dbfead6a15 | ||
|
|
fd3f207e45 | ||
|
|
594b403997 | ||
|
|
bafe07de85 | ||
|
|
3e047a6e03 | ||
|
|
29c0dca0ce | ||
|
|
5cfd3f0ba3 | ||
|
|
923dcf10a7 | ||
|
|
7b71bd319c | ||
|
|
51089c5e0a | ||
|
|
24944e00a7 | ||
|
|
66faf0d330 | ||
|
|
c0de126b2b | ||
|
|
c1f0a5a15f | ||
|
|
f640b32cc9 | ||
|
|
93e47dd410 | ||
|
|
8fb3def2d5 | ||
|
|
98a0f2b821 | ||
|
|
4fafa91506 | ||
|
|
09a1fea40f | ||
|
|
e55d70c0e6 | ||
|
|
ca45ff3834 | ||
|
|
35c71ebcfd | ||
|
|
33edcca348 | ||
|
|
dac5b991e0 | ||
|
|
8ba5e05421 | ||
|
|
35b7be3905 | ||
|
|
b7d923e02b | ||
|
|
eaf2c0064c | ||
|
|
a65cd9e5f9 | ||
|
|
e94b26f1df | ||
|
|
e96b38ff5c | ||
|
|
e894d4df5c | ||
|
|
c58ae4daac | ||
|
|
cb9af7d742 | ||
|
|
2a364dee67 | ||
|
|
56107b3667 | ||
|
|
31aab32d95 | ||
|
|
0b66409ed2 | ||
|
|
8ae288d2ca | ||
|
|
4419ff310a | ||
|
|
2f524923da | ||
|
|
07d761a880 | ||
|
|
f6f6637973 | ||
|
|
2cd3ffb33f | ||
|
|
abd9219347 | ||
|
|
417a42ae10 | ||
|
|
0e12153c45 | ||
|
|
cb33387ed6 | ||
|
|
38d4689b63 | ||
|
|
23d1db9c75 | ||
|
|
4e079b5d0b | ||
|
|
3fcbdd3fc5 | ||
|
|
78b44919c5 | ||
|
|
13a8d49c90 | ||
|
|
7308f9a704 | ||
|
|
18f9b84af6 | ||
|
|
56517b027a | ||
|
|
d4a02e3c2b | ||
|
|
33131e1395 | ||
|
|
73ac46f421 | ||
|
|
7fc70ee1f4 | ||
|
|
d9b5f27311 | ||
|
|
252838d896 | ||
|
|
cb91ad3ae0 | ||
|
|
60f3d718ac | ||
|
|
e8e382372a | ||
|
|
205c365b1b | ||
|
|
09857008bd | ||
|
|
5eddc26850 | ||
|
|
496429d6f4 | ||
|
|
a915f185f8 | ||
|
|
0f6e1752e3 | ||
|
|
e57ccde532 | ||
|
|
f75a16f40c | ||
|
|
a869e183db | ||
|
|
c60edb0090 | ||
|
|
84d82f360b | ||
|
|
b002bdff39 | ||
|
|
5ffcdb5f1e | ||
|
|
79bbd86c2f | ||
|
|
39a212140a | ||
|
|
dddd712f08 | ||
|
|
a7dbbbe578 | ||
|
|
2445739c0e | ||
|
|
403f1f635b | ||
|
|
879372cb79 | ||
|
|
6b05c0ab01 | ||
|
|
289f264371 | ||
|
|
869ddb643d | ||
|
|
c63f1a9997 | ||
|
|
0fc0dc5101 | ||
|
|
213bc70e2d | ||
|
|
c839bc89eb | ||
|
|
84f2871650 | ||
|
|
e1b4d4d703 | ||
|
|
b564b0bf91 | ||
|
|
7e1dcf9003 | ||
|
|
0f4c903fed | ||
|
|
0ac483acfc | ||
|
|
f4835a89d3 | ||
|
|
139f248572 | ||
|
|
b23d37f76f | ||
|
|
56358be542 | ||
|
|
1377e61d03 | ||
|
|
ce694ba8b5 | ||
|
|
8eae6b97fc | ||
|
|
d29645cc49 | ||
|
|
f870ccc23c | ||
|
|
3aa2f922e7 | ||
|
|
129fff1c2a | ||
|
|
10b13dfe9c | ||
|
|
d506cc40a2 | ||
|
|
358a54152b | ||
|
|
06e2c455e8 | ||
|
|
a1838eee30 | ||
|
|
56b082def7 | ||
|
|
92a10ba0f0 | ||
|
|
c637ae8281 | ||
|
|
40953b17c4 | ||
|
|
a473154250 | ||
|
|
13f3c3e228 | ||
|
|
817cc87c8c | ||
|
|
ab09efa762 | ||
|
|
7061c043d9 | ||
|
|
92a19e9250 | ||
|
|
4f5fd31d81 | ||
|
|
1b565f9879 | ||
|
|
d2b475ae41 | ||
|
|
9c61006941 | ||
|
|
4db26bc092 | ||
|
|
8c0f543bc8 | ||
|
|
8e3a48eb6f | ||
|
|
7a22318b0f | ||
|
|
a0bf24f7cc | ||
|
|
3c6eaa4d34 | ||
|
|
3bf817aea1 | ||
|
|
a3ebe02f85 | ||
|
|
4eda9ebffc | ||
|
|
278f26aadd | ||
|
|
17b82ab5d3 | ||
|
|
30e66d1c17 | ||
|
|
2089015221 | ||
|
|
e19a62aa07 | ||
|
|
42d003597e | ||
|
|
f9da57d87f | ||
|
|
daf8230cca | ||
|
|
f02265b662 | ||
|
|
5eb893a995 | ||
|
|
dfd517706a | ||
|
|
b47f4f56ef | ||
|
|
a870fb7f6c | ||
|
|
7cd308fcae | ||
|
|
6e6f75386b | ||
|
|
aad4921e09 | ||
|
|
8b8113b482 | ||
|
|
98acd1178d | ||
|
|
0070f9abad | ||
|
|
dca048981f | ||
|
|
74b98d85ed | ||
|
|
67a7637b9f | ||
|
|
2511a19d2d | ||
|
|
f04ddad94f | ||
|
|
b4e5af6346 | ||
|
|
f679fd9ba9 | ||
|
|
b6930a2a9e | ||
|
|
4db7137dbf | ||
|
|
bee534922b | ||
|
|
d6fe46649c | ||
|
|
236539c881 | ||
|
|
2644c2ef47 | ||
|
|
f590766421 | ||
|
|
fa1c62d11a | ||
|
|
ffc0a42c18 | ||
|
|
bc3c1ab628 | ||
|
|
6c249ee4d2 | ||
|
|
3330f01267 | ||
|
|
bd946bfbea | ||
|
|
bb92e9f7a4 | ||
|
|
63686eeee1 | ||
|
|
c0a286532a | ||
|
|
ce0354f294 | ||
|
|
231a1b624f | ||
|
|
9b8fd39d12 | ||
|
|
90c4e42c11 | ||
|
|
ee806bc035 | ||
|
|
d76611730e | ||
|
|
bdd677d66a | ||
|
|
2299c9fade | ||
|
|
885714e883 | ||
|
|
f95c7212bf | ||
|
|
bb0da9488f | ||
|
|
1aeacb0297 | ||
|
|
b92b7a3ece | ||
|
|
0a1fe0135f | ||
|
|
4391058563 | ||
|
|
ea9bdd03e4 | ||
|
|
ed99c96232 | ||
|
|
755e17dc97 | ||
|
|
76af42ae6e | ||
|
|
e94babe57e | ||
|
|
416e4c5366 | ||
|
|
6b9840268f | ||
|
|
415d8c2ea3 | ||
|
|
3f456c6738 | ||
|
|
59480ea5a6 | ||
|
|
920666bc70 | ||
|
|
eebcb322cf | ||
|
|
04b0489ff3 | ||
|
|
dd5f44ff91 | ||
|
|
a7b89ba06a | ||
|
|
e5344d37d0 | ||
|
|
c07f862ef2 | ||
|
|
8b0add47a2 | ||
|
|
fe9ce46ab1 | ||
|
|
01c5c98396 | ||
|
|
d00f07acb8 | ||
|
|
83bfa9158d | ||
|
|
ac2637286b | ||
|
|
541544292a | ||
|
|
97bd3fc082 | ||
|
|
71ce2a2415 | ||
|
|
4b0d377e66 | ||
|
|
ae2bc8182f | ||
|
|
d9ec14e048 | ||
|
|
c0f0a758df | ||
|
|
06270e66c8 | ||
|
|
75fe707de3 | ||
|
|
1a5a2f64d4 | ||
|
|
220fd51b27 | ||
|
|
29cdc77817 | ||
|
|
483c59f2e4 | ||
|
|
1fdab613fd | ||
|
|
539b9e7746 | ||
|
|
045f693eef | ||
|
|
3192f84576 | ||
|
|
27038d4cf9 | ||
|
|
4acb670b88 | ||
|
|
79b9b49218 | ||
|
|
5f161df06b | ||
|
|
fc3b9046d8 | ||
|
|
754d2a53a0 | ||
|
|
e913bae9e3 | ||
|
|
22d228c1b0 | ||
|
|
d3a3cab425 | ||
|
|
1fe7352ed0 | ||
|
|
9d1a5cf0d3 | ||
|
|
c8a45d95a7 | ||
|
|
92a1c1891b | ||
|
|
858174791f | ||
|
|
fb4e653269 | ||
|
|
210100a108 | ||
|
|
edd1487378 | ||
|
|
68f4ce1ec5 | ||
|
|
c3c355a8c5 | ||
|
|
70d3e221a9 | ||
|
|
b556617e1d | ||
|
|
e327172fd0 | ||
|
|
c5f82483e6 | ||
|
|
a418b05272 | ||
|
|
5c3f66fe05 | ||
|
|
81ce3f7d10 | ||
|
|
64cfba735e | ||
|
|
8828b4fe52 | ||
|
|
87fdd203b5 | ||
|
|
187674ddac | ||
|
|
f94a08f12f | ||
|
|
252ad711f1 | ||
|
|
9d6bfd4786 | ||
|
|
d3690b12c6 | ||
|
|
32e08ca165 | ||
|
|
bc4f8fbe60 | ||
|
|
fd3deeb318 | ||
|
|
7108358ebd | ||
|
|
98daea0e97 | ||
|
|
48acb03b81 | ||
|
|
08ac485eac | ||
|
|
c033a81eca | ||
|
|
5df9127add | ||
|
|
b9e9cc534c | ||
|
|
79be464326 | ||
|
|
f67aad0b2d | ||
|
|
55b36fe719 | ||
|
|
7cce77cccd | ||
|
|
170f794c3a | ||
|
|
ae4bd79ca1 | ||
|
|
d76982bbeb | ||
|
|
fb4229c4ae | ||
|
|
caec338d25 | ||
|
|
b94200233d | ||
|
|
eb3ebe24e8 | ||
|
|
4514a4bfcc | ||
|
|
5e4e48fffe | ||
|
|
47a33f97f9 | ||
|
|
b36ef9da1e | ||
|
|
068861d0cc | ||
|
|
f2f8f3ccd2 | ||
|
|
2d7a1ce71a | ||
|
|
74d72eb257 | ||
|
|
9512ee657a | ||
|
|
78f80eb7dc | ||
|
|
fa525b4488 | ||
|
|
ee3e83e09c | ||
|
|
ea4354ba2e | ||
|
|
5c5c872afc | ||
|
|
9f2ffd102c | ||
|
|
34f8941868 | ||
|
|
07b217d9f8 | ||
|
|
cb83d319b9 | ||
|
|
23daa3efdf | ||
|
|
3a1ffceb58 | ||
|
|
f3431bd95d | ||
|
|
01c7250be2 | ||
|
|
e6bc36e110 | ||
|
|
afc1f5f4e1 | ||
|
|
4a2ad8b145 | ||
|
|
17ab0aba26 | ||
|
|
cc1b45b7cc | ||
|
|
4d990947de | ||
|
|
5542d6db21 | ||
|
|
8ca89ead0e | ||
|
|
ebf5f24487 | ||
|
|
90269d5204 | ||
|
|
e4332f6275 | ||
|
|
cd7168772d | ||
|
|
77ded80450 | ||
|
|
fbc69b6ae1 | ||
|
|
ea7dd699b9 | ||
|
|
018a852995 | ||
|
|
8a28ddbfe6 | ||
|
|
f186046c98 | ||
|
|
5644e834fa | ||
|
|
0b1f69bfd2 | ||
|
|
4eb5cd928e | ||
|
|
b8d47fe0a8 | ||
|
|
abcd9d77d4 | ||
|
|
095e5ede81 | ||
|
|
52754cbbbb | ||
|
|
ea9d048bc9 | ||
|
|
942224c685 | ||
|
|
670a25b039 | ||
|
|
cab02c86bc | ||
|
|
b4a67460e0 | ||
|
|
b56750df30 | ||
|
|
aa5fd64777 | ||
|
|
5a13b4df28 | ||
|
|
67bba95dd1 | ||
|
|
cd6152b193 | ||
|
|
67c070c20f | ||
|
|
2355bb8bb5 | ||
|
|
c4d24254db | ||
|
|
27b6bafd0f | ||
|
|
9cbdcc6260 | ||
|
|
192bbb715e | ||
|
|
014da3a225 | ||
|
|
803f4cd298 | ||
|
|
885a0508c0 | ||
|
|
a1472fb190 | ||
|
|
b86df7217c | ||
|
|
26815d042a | ||
|
|
026f21eddf | ||
|
|
30501aebb1 | ||
|
|
4014b1b574 | ||
|
|
8d54382b10 | ||
|
|
47dd8241b6 | ||
|
|
195da2adcc | ||
|
|
2b430eec6f | ||
|
|
d51e36998b | ||
|
|
a970a1263c | ||
|
|
cf9ccea70b | ||
|
|
f885cbb4ea | ||
|
|
97dfabc416 | ||
|
|
8d2b0749a0 | ||
|
|
a3acf4a8cc | ||
|
|
e505ab6019 | ||
|
|
9b24984b07 | ||
|
|
7ce08ea860 | ||
|
|
a156edbd73 | ||
|
|
9dae5827cc | ||
|
|
5da799244f | ||
|
|
bf79183bd6 | ||
|
|
afcb3b7ad8 | ||
|
|
5bfbcb210c | ||
|
|
4f65d45e55 | ||
|
|
3f8ecfedbb | ||
|
|
d8137a967c | ||
|
|
ffec935e2f | ||
|
|
253301ba4f | ||
|
|
a21b79cfbe | ||
|
|
3f4c24d350 | ||
|
|
645f413523 | ||
|
|
08478aa757 | ||
|
|
4aef8667b7 | ||
|
|
9d08da1fc9 | ||
|
|
4408aa7dbe | ||
|
|
d2e8c9465b | ||
|
|
04df0da7cb | ||
|
|
5eeddecb40 | ||
|
|
71aea45811 | ||
|
|
cf690fbb61 | ||
|
|
85b286ec47 | ||
|
|
07d0cf6839 | ||
|
|
5e43b603ac | ||
|
|
69d2cfd56d | ||
|
|
0f90293252 | ||
|
|
0d166e1403 | ||
|
|
b5879e6e1d | ||
|
|
5b169b7f9d | ||
|
|
099a758c94 | ||
|
|
638e5d233a | ||
|
|
a23362cee0 | ||
|
|
040db856f8 | ||
|
|
8d0654c323 | ||
|
|
cacfdbad90 | ||
|
|
811bf6f449 | ||
|
|
43f8f3e4ad | ||
|
|
a045c52146 | ||
|
|
98531e07ea | ||
|
|
5020a267af | ||
|
|
debe21de7b | ||
|
|
084066bde7 | ||
|
|
46d7dfc750 | ||
|
|
37c17e4300 | ||
|
|
3a21f545d8 | ||
|
|
f35167a0de | ||
|
|
0b6c09da02 | ||
|
|
d9c08bd081 | ||
|
|
927db7f189 | ||
|
|
badf36899e | ||
|
|
d3aed076a6 | ||
|
|
962b0bb65c | ||
|
|
6e940e4d08 | ||
|
|
90e9f70a1a | ||
|
|
bfdab4db20 | ||
|
|
f0e4574132 | ||
|
|
c461624a67 | ||
|
|
e6060aff6b | ||
|
|
d1e6ee9cd7 | ||
|
|
6480a6e4e5 | ||
|
|
6cfbdf6586 | ||
|
|
6b2063b06f | ||
|
|
301a7c5dcd | ||
|
|
e70a0dcf3d | ||
|
|
d1ab3461a6 | ||
|
|
b81a6762bc | ||
|
|
5875eda4d0 | ||
|
|
04c418d02a | ||
|
|
02a002d55b | ||
|
|
0305904873 | ||
|
|
ee84567c17 | ||
|
|
528235ce9d | ||
|
|
27ea6ca092 | ||
|
|
cb94354099 | ||
|
|
53dab29ddb | ||
|
|
b1479e6e34 | ||
|
|
ea3262f7b0 | ||
|
|
143073b61d | ||
|
|
c472d60f80 | ||
|
|
0c01075ba8 | ||
|
|
1149d499a8 | ||
|
|
85a941d6c6 | ||
|
|
0a27b63584 | ||
|
|
6f5f91245b | ||
|
|
234955ac01 | ||
|
|
99d5266aa0 | ||
|
|
a5967a283f | ||
|
|
21a4935ec4 | ||
|
|
610e3cf968 | ||
|
|
45c9d6185b | ||
|
|
e18a4afcbb | ||
|
|
499f86b065 | ||
|
|
80cf4406a7 | ||
|
|
cc4e3875f3 | ||
|
|
1c4871acb3 | ||
|
|
3b683648fa | ||
|
|
3923f10277 | ||
|
|
1a681746b5 | ||
|
|
5703ef26cf | ||
|
|
5096d50d37 | ||
|
|
f7e227a4aa | ||
|
|
bbff377ceb | ||
|
|
f8372c51a7 | ||
|
|
31debefbe1 | ||
|
|
c7d214e55a | ||
|
|
e3e2c3a0d2 | ||
|
|
f96ce85365 | ||
|
|
aa79196d38 | ||
|
|
2b14c3e605 | ||
|
|
41ba110ef4 | ||
|
|
ad42a32260 | ||
|
|
cc408f9688 | ||
|
|
520e96a039 | ||
|
|
db9fbbaebf | ||
|
|
88384ad7d1 | ||
|
|
464b459073 | ||
|
|
aea228c3df | ||
|
|
8cdd171ab7 | ||
|
|
9473c235f2 | ||
|
|
b443467770 | ||
|
|
a6bf9dd39c | ||
|
|
8fdcea2e20 | ||
|
|
31bd943d67 | ||
|
|
ba78a3aa5b | ||
|
|
1948c66c11 | ||
|
|
3cf7cf0a7f | ||
|
|
a593cddf52 | ||
|
|
cecf16e65e | ||
|
|
458b233e16 | ||
|
|
cca7ed6bf7 | ||
|
|
f63cf7406a | ||
|
|
e21d666328 | ||
|
|
ab3f5dbc4c | ||
|
|
528f15f117 | ||
|
|
7c72aa8a80 | ||
|
|
2420c05930 | ||
|
|
3a312f3814 | ||
|
|
bac67bd91a | ||
|
|
36e67203a4 | ||
|
|
a52d1c97ec | ||
|
|
9d3125c546 | ||
|
|
86a6d7a4f5 | ||
|
|
0f214b1441 | ||
|
|
a0b50cd41d | ||
|
|
1d1754dc98 | ||
|
|
b8464ef6c5 | ||
|
|
692ca52182 | ||
|
|
b4ecaecd45 | ||
|
|
9954768636 | ||
|
|
cbffc5cade | ||
|
|
4bbf5c562e | ||
|
|
329e5ed467 | ||
|
|
19a160695c | ||
|
|
1e195b7237 | ||
|
|
2b37a5dc08 | ||
|
|
8aadf5b097 | ||
|
|
13428ba696 | ||
|
|
52f2ca7ff6 | ||
|
|
174ce8786b | ||
|
|
fc118f295d | ||
|
|
18cfe2f92f | ||
|
|
0d4a7dbac9 | ||
|
|
a370851494 | ||
|
|
7b49cc73ee | ||
|
|
a8c5af8425 | ||
|
|
3441a9ccf0 | ||
|
|
659d21680b | ||
|
|
2da833883b | ||
|
|
c301bf0827 | ||
|
|
1c4303b76d | ||
|
|
170a6ac36e | ||
|
|
92fa4c041d | ||
|
|
f34a9f6eac | ||
|
|
9fb69af355 | ||
|
|
59606d8935 | ||
|
|
bd7f5ec4c1 | ||
|
|
d082993a7a | ||
|
|
640d4162b6 | ||
|
|
66eb08f2d1 | ||
|
|
93fbd67a85 | ||
|
|
cf031717dd | ||
|
|
075ec1cf98 | ||
|
|
8f3b6a2371 | ||
|
|
ac24d9be5b | ||
|
|
a0e800f102 | ||
|
|
7e4572a86a | ||
|
|
4f0d3a958d | ||
|
|
06c5ba7f0e | ||
|
|
673fb26d6e | ||
|
|
5fa98da17e | ||
|
|
9b2f33f7bd | ||
|
|
2b70c73f80 | ||
|
|
1aec64cbae | ||
|
|
611946559c | ||
|
|
2997c6396f | ||
|
|
859d5df056 | ||
|
|
8a1902e5a8 | ||
|
|
285655f52d | ||
|
|
fceb170a2a | ||
|
|
4376e89149 | ||
|
|
cbd1d3134e | ||
|
|
fc479dbcc0 | ||
|
|
ae47ac19b8 | ||
|
|
84f6bd3fef | ||
|
|
d3b2da8e3b | ||
|
|
493ccc27d1 | ||
|
|
b37e6dc28d | ||
|
|
8cd6a94e26 | ||
|
|
13df32ba3f | ||
|
|
262a39cafb | ||
|
|
480f2e31b0 | ||
|
|
d0bb0aea97 | ||
|
|
bf3f927a99 | ||
|
|
19818e717f | ||
|
|
b6491a3842 | ||
|
|
c04c696ba6 | ||
|
|
17474bf005 | ||
|
|
756ec0e672 | ||
|
|
3dfdb60139 | ||
|
|
5a409dbe2c | ||
|
|
9ef37d9776 | ||
|
|
ba0a357d48 | ||
|
|
659ffa4406 | ||
|
|
12bba31270 | ||
|
|
dd66e44871 | ||
|
|
c5c87522ca | ||
|
|
5ef80f0a17 | ||
|
|
7372df3aff | ||
|
|
cf514b0d6b | ||
|
|
b232a10167 | ||
|
|
2a465d2f03 | ||
|
|
802f70fedd | ||
|
|
5acfa7d3d6 | ||
|
|
85188bf137 | ||
|
|
bfc44f2b4e | ||
|
|
96aaa8b14a | ||
|
|
53ed006a54 | ||
|
|
171c41df12 | ||
|
|
4b53edb3bd | ||
|
|
62085539a7 | ||
|
|
1c8e558e25 | ||
|
|
568145c247 | ||
|
|
5703bc7df2 | ||
|
|
95a00a165a | ||
|
|
599bc8a823 | ||
|
|
9578841480 | ||
|
|
5387a6b534 | ||
|
|
bf09e96e04 | ||
|
|
b5d8cecd91 | ||
|
|
6d913f42c8 | ||
|
|
1e0a875fa3 | ||
|
|
4d77ce5a66 | ||
|
|
f3a6fb7d8b | ||
|
|
b6f73d96ca | ||
|
|
13f3c8281f | ||
|
|
0107435a73 | ||
|
|
ce674a872a | ||
|
|
51758b965e | ||
|
|
7fec511463 | ||
|
|
1dd006d846 | ||
|
|
2800927fa1 | ||
|
|
f133e3cccb | ||
|
|
b0a520fe18 | ||
|
|
3f30dd01ad | ||
|
|
0c081a9597 | ||
|
|
7176460de3 | ||
|
|
733a1fa73d | ||
|
|
e3809ba058 | ||
|
|
4d3de39c64 | ||
|
|
1765e50703 | ||
|
|
f9feaa313b | ||
|
|
9781d8971a | ||
|
|
a0a9b5bbc5 | ||
|
|
c684faf423 | ||
|
|
cdca559d99 | ||
|
|
d76dff8594 | ||
|
|
223504a206 | ||
|
|
1ab4eb00c0 | ||
|
|
32e3e7d9c5 | ||
|
|
98123b9215 | ||
|
|
9069a49145 | ||
|
|
d417237e64 | ||
|
|
648f33473f | ||
|
|
446619ce85 | ||
|
|
f5fa1f6210 | ||
|
|
976fb99aa3 | ||
|
|
a0529d1cfc | ||
|
|
8001af9743 | ||
|
|
e48b72a859 | ||
|
|
71ba018782 | ||
|
|
59ff44132b | ||
|
|
8a0323ec08 | ||
|
|
4c7df6c7f4 | ||
|
|
676cd3104b | ||
|
|
a40210c55c | ||
|
|
034f90c1e0 | ||
|
|
64223927b8 | ||
|
|
e2c03255bb | ||
|
|
63495d3a6a | ||
|
|
88466ec352 | ||
|
|
1995eb935b | ||
|
|
f6532ca27a | ||
|
|
75dd5305c4 | ||
|
|
76cf989455 | ||
|
|
5b8e932509 | ||
|
|
993b705d8b | ||
|
|
19204882c4 | ||
|
|
605dc59f8d | ||
|
|
2332884d8b | ||
|
|
94f3d80a75 | ||
|
|
0b0e64304e | ||
|
|
5a1a766bd4 | ||
|
|
c15f446ffc | ||
|
|
c88cdde9ec | ||
|
|
40dbf53792 | ||
|
|
0cbf6f6601 | ||
|
|
c8fc873cf9 | ||
|
|
b935bef906 | ||
|
|
c1f0dd81d2 | ||
|
|
5722dc90f0 | ||
|
|
e3c260f4ca | ||
|
|
d1e48c657e | ||
|
|
decf70c87c | ||
|
|
4de9076b49 | ||
|
|
922df88cdd | ||
|
|
f25aeee756 | ||
|
|
2b36953fdc | ||
|
|
1dcf302665 | ||
|
|
1fd95c2886 | ||
|
|
93e1d7fcee | ||
|
|
b2b860bb8e | ||
|
|
0bd88fc9d9 | ||
|
|
20f9450218 | ||
|
|
401c402afc | ||
|
|
77a105d888 | ||
|
|
257c6b729f | ||
|
|
c5c941e928 | ||
|
|
092006fbbe | ||
|
|
6add19fb04 | ||
|
|
02d4b821d7 | ||
|
|
3d00ac338b | ||
|
|
387b9778f3 | ||
|
|
582876b99e | ||
|
|
3b3391c0d1 | ||
|
|
df61b1046a | ||
|
|
8426bcad27 | ||
|
|
d22fa54f7b | ||
|
|
2d56dddf7a | ||
|
|
7da0549b8c | ||
|
|
b821ece052 | ||
|
|
b240da41e0 | ||
|
|
d85baba1d3 | ||
|
|
8a44b909a4 | ||
|
|
5362264b18 | ||
|
|
1858cf3b33 | ||
|
|
1f876cde39 | ||
|
|
7288c7b541 | ||
|
|
2b8f5a7b9d | ||
|
|
c2e1425209 | ||
|
|
c9c1218234 | ||
|
|
11d776aea1 | ||
|
|
1386744fe0 | ||
|
|
da0d012328 | ||
|
|
f88abf9987 | ||
|
|
4a4fa7792f | ||
|
|
73adbc660b | ||
|
|
aa97a6d64f | ||
|
|
e0d87eb093 | ||
|
|
85b8c599c4 | ||
|
|
72136c2bfc | ||
|
|
71e9420929 | ||
|
|
7457db8bba | ||
|
|
69125b490e | ||
|
|
3c94cd3194 | ||
|
|
a6ac753c64 | ||
|
|
55600c40a9 | ||
|
|
9070c246d4 | ||
|
|
75ff5409f4 | ||
|
|
642fad9a6e | ||
|
|
5ae7ac3eca | ||
|
|
885862a45e | ||
|
|
9b751fced8 | ||
|
|
19ccc6a38d | ||
|
|
ad8b41adb0 | ||
|
|
807b8dea91 | ||
|
|
8e8935b9c4 | ||
|
|
76bf574668 | ||
|
|
9d17fc15a3 | ||
|
|
1cadd4e923 | ||
|
|
ab791d1b9c | ||
|
|
4f206d2773 | ||
|
|
7f9d9b81aa | ||
|
|
c77c3ab015 | ||
|
|
8acd81cc43 | ||
|
|
c0e52b9a1a | ||
|
|
0840da1bd5 | ||
|
|
852df89f93 | ||
|
|
b5eb8694f6 | ||
|
|
f4986008fe | ||
|
|
d6644c4935 | ||
|
|
19112aecb2 | ||
|
|
5bb8c86903 | ||
|
|
a659b57e63 | ||
|
|
44e96c544b | ||
|
|
0a5b8891a8 | ||
|
|
6a5db32d5d | ||
|
|
b0f3e065be | ||
|
|
b5b0875203 | ||
|
|
9a557978c4 | ||
|
|
fe895211c1 | ||
|
|
907131b7f5 | ||
|
|
76508146ae | ||
|
|
7f28b767e4 | ||
|
|
5f5a748031 | ||
|
|
867b519a2b | ||
|
|
74852520dc | ||
|
|
faec4d8e50 | ||
|
|
d2aca1d621 | ||
|
|
7bcd8c819a | ||
|
|
7209a61583 | ||
|
|
1523fafce0 | ||
|
|
3915c55251 | ||
|
|
5259aa20e6 | ||
|
|
11ecb473b6 | ||
|
|
7982fdac1c | ||
|
|
54d92a11e8 | ||
|
|
5eb302898f | ||
|
|
5b3a414987 | ||
|
|
05961ac883 | ||
|
|
afd07c25ba | ||
|
|
7ab92d88b1 | ||
|
|
3780299803 | ||
|
|
d78bb9ed3f | ||
|
|
b5f1552ed8 | ||
|
|
917cc7f27c | ||
|
|
2327e73ee7 | ||
|
|
397ddef68c | ||
|
|
3ec7f293ee | ||
|
|
26c8e8dab8 | ||
|
|
fdcea88519 | ||
|
|
bf6c73060b | ||
|
|
ddcd3861d3 | ||
|
|
971d47eb42 | ||
|
|
13bd42bdab | ||
|
|
71ac212dc7 | ||
|
|
2319a00c4f | ||
|
|
1268077f6b | ||
|
|
5c579de459 | ||
|
|
167faff1f3 | ||
|
|
22ad95cbfe | ||
|
|
db8508cefc | ||
|
|
5ac0772a2a | ||
|
|
e2c2d6606d | ||
|
|
48361f58b6 | ||
|
|
dcb439f74a | ||
|
|
739a27be63 | ||
|
|
e84cdce398 | ||
|
|
af2fe242f9 | ||
|
|
0fb177bf85 | ||
|
|
baab70c509 | ||
|
|
bc1c70bd1a | ||
|
|
12929c4571 | ||
|
|
62522e4eb3 | ||
|
|
221060cc70 | ||
|
|
58d1f7cee1 | ||
|
|
430256266f | ||
|
|
f9e38b11d9 | ||
|
|
78e075546a | ||
|
|
658e111e3c | ||
|
|
0e23b0bedd | ||
|
|
903c768f7f | ||
|
|
d08f0e6599 | ||
|
|
cd22ba1a2b | ||
|
|
77a11d2a2e | ||
|
|
cce8cb8528 | ||
|
|
6c6b447ea1 | ||
|
|
4554450d1d | ||
|
|
a0d1dbf833 | ||
|
|
a1a89df17f | ||
|
|
cf36384481 | ||
|
|
9103371362 | ||
|
|
1b5ad34c8e | ||
|
|
c57e88850c | ||
|
|
101a831534 | ||
|
|
3cc991fa4f | ||
|
|
c348f4ccad | ||
|
|
0181685d2f | ||
|
|
39bb94dd55 | ||
|
|
77a2bbbb8d | ||
|
|
afb0a80de1 | ||
|
|
49932e02a6 | ||
|
|
990a4ad583 | ||
|
|
fc9e1e401b | ||
|
|
15ca7e82bd | ||
|
|
3b81bbcae5 | ||
|
|
902fc2cbe8 | ||
|
|
50f5dabf4a | ||
|
|
aa6c9e2106 | ||
|
|
919fdb3594 | ||
|
|
c625cc68bf | ||
|
|
d732140bf9 | ||
|
|
db525bd5db | ||
|
|
039c666247 | ||
|
|
ed5c24c281 | ||
|
|
f2f4010203 | ||
|
|
a9e261d280 | ||
|
|
a710674cd4 | ||
|
|
ddfc00ed9f | ||
|
|
ac71970561 | ||
|
|
fd50529d86 | ||
|
|
52d95e537c | ||
|
|
15b21fff2b | ||
|
|
f46bccfecd | ||
|
|
1f55973f72 | ||
|
|
3d5fd61285 | ||
|
|
069b501ca3 | ||
|
|
d035af7ff0 | ||
|
|
20302cd378 | ||
|
|
959685e260 | ||
|
|
e0058c17ff | ||
|
|
bf61f5cfe8 | ||
|
|
8dcc25e1a9 | ||
|
|
a428167dc6 | ||
|
|
e46d819c46 | ||
|
|
48e3a3eb68 | ||
|
|
a635fb3f77 | ||
|
|
274f2fe10d | ||
|
|
320f679038 | ||
|
|
94c20ba29f | ||
|
|
8baebcfb5b | ||
|
|
2c96d49cf2 | ||
|
|
a9cabdc342 | ||
|
|
90a95b4688 | ||
|
|
7fcce4a59b | ||
|
|
554ffcd08f | ||
|
|
0c46ea13c7 | ||
|
|
af0574c04e | ||
|
|
6c38295d62 | ||
|
|
1e01dbb151 | ||
|
|
be270259ee | ||
|
|
03f9955f8b | ||
|
|
55e613fae5 | ||
|
|
a5bad2b9b7 | ||
|
|
ebb251d8cf | ||
|
|
56768f2d3d | ||
|
|
5b3d36e081 | ||
|
|
ad08590197 | ||
|
|
53b5588bda | ||
|
|
1015a8c098 | ||
|
|
27ddc215cc | ||
|
|
c11a6cd432 | ||
|
|
514eedbc63 | ||
|
|
1f61f80c92 | ||
|
|
830ffd0559 | ||
|
|
ed066df469 | ||
|
|
e6676c7d09 | ||
|
|
33115a39a3 | ||
|
|
6538360fe1 | ||
|
|
3a62e432da | ||
|
|
9c3f60c26c | ||
|
|
ed0e5b8c5a | ||
|
|
c75d94bd90 | ||
|
|
a8d6374d76 | ||
|
|
4b10402c5b | ||
|
|
e5863920c4 | ||
|
|
7f61b44d42 | ||
|
|
a5660fa2b4 | ||
|
|
ecc03e3ebc | ||
|
|
a92c2899c8 | ||
|
|
af4638e83f | ||
|
|
cecf1a5497 | ||
|
|
f2374982b8 | ||
|
|
d736dd027d | ||
|
|
214db9e0b1 | ||
|
|
3bbc89afc9 | ||
|
|
e35ccbbb18 | ||
|
|
20571c5aa1 | ||
|
|
3872a6b475 | ||
|
|
083a1c85a8 | ||
|
|
943e0285ac | ||
|
|
d7abfc688c | ||
|
|
8f01ef90cf | ||
|
|
8d071bf4ea | ||
|
|
3929fe64a3 | ||
|
|
a14086d484 | ||
|
|
20d25059bf | ||
|
|
ccee7162bc | ||
|
|
4fe8e40569 | ||
|
|
b91b3d5da6 | ||
|
|
debbae6ab1 | ||
|
|
2c6f01ae38 | ||
|
|
92f81fa054 | ||
|
|
0362fd1079 | ||
|
|
38765dc89a | ||
|
|
78306b3c12 | ||
|
|
e51a291195 | ||
|
|
d551848a9b | ||
|
|
fe6247dded | ||
|
|
5fb8b458bb | ||
|
|
4e21391f8c | ||
|
|
9ab4bb963f | ||
|
|
340c55c570 | ||
|
|
de1322b928 | ||
|
|
010d257b69 | ||
|
|
58f05f74cf | ||
|
|
e5d517dad2 | ||
|
|
965dea5fe6 | ||
|
|
1ffcc75031 | ||
|
|
e084cc9a3a | ||
|
|
6ed78d1202 | ||
|
|
270eaa1452 | ||
|
|
e1038ea632 | ||
|
|
8947100701 | ||
|
|
cb99e7d920 | ||
|
|
a4b0a69c45 | ||
|
|
2a364910c0 | ||
|
|
45ba648622 | ||
|
|
dcd48f4264 | ||
|
|
b048921c11 | ||
|
|
8ee9f1b1d9 | ||
|
|
f2c39e4004 | ||
|
|
4335aa563f | ||
|
|
62ec3546d6 | ||
|
|
8bb0bd05f9 | ||
|
|
e538242962 | ||
|
|
d70d2ad405 | ||
|
|
4f638f6d77 | ||
|
|
80d78705b0 | ||
|
|
140cec7c59 | ||
|
|
746b3c5a54 | ||
|
|
a4788b5b24 | ||
|
|
8dcf0f58b5 | ||
|
|
a8080c5db3 | ||
|
|
a52977d1cf | ||
|
|
0bb6fed822 | ||
|
|
d86305a7c3 | ||
|
|
5aeef17d09 | ||
|
|
2d41d993e3 | ||
|
|
503cc7ea97 | ||
|
|
7f41847c5c | ||
|
|
fde683a82e | ||
|
|
4feff7d917 | ||
|
|
e61951a319 | ||
|
|
da81274eb9 | ||
|
|
8740141a93 | ||
|
|
9223a2b530 | ||
|
|
300c74e3fc | ||
|
|
3f82c7fb6f | ||
|
|
2cb7a1d96c | ||
|
|
00562455e0 | ||
|
|
bb88dcfe66 | ||
|
|
970e594009 | ||
|
|
cd5a784277 | ||
|
|
771f653174 | ||
|
|
109cb81ab7 | ||
|
|
bf87f7ba84 | ||
|
|
92b8eae2dc | ||
|
|
776f86c7f2 | ||
|
|
c10c3a1cfe | ||
|
|
94fccc5112 | ||
|
|
73fa0e3efc | ||
|
|
2b827e43d7 | ||
|
|
e706368225 | ||
|
|
2f5271ab83 | ||
|
|
4e448b23a8 | ||
|
|
38002d4907 | ||
|
|
fd81f9b1b4 | ||
|
|
77900f5745 | ||
|
|
8684aac4f2 | ||
|
|
b1e0bc90ba | ||
|
|
8e305bfd0f | ||
|
|
32716e1480 | ||
|
|
833eccb6c4 | ||
|
|
f64b3618f2 | ||
|
|
325cd9a066 | ||
|
|
544c711fd7 | ||
|
|
e02afb34d1 | ||
|
|
dc5acd24b2 | ||
|
|
7555263e38 | ||
|
|
71d016722e | ||
|
|
96560e4914 | ||
|
|
04be40767b | ||
|
|
5a6197cfc6 | ||
|
|
5fca12af49 | ||
|
|
853830a446 | ||
|
|
2f47f72957 | ||
|
|
de35cf9840 | ||
|
|
18d8107992 | ||
|
|
2478b72a3e | ||
|
|
4d60150345 | ||
|
|
6a3a8d5578 | ||
|
|
08828991e7 | ||
|
|
4c14a96888 | ||
|
|
0478ec9696 | ||
|
|
46044c068b | ||
|
|
c6fe6b83ac | ||
|
|
cc39d4dd7d | ||
|
|
b79c049bd4 | ||
|
|
4cbf19c97e | ||
|
|
27041cbf59 | ||
|
|
8e2c72ed1b | ||
|
|
7820c9bc44 | ||
|
|
92fff9acf5 | ||
|
|
91da49dc52 | ||
|
|
b5a45417d9 | ||
|
|
3db4993077 | ||
|
|
bc1a5fdd8d | ||
|
|
191f1c38df | ||
|
|
adb61259c1 | ||
|
|
ddc2e84e45 | ||
|
|
a050a61f2e | ||
|
|
99195c3f4c | ||
|
|
280c159078 | ||
|
|
6a8f1b941e | ||
|
|
8a6ce19e1e | ||
|
|
d071adea9a | ||
|
|
3d7455316f | ||
|
|
3f50baa318 | ||
|
|
8164c96379 | ||
|
|
4ab3f01867 | ||
|
|
dbb277f749 | ||
|
|
0579f2ede6 | ||
|
|
ef3af9aad3 | ||
|
|
d5694036fa | ||
|
|
f91847dad0 | ||
|
|
c4eaa973f0 | ||
|
|
42fa77c81f | ||
|
|
e4bfeb9e44 | ||
|
|
67f2162fb3 | ||
|
|
465499f6c3 | ||
|
|
ea75311a34 | ||
|
|
33fd8a9ec7 | ||
|
|
417ffc09f8 | ||
|
|
1057f50f86 | ||
|
|
5b933cde61 | ||
|
|
47442d1bc9 | ||
|
|
f25c83e006 | ||
|
|
bc34024e32 | ||
|
|
628bef9094 | ||
|
|
63598019e1 | ||
|
|
501244ed25 | ||
|
|
e12912450c | ||
|
|
8262c9ece7 | ||
|
|
cc208ce451 | ||
|
|
c6374a899c | ||
|
|
8f80bcb159 | ||
|
|
e56ecfec40 | ||
|
|
80cf422a5e | ||
|
|
d788c310ee | ||
|
|
7583db3bef | ||
|
|
ac5abd96bb | ||
|
|
aa944ac5e8 | ||
|
|
35e1fb9ae5 | ||
|
|
a15863ae35 | ||
|
|
a04fd06e38 | ||
|
|
f6cc2c7b91 | ||
|
|
99ee526ac5 | ||
|
|
d100067e02 | ||
|
|
f777c62a66 | ||
|
|
06ef0e5fdc | ||
|
|
5209623064 | ||
|
|
7c53413bc5 | ||
|
|
42f92b8dc1 | ||
|
|
986baccf83 | ||
|
|
32d31e7644 | ||
|
|
03161446b9 | ||
|
|
17bbb7f145 | ||
|
|
71c4ec34d5 | ||
|
|
da3ed74c4e | ||
|
|
46ae8f92cc | ||
|
|
9b3dec5f70 | ||
|
|
146bfb28d1 | ||
|
|
46fb331275 | ||
|
|
ff39b8b252 | ||
|
|
004250ed23 | ||
|
|
037339f3be | ||
|
|
e0437ab447 | ||
|
|
808a161d39 | ||
|
|
6d8e1794a0 | ||
|
|
89338c0b4b | ||
|
|
7f7cbd5666 | ||
|
|
846ed76808 | ||
|
|
ab45b5ec8a | ||
|
|
db93a4c4a7 | ||
|
|
59566eb363 | ||
|
|
7fb85e5b25 | ||
|
|
c061912574 | ||
|
|
3eeb7e7cae | ||
|
|
cf653640b3 | ||
|
|
5cfd897298 | ||
|
|
7ecb6a6d96 | ||
|
|
c08f177d3b | ||
|
|
1c6e722961 | ||
|
|
0d49817f00 | ||
|
|
85c21df5e7 | ||
|
|
f9d5b8eb74 | ||
|
|
bcc3337c58 | ||
|
|
163888f329 | ||
|
|
8b986dfab3 | ||
|
|
19bd6d0bca | ||
|
|
c2caef4ad5 | ||
|
|
1d9ac4918c | ||
|
|
bc3be1029c | ||
|
|
bc238de5ce | ||
|
|
1072235b1a | ||
|
|
3c2c7b379d | ||
|
|
4af194035c | ||
|
|
3171cfd381 | ||
|
|
8183bf7f95 | ||
|
|
82bec1e324 | ||
|
|
897cc01f93 | ||
|
|
5bcfa35737 | ||
|
|
c1bcf91dd6 | ||
|
|
621e4d196e | ||
|
|
45ebc2239f | ||
|
|
a6248905a0 | ||
|
|
699dcdaf5b | ||
|
|
23d1f6b507 | ||
|
|
f72f4c49fb | ||
|
|
2803ee8274 | ||
|
|
0d2e6f5e98 | ||
|
|
99bf7f77c4 | ||
|
|
7fe2ab720f | ||
|
|
18cecc8d38 | ||
|
|
5d068fc2d4 | ||
|
|
84d98763f1 | ||
|
|
86356c737c | ||
|
|
1fa233aae7 | ||
|
|
1dc01314a1 | ||
|
|
fb40bb22df | ||
|
|
1dc22ec76c | ||
|
|
41ac140076 | ||
|
|
4e019cc233 | ||
|
|
36007ceb68 | ||
|
|
25fdeac697 | ||
|
|
07d27edb76 | ||
|
|
39fabf39ae | ||
|
|
945a483e9b | ||
|
|
1725dbfa98 | ||
|
|
67790abf0e | ||
|
|
3ec08f6ae1 | ||
|
|
c419654a11 | ||
|
|
51ad6094e8 | ||
|
|
5b7d189058 | ||
|
|
7d57d55414 | ||
|
|
65956dbc8d | ||
|
|
d75072362a | ||
|
|
22947af854 | ||
|
|
50a67dbd3e | ||
|
|
7fd954e10d | ||
|
|
4c53fcecfa | ||
|
|
17348dae8a | ||
|
|
05d495b282 | ||
|
|
3b7a940e9b | ||
|
|
501c6f260a | ||
|
|
e1fa2b9831 | ||
|
|
043175ae4d | ||
|
|
8b266b1327 | ||
|
|
f7abe3bb34 | ||
|
|
480e85f615 | ||
|
|
0182d1ca09 | ||
|
|
99a0dce8cd | ||
|
|
badcace987 | ||
|
|
e8b73e22b7 | ||
|
|
45f68d59ff | ||
|
|
1762987aae | ||
|
|
ad2e142b01 | ||
|
|
88fa5d5c41 | ||
|
|
e45ec4324f | ||
|
|
d9a8e29a94 | ||
|
|
3ced57a263 | ||
|
|
458868a634 | ||
|
|
7ecc0543f4 | ||
|
|
6d6f3d38d4 | ||
|
|
a4e715fa71 | ||
|
|
8594d11693 | ||
|
|
a4c14ebef7 | ||
|
|
599874c9c1 | ||
|
|
5121b0df93 | ||
|
|
e3a2f1cfbe | ||
|
|
414fb9dba2 | ||
|
|
a402c69c55 | ||
|
|
c007165a0f | ||
|
|
a3d50fc197 | ||
|
|
baa0ac44ca | ||
|
|
6768901446 | ||
|
|
35e77976a6 | ||
|
|
dba805e8c4 | ||
|
|
e3aca85efd | ||
|
|
f35a18bb63 | ||
|
|
a6ad0208db | ||
|
|
e02ccbf32a | ||
|
|
b362a55c04 | ||
|
|
69d0801121 | ||
|
|
f85bca06d7 | ||
|
|
3589e94121 | ||
|
|
2baf2cfed6 | ||
|
|
4d5c93adfa | ||
|
|
93eff7fac6 | ||
|
|
ce68a9c708 | ||
|
|
280dad1c07 | ||
|
|
c3d954263b | ||
|
|
e058ba5d3b | ||
|
|
05d51cc35c | ||
|
|
a51f310e96 | ||
|
|
89ccdf2814 | ||
|
|
52af352fcd | ||
|
|
088287227e | ||
|
|
ad1f9527c1 | ||
|
|
ca17717af7 | ||
|
|
2a849ccba5 | ||
|
|
4bf20846bc | ||
|
|
ad80184e7f | ||
|
|
e5ca63db20 | ||
|
|
7a33ae35e0 | ||
|
|
ce58ba3472 | ||
|
|
43ae2ea5f5 | ||
|
|
2f03922b43 | ||
|
|
5db2856270 | ||
|
|
e3e3229612 | ||
|
|
8b2ed736a6 | ||
|
|
27da5f84c4 | ||
|
|
98d04702ae | ||
|
|
a0664a49d2 | ||
|
|
55fb0a6efb | ||
|
|
7fb83f4f77 | ||
|
|
3006cd4f60 | ||
|
|
970f8c6dcd | ||
|
|
c99de2370f | ||
|
|
8c9ff4a66f | ||
|
|
42eeddcbfb | ||
|
|
8b0f17fb25 | ||
|
|
a3900495d5 | ||
|
|
d7bc1f0f77 | ||
|
|
281a04837f | ||
|
|
3ea688be69 | ||
|
|
c27180fb32 | ||
|
|
1bea7853ef | ||
|
|
104521517c | ||
|
|
bb217e5c49 | ||
|
|
12f302d356 | ||
|
|
6f233462c1 | ||
|
|
77e7c25e9c | ||
|
|
b027a6b9a1 | ||
|
|
6bb4575c95 | ||
|
|
37eace9db4 | ||
|
|
0414406471 | ||
|
|
8c000f327e | ||
|
|
951e70328f | ||
|
|
2dd7717128 | ||
|
|
9d6c548730 | ||
|
|
8a46853dfd | ||
|
|
789fd21bb7 | ||
|
|
3fa97b5ce7 | ||
|
|
c8ebbc657a | ||
|
|
b59585437c | ||
|
|
6f4e1365b1 | ||
|
|
fcef404f50 | ||
|
|
aabb492d01 | ||
|
|
cfa21934bb | ||
|
|
7561ce753a | ||
|
|
5ac0e58886 | ||
|
|
a14fc35e47 | ||
|
|
5fd00e3063 | ||
|
|
a46a012c3c | ||
|
|
3072105efe | ||
|
|
8f09ac2611 | ||
|
|
e12be7cf29 | ||
|
|
588d79641a | ||
|
|
daac6de533 | ||
|
|
c6d7307efe | ||
|
|
710f379bd3 | ||
|
|
e4d9be86b4 | ||
|
|
3c483c61e7 | ||
|
|
c453d14352 | ||
|
|
de060d66ab | ||
|
|
c458a8f5e7 | ||
|
|
4a77f847b4 | ||
|
|
edc6474f27 | ||
|
|
117f47e3a2 | ||
|
|
4f11ff76a5 | ||
|
|
10e97b63be | ||
|
|
af76a09e03 | ||
|
|
147bd8341d | ||
|
|
5c0dd67094 | ||
|
|
49688d6523 | ||
|
|
850f23be82 | ||
|
|
9e5769912b | ||
|
|
ab50bc9936 | ||
|
|
a604a3904f | ||
|
|
e112f2d8af | ||
|
|
376d2e1433 | ||
|
|
ed0caa119a | ||
|
|
f768146d8e | ||
|
|
412083d9ea | ||
|
|
07cdb42ff7 | ||
|
|
1e37e8f333 | ||
|
|
4fa89c4a45 | ||
|
|
0d7a2128b6 | ||
|
|
9aa3d8b987 | ||
|
|
eaf44bc18c | ||
|
|
ae33c8de18 | ||
|
|
b12e82c344 | ||
|
|
8dee648d01 | ||
|
|
8e6dc54b16 | ||
|
|
db9c48b085 | ||
|
|
c0171f5fd1 | ||
|
|
9a5a55d074 | ||
|
|
855836d9aa | ||
|
|
8a0a0bcdfc | ||
|
|
43c00568c6 | ||
|
|
31be731de0 | ||
|
|
113ef66e26 | ||
|
|
4d38e69f63 | ||
|
|
8c02345dfd | ||
|
|
a2efde1103 | ||
|
|
eb81583d9f | ||
|
|
44213bf830 | ||
|
|
f187f77e3d | ||
|
|
63a3f02368 | ||
|
|
994e6826b4 | ||
|
|
97991fd8fc | ||
|
|
1fdda98d8d | ||
|
|
a73ca94124 | ||
|
|
82d2aa8a47 | ||
|
|
75af07331a | ||
|
|
4be4ad07f3 | ||
|
|
57874a9bcb | ||
|
|
ec7968b2f4 | ||
|
|
81546fe727 | ||
|
|
7948bac6ba | ||
|
|
eceb5ba982 | ||
|
|
345dab9633 | ||
|
|
5c952021b7 | ||
|
|
80a5b44fe9 | ||
|
|
b66e6560ca | ||
|
|
673c2988d6 | ||
|
|
042f2e0224 | ||
|
|
b300bb9f7a | ||
|
|
205f2690d6 | ||
|
|
aeea301ee3 | ||
|
|
8e6bbed74f | ||
|
|
ef506d49aa | ||
|
|
c205a888a9 | ||
|
|
a3b66aec1f | ||
|
|
68f4c50bd3 | ||
|
|
7dbd79750c | ||
|
|
fd301186c7 | ||
|
|
b40328e621 | ||
|
|
7cd832e914 | ||
|
|
44feea4c01 | ||
|
|
c5ce475359 | ||
|
|
894a0540b9 | ||
|
|
967f4570ed | ||
|
|
14360beaf7 | ||
|
|
46e3258629 | ||
|
|
b3ad0a62c1 | ||
|
|
a5edd9c7ff | ||
|
|
7f49accc22 | ||
|
|
b8c2a695b8 | ||
|
|
c73bbc85bd | ||
|
|
d6545b253b | ||
|
|
293761bdf5 | ||
|
|
d862453956 | ||
|
|
58974c9305 | ||
|
|
cddb6609f1 | ||
|
|
4a9c51a6c8 | ||
|
|
329ae11d2f | ||
|
|
c3bc5cfc3b | ||
|
|
24f9003cd3 | ||
|
|
4c2bf59c46 | ||
|
|
642a89733b | ||
|
|
2b3d9427e1 | ||
|
|
6368241b77 | ||
|
|
57ae9022dd | ||
|
|
7ed68952ba | ||
|
|
4696733eb4 | ||
|
|
5f5d31730c | ||
|
|
e07977eea9 | ||
|
|
71fb024061 | ||
|
|
54cfc6e09b | ||
|
|
150cfa29e7 | ||
|
|
b90cdf9588 | ||
|
|
6316479930 | ||
|
|
f9603dc11a | ||
|
|
5359e9a09d | ||
|
|
28d2c6db73 | ||
|
|
abc8b18b78 | ||
|
|
c889bfa6d4 | ||
|
|
f2a0098fed | ||
|
|
b549c56b23 | ||
|
|
f107d380b9 |
No files matched your search
@@ -1,9 +0,0 @@
|
||||
freebsd_instance:
|
||||
image_family: freebsd-12-2
|
||||
|
||||
task:
|
||||
install_script: pkg install -y alsa-lib cmake evdev-proto flac git libao libevdev libudev-devd libzip mesa-libs miniupnpc ninja pkgconf png pulseaudio sdl2
|
||||
script:
|
||||
- git submodule update --init --recursive
|
||||
- cmake -B build -DCMAKE_BUILD_TYPE=Release -G Ninja
|
||||
- cmake --build build --config Release
|
||||
@@ -0,0 +1 @@
|
||||
custom: ['https://www.paypal.com/paypalme/FlycastEmu']
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Please Note: This form is the minimum required information for submitting bugs.**
|
||||
**Removing this form may lead to your issue being closed until it is completed.**
|
||||
|
||||
Platform / OS / Hardware:
|
||||
|
||||
Github hash:
|
||||
|
||||
Hardware:
|
||||
|
||||
**_Description of the Issue_**
|
||||
|
||||
Add a short, concise description of the issue here
|
||||
|
||||
**_Debugging Steps Tested_**
|
||||
|
||||
* Fill in any steps already tried here
|
||||
* Begin each new line with an asterisk
|
||||
* If no steps are required, please skip
|
||||
|
||||
**_Logs Gathered_**
|
||||
|
||||
```
|
||||
|
||||
Please paste the contents of the log / logs here
|
||||
You may leave this field blank if you have none.
|
||||
|
||||
```
|
||||
|
||||
|
||||
**_Screenshots_**
|
||||
|
||||
(Replace this line with any issue screenshots)
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: enhancement
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -8,44 +8,88 @@ jobs:
|
||||
|
||||
steps:
|
||||
- name: Set up build environment
|
||||
run: echo "y" | sudo ${ANDROID_HOME}/tools/bin/sdkmanager --install "ndk;20.0.5594570"
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install ccache libcurl4-openssl-dev ninja-build
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
|
||||
- uses: actions/cache@v2
|
||||
submodules: true
|
||||
|
||||
- uses: actions/setup-java@v4
|
||||
with:
|
||||
path: ~/.gradle/caches
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
cache: 'gradle'
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.ccache
|
||||
key: android-ccache-${{ github.sha }}
|
||||
restore-keys: android-ccache-
|
||||
|
||||
- name: Gradle
|
||||
working-directory: shell/android-studio
|
||||
run: ./gradlew assembleDebug --parallel
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: flycast-debug.apk
|
||||
path: shell/android-studio/flycast/build/outputs/apk/debug/flycast-debug.apk
|
||||
|
||||
- name: Set up git vars
|
||||
run: |
|
||||
echo GIT_BUILD=`git describe --all --always | sed 's/remotes\/origin/heads/'`-$GITHUB_SHA >> $GITHUB_ENV
|
||||
|
||||
- name: Clean up
|
||||
run: rm -f shell/android-studio/flycast/build/outputs/apk/debug/*.json
|
||||
|
||||
- uses: jakejarvis/s3-sync-action@master
|
||||
with:
|
||||
args: --acl public-read --follow-symlinks
|
||||
run: ./gradlew assembleRelease --parallel
|
||||
env:
|
||||
AWS_S3_BUCKET: flycast-builds
|
||||
AWS_ACCESS_KEY_ID: AKIAJOZQS4H2PHQWYFCA
|
||||
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_KEY }}
|
||||
AWS_REGION: 'us-east-2'
|
||||
SOURCE_DIR: 'shell/android-studio/flycast/build/outputs/apk/debug/'
|
||||
DEST_DIR: android/${{ env.GIT_BUILD }}
|
||||
if: ${{ github.event_name == 'push' }}
|
||||
SENTRY_UPLOAD_URL: ${{ secrets.SENTRY_UPLOAD_URL }}
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: flycast-release.apk
|
||||
path: shell/android-studio/flycast/build/outputs/apk/release/flycast-release.apk
|
||||
|
||||
- name: Build dump_syms
|
||||
working-directory: core/deps/breakpad
|
||||
run: |
|
||||
./configure --prefix=$PWD
|
||||
make -j2
|
||||
make install
|
||||
|
||||
- name: Extract symbols
|
||||
run: |
|
||||
DUMP_SYMS=./core/deps/breakpad/bin/dump_syms
|
||||
SO_DIR=shell/android-studio/flycast/build/intermediates/merged_native_libs/release/mergeReleaseNativeLibs/out/lib
|
||||
for arch in arm64-v8a armeabi-v7a x86 x86_64 ; do
|
||||
$DUMP_SYMS $SO_DIR/$arch/libflycast.so > libflycast.so.sym
|
||||
BUILD_ID=`head -1 libflycast.so.sym | awk '{ print $4 }'`
|
||||
mkdir -p symbols/libflycast.so/$BUILD_ID
|
||||
mv libflycast.so.sym symbols/libflycast.so/$BUILD_ID
|
||||
done
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
id: aws-credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-access-key-id: AKIAJOZQS4H2PHQWYFCA
|
||||
aws-secret-access-key: ${{ secrets.S3_SECRET_KEY }}
|
||||
aws-region: us-east-2
|
||||
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push'
|
||||
|
||||
- name: Upload to S3
|
||||
run: aws s3 sync shell/android-studio/flycast/build/outputs/apk/release s3://flycast-builds/android/${GITHUB_REF#refs/}-$GITHUB_SHA --acl public-read --exclude='*.json' --follow-symlinks
|
||||
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' }}
|
||||
|
||||
- name: Setup Sentry CLI
|
||||
uses: mathieu-bour/setup-sentry-cli@v2
|
||||
env:
|
||||
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN }}
|
||||
with:
|
||||
url: https://sentry.io
|
||||
token: ${{ env.SENTRY_TOKEN }}
|
||||
organization: flycast
|
||||
project: minidump
|
||||
version: 2.21.2
|
||||
if: ${{ env.SENTRY_TOKEN != '' }}
|
||||
|
||||
- name: Upload symbols to Sentry
|
||||
run: |
|
||||
VERSION=$(git describe --tags --always)
|
||||
sentry-cli releases new "$VERSION"
|
||||
sentry-cli releases set-commits "$VERSION" --auto
|
||||
sentry-cli debug-files upload symbols
|
||||
shell: bash
|
||||
env:
|
||||
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN }}
|
||||
if: ${{ env.SENTRY_TOKEN != '' }}
|
||||
@@ -0,0 +1,48 @@
|
||||
name: BSD CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
env:
|
||||
CCACHE_DIR: ${{ github.workspace }}/.ccache
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
matrix:
|
||||
operating_system: [ freebsd, netbsd, openbsd ]
|
||||
architecture: [ arm64, x86-64 ]
|
||||
include:
|
||||
- operating_system: freebsd
|
||||
version: '14.0'
|
||||
pkginstall: sudo pkg install -y alsa-lib ccache cmake evdev-proto git libao libevdev libudev-devd libzip miniupnpc ninja pkgconf pulseaudio sdl2
|
||||
- operating_system: netbsd
|
||||
version: '9.3'
|
||||
pkginstall: sudo pkgin update && sudo pkgin -y install alsa-lib ccache cmake gcc12 git libao libzip miniupnpc ninja-build pkgconf pulseaudio SDL2 && export PATH=/usr/pkg/gcc12/bin:$PATH
|
||||
- operating_system: openbsd
|
||||
version: '7.4'
|
||||
pkginstall: sudo pkg_add ccache cmake git libao libzip miniupnpc ninja pkgconf pulseaudio sdl2
|
||||
exclude:
|
||||
- architecture: arm64
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.CCACHE_DIR }}
|
||||
key: ccache-${{ matrix.operating_system }}-${{ matrix.architecture }}-${{ github.sha }}
|
||||
restore-keys: ccache-${{ matrix.operating_system }}-${{ matrix.architecture }}-
|
||||
|
||||
- uses: cross-platform-actions/[email protected]
|
||||
with:
|
||||
operating_system: ${{ matrix.operating_system }}
|
||||
architecture: ${{ matrix.architecture }}
|
||||
version: ${{ matrix.version }}
|
||||
environment_variables: CCACHE_DIR
|
||||
run: |
|
||||
${{ matrix.pkginstall }}
|
||||
cmake -B build -DCMAKE_BUILD_TYPE=Release -G Ninja
|
||||
cmake --build build --config Release
|
||||
+131
-53
@@ -7,97 +7,175 @@ jobs:
|
||||
name: ${{ matrix.config.name }}
|
||||
runs-on: ${{ matrix.config.os }}
|
||||
|
||||
defaults:
|
||||
run:
|
||||
shell: ${{ matrix.config.shell }}
|
||||
|
||||
env:
|
||||
CCACHE_DIR: ${{ github.workspace }}/.ccache
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
config:
|
||||
- {name: i686-pc-windows-msvc, os: windows-latest, cmakeArgs: -DCMAKE_SYSTEM_VERSION="10.0.18362.0" -G "Visual Studio 16 2019" -A Win32}
|
||||
- {name: x86_64-apple-darwin, os: macos-latest, cmakeArgs: -G "Xcode", destDir: osx}
|
||||
- {name: x86_64-pc-linux-gnu, os: ubuntu-latest}
|
||||
- {name: x86_64-pc-windows-msvc, os: windows-latest, cmakeArgs: -DCMAKE_SYSTEM_VERSION="10.0.18362.0" -G "Visual Studio 16 2019" -A x64}
|
||||
- {name: x86_64-w64-mingw32, os: windows-latest, cmakeArgs: -G "MinGW Makefiles", destDir: win}
|
||||
- {name: i686-pc-windows-msvc, os: windows-latest, shell: cmd, arch: x86, cmakeArgs: -G Ninja, buildType: Release}
|
||||
- {name: apple-darwin, os: macos-latest, shell: sh, cmakeArgs: -G Xcode -DAPPLE_BREAKPAD=ON, destDir: osx, buildType: RelWithDebInfo}
|
||||
- {name: apple-ios, os: macos-latest, shell: sh, cmakeArgs: -DCMAKE_SYSTEM_NAME=iOS -G Xcode, destDir: ios, buildType: Release}
|
||||
- {name: x86_64-pc-linux-gnu, os: ubuntu-20.04, shell: sh, cmakeArgs: -G Ninja, destDir: linux, buildType: RelWithDebInfo}
|
||||
- {name: x86_64-pc-windows-msvc, os: windows-latest, shell: cmd, arch: x64, cmakeArgs: -G Ninja, buildType: Release}
|
||||
- {name: x86_64-w64-mingw32, os: windows-latest, shell: 'msys2 {0}', cmakeArgs: -G Ninja, destDir: win, buildType: RelWithDebInfo}
|
||||
- {name: libretro-x86_64-pc-linux-gnu, os: ubuntu-latest, shell: sh, cmakeArgs: -DLIBRETRO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -G Ninja, buildType: Release}
|
||||
- {name: libretro-x86_64-w64-mingw32, os: windows-latest, shell: 'msys2 {0}', cmakeArgs: -DLIBRETRO=ON -G Ninja, buildType: Release}
|
||||
|
||||
steps:
|
||||
- name: Set up build environment (macos-latest)
|
||||
- name: Set up build environment (macOS)
|
||||
run: |
|
||||
brew install ccache flac libao libomp pulseaudio zlib
|
||||
echo "/usr/local/opt/ccache/libexec" >> $GITHUB_PATH
|
||||
echo "CCACHE_DIR=/tmp/ccache" >> $GITHUB_ENV
|
||||
if: matrix.config.os == 'macos-latest'
|
||||
# Unlink and re-link to prevent errors when github mac runner images install python outside of brew. See https://github.com/actions/setup-python/issues/577
|
||||
brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done
|
||||
brew update || :
|
||||
brew install libao ldid ninja pulseaudio
|
||||
VULKAN_VER=1.3.261.1 && aria2c https://sdk.lunarg.com/sdk/download/$VULKAN_VER/mac/vulkansdk-macos-$VULKAN_VER.dmg
|
||||
hdiutil attach ./vulkansdk-macos-*.dmg -mountpoint /Volumes/VulkanSDK
|
||||
sudo /Volumes/VulkanSDK/InstallVulkan.app/Contents/MacOS/InstallVulkan --root $HOME/VulkanSDK --accept-licenses --default-answer --confirm-command install
|
||||
hdiutil detach /Volumes/VulkanSDK
|
||||
echo "VULKAN_SDK=$HOME/VulkanSDK/macOS" >> $GITHUB_ENV
|
||||
if: runner.os == 'macOS'
|
||||
|
||||
- name: Set up build environment (ubuntu-latest)
|
||||
- name: Set up build environment (Linux)
|
||||
run: |
|
||||
sudo add-apt-repository ppa:christianrauch/libdecoration
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install ccache libao-dev libasound2-dev libevdev-dev libflac-dev libgl1-mesa-dev libpulse-dev libsdl2-dev libudev-dev libzip-dev libminiupnpc-dev
|
||||
echo "CCACHE_DIR=/tmp/ccache" >> $GITHUB_ENV
|
||||
if: matrix.config.os == 'ubuntu-latest'
|
||||
sudo apt-get -y install ccache libao-dev libasound2-dev libevdev-dev libgl1-mesa-dev liblua5.3-dev libminiupnpc-dev libpulse-dev libsdl2-dev libudev-dev libzip-dev ninja-build libcurl4-openssl-dev
|
||||
sudo apt-get -y install libwayland-dev libdecor-0-dev libaudio-dev libjack-dev libsndio-dev libsamplerate0-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxkbcommon-dev libdrm-dev libgbm-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev
|
||||
if: runner.os == 'Linux'
|
||||
|
||||
- uses: actions/cache@v2
|
||||
- name: Set up build environment (Windows, MinGW)
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
path: /tmp/ccache
|
||||
key: ccache-${{ matrix.config.os }}-${{ github.sha }}
|
||||
restore-keys: ccache-${{ matrix.config.os }}-
|
||||
if: matrix.config.os != 'windows-latest'
|
||||
msystem: MINGW64
|
||||
install: git make mingw-w64-x86_64-ccache mingw-w64-x86_64-cmake mingw-w64-x86_64-lua mingw-w64-x86_64-ninja mingw-w64-x86_64-SDL2 mingw-w64-x86_64-toolchain
|
||||
if: matrix.config.shell == 'msys2 {0}'
|
||||
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up build environment (Windows, Visual Studio)
|
||||
run: |
|
||||
choco install ccache directx-sdk ninja
|
||||
echo DXSDK_DIR=C:\Program Files (x86)\Microsoft DirectX SDK (June 2010)>> %GITHUB_ENV%
|
||||
if: matrix.config.shell == 'cmd'
|
||||
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
with:
|
||||
arch: ${{ matrix.config.arch }}
|
||||
if: matrix.config.shell == 'cmd'
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: recursive
|
||||
submodules: true
|
||||
|
||||
- name: Create artifact directory
|
||||
run: mkdir -p build/artifact
|
||||
- name: Compile a universal OpenMP (macOS)
|
||||
run: HOMEBREW_NO_INSTALLED_DEPENDENTS_CHECK=1 brew reinstall --build-from-source --formula ./shell/apple/libomp.rb
|
||||
if: matrix.config.name == 'apple-darwin'
|
||||
|
||||
- name: Build SDL (macos-latest)
|
||||
run: |
|
||||
cd shell/apple
|
||||
mkdir artifacts
|
||||
brew install --build-from-source ./sdl2.rb
|
||||
if: matrix.config.os == 'macos-latest'
|
||||
- name: Compile OpenMP.xcframework (iOS)
|
||||
run: ./shell/apple/emulator-ios/OpenMP/build_ios_openmp.sh --disableSimulator
|
||||
if: matrix.config.name == 'apple-ios'
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ${{ env.CCACHE_DIR }}
|
||||
key: ccache-${{ matrix.config.name }}-${{ github.sha }}
|
||||
restore-keys: ccache-${{ matrix.config.name }}-
|
||||
if: runner.os != 'macOS'
|
||||
|
||||
- name: CMake
|
||||
run: |
|
||||
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=artifact ${{ matrix.config.cmakeArgs }}
|
||||
cmake --build build --config Release --parallel 2
|
||||
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config.buildType }} -DCMAKE_INSTALL_PREFIX=artifact ${{ matrix.config.cmakeArgs }} -DSENTRY_UPLOAD_URL=${{ env.SENTRY_UPLOAD_URL }}
|
||||
cmake --build build --config ${{ matrix.config.buildType }} --target install
|
||||
env:
|
||||
SENTRY_UPLOAD_URL: ${{ secrets.SENTRY_UPLOAD_URL }}
|
||||
|
||||
- name: Unit Tests
|
||||
run: |
|
||||
mkdir -p build/tests
|
||||
cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE=tests -DENABLE_CTEST=ON ${{ matrix.config.cmakeArgs }}
|
||||
cmake --build build --config Release --parallel 2
|
||||
./build/tests/flycast
|
||||
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.config.buildType }} -DCMAKE_INSTALL_PREFIX=artifact -DENABLE_CTEST=ON ${{ matrix.config.cmakeArgs }}
|
||||
cmake --build build --config ${{ matrix.config.buildType }}
|
||||
./build/flycast
|
||||
if: matrix.config.name == 'x86_64-pc-linux-gnu'
|
||||
|
||||
- uses: actions/upload-artifact@v2
|
||||
- name: Dump symbols
|
||||
run: |
|
||||
mkdir -p symbols
|
||||
core/deps/breakpad/bin/dump_syms artifact/bin/flycast.exe > symbols/flycast.sym 2>/dev/null
|
||||
strip artifact/bin/flycast.exe
|
||||
if: matrix.config.name == 'x86_64-w64-mingw32'
|
||||
|
||||
- name: Build breakpad (linux)
|
||||
working-directory: core/deps/breakpad
|
||||
run: |
|
||||
./configure
|
||||
make
|
||||
sudo make install
|
||||
if: matrix.config.name == 'x86_64-pc-linux-gnu'
|
||||
|
||||
- name: Dump symbols and make AppImage (linux)
|
||||
run: |
|
||||
mkdir -p symbols
|
||||
dump_syms artifact/bin/flycast > symbols/flycast.sym 2>/dev/null
|
||||
strip artifact/bin/flycast
|
||||
shell/linux/make-appimage.sh . artifact/bin appimage
|
||||
mv flycast-x86_64.AppImage artifact/bin
|
||||
rm artifact/bin/flycast
|
||||
if: matrix.config.name == 'x86_64-pc-linux-gnu'
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: flycast-${{ matrix.config.name }}
|
||||
path: build/artifact
|
||||
path: artifact/bin
|
||||
|
||||
- name: Package app (macos)
|
||||
run: |
|
||||
cd build/artifact
|
||||
rm -rf Flycast.swiftmodule
|
||||
zip -r flycast.app.zip Flycast.app
|
||||
rm -rf Flycast.app
|
||||
if: matrix.config.os == 'macos-latest'
|
||||
cd artifact/bin
|
||||
zip -rm flycast.app.zip Flycast.app
|
||||
if: matrix.config.name == 'apple-darwin'
|
||||
|
||||
- name: Package app (windows)
|
||||
run: |
|
||||
powershell Compress-Archive build/artifact/flycast.exe build/artifact/flycast.zip
|
||||
rm build/artifact/flycast.exe
|
||||
powershell Compress-Archive artifact/bin/flycast.exe artifact/bin/flycast.zip
|
||||
rm artifact/bin/flycast.exe
|
||||
if: matrix.config.name == 'x86_64-w64-mingw32'
|
||||
|
||||
- name: Set up git vars
|
||||
run: |
|
||||
echo GIT_BUILD=`git describe --all --always | sed 's/remotes\/origin/heads/'`-$GITHUB_SHA >> $GITHUB_ENV
|
||||
shell: bash
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
id: aws-credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-access-key-id: AKIAJOZQS4H2PHQWYFCA
|
||||
aws-secret-access-key: ${{ secrets.S3_SECRET_KEY }}
|
||||
aws-region: us-east-2
|
||||
if: github.event_name == 'push'
|
||||
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push' && matrix.config.destDir != ''
|
||||
|
||||
- name: Upload to S3
|
||||
run: aws s3 sync build/artifact s3://flycast-builds/${{ matrix.config.destDir }}/${{ env.GIT_BUILD }} --acl public-read --follow-symlinks
|
||||
if: github.event_name == 'push' && matrix.config.destDir != ''
|
||||
run: aws s3 sync artifact/bin s3://flycast-builds/${{ matrix.config.destDir }}/${GITHUB_REF#refs/}-$GITHUB_SHA --acl public-read --follow-symlinks
|
||||
shell: bash
|
||||
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' }}
|
||||
|
||||
- name: Setup Sentry CLI
|
||||
uses: mathieu-bour/setup-sentry-cli@v2
|
||||
env:
|
||||
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN }}
|
||||
with:
|
||||
url: https://sentry.io
|
||||
token: ${{ env.SENTRY_TOKEN }}
|
||||
organization: flycast
|
||||
project: minidump
|
||||
version: 2.21.2
|
||||
if: ${{ env.SENTRY_TOKEN != '' }}
|
||||
|
||||
- name: Upload symbols to Sentry (Windows, macOS, Linux)
|
||||
run: |
|
||||
VERSION=$(git describe --tags --always)
|
||||
sentry-cli releases new "$VERSION"
|
||||
sentry-cli releases set-commits "$VERSION" --auto
|
||||
sentry-cli debug-files upload symbols
|
||||
shell: bash
|
||||
env:
|
||||
SENTRY_TOKEN: ${{ secrets.SENTRY_TOKEN }}
|
||||
if: ${{ env.SENTRY_TOKEN != '' && (matrix.config.name == 'x86_64-w64-mingw32' || matrix.config.name == 'apple-darwin' || matrix.config.name == 'x86_64-pc-linux-gnu') }}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# Prepare source texts & upload them to Crowdin
|
||||
|
||||
name: Crowdin Source Texts Upload
|
||||
|
||||
# on change to the English texts
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
paths:
|
||||
- 'shell/libretro/libretro_core_options.h'
|
||||
|
||||
jobs:
|
||||
upload_source_file:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup Java JDK
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 18
|
||||
distribution: zulu
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Upload Source
|
||||
shell: bash
|
||||
env:
|
||||
CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }}
|
||||
run: |
|
||||
python3 intl/upload_workflow.py $CROWDIN_API_KEY "flyinghead-flycast" "shell/libretro/libretro_core_options.h"
|
||||
@@ -0,0 +1,49 @@
|
||||
# Download translations form Crowdin & Recreate libretro_core_options_intl.h
|
||||
|
||||
name: Crowdin Translation Integration
|
||||
|
||||
on:
|
||||
schedule:
|
||||
# please choose a random time & weekday to avoid all repos synching at the same time
|
||||
- cron: '15 22 * * 5' # Fridays at 10:15 PM, UTC
|
||||
|
||||
jobs:
|
||||
create_intl_file:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Setup Java JDK
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: 18
|
||||
distribution: zulu
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal access token.
|
||||
fetch-depth: 0 # otherwise, there would be errors pushing refs to the destination repository.
|
||||
|
||||
- name: Create intl file
|
||||
shell: bash
|
||||
env:
|
||||
CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }}
|
||||
run: |
|
||||
python3 intl/download_workflow.py $CROWDIN_API_KEY "flyinghead-flycast" "shell/libretro/libretro_core_options_intl.h"
|
||||
|
||||
- name: Commit files
|
||||
run: |
|
||||
git config --local user.email "[email protected]"
|
||||
git config --local user.name "github-actions[bot]"
|
||||
git add intl/*_workflow.py "shell/libretro/libretro_core_options_intl.h"
|
||||
git commit -m "Fetch translations & Recreate libretro_core_options_intl.h"
|
||||
|
||||
- name: GitHub Push
|
||||
uses: ad-m/[email protected]
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
branch: ${{ github.ref }}
|
||||
@@ -0,0 +1,62 @@
|
||||
name: Nintendo Switch CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: ${{ matrix.config.name }}
|
||||
runs-on: ubuntu-latest
|
||||
container: devkitpro/devkita64:latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
config:
|
||||
- {name: standalone, destDir: switch}
|
||||
- {name: libretro, cmakeArgs: -DLIBRETRO=ON}
|
||||
|
||||
steps:
|
||||
- name: Set up build environment
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get -y install awscli ccache
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
|
||||
- name: Mark git repository as safe
|
||||
run: git config --global --add safe.directory $PWD
|
||||
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.ccache
|
||||
key: ccache-switch-${{ matrix.config.name }}-${{ github.sha }}
|
||||
restore-keys: ccache-switch-${{ matrix.config.name }}-
|
||||
|
||||
- name: CMake
|
||||
run: |
|
||||
$DEVKITPRO/portlibs/switch/bin/aarch64-none-elf-cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=artifact -G Ninja ${{ matrix.config.cmakeArgs }}
|
||||
cmake --build build --config Release --target install
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: flycast-switch-${{ matrix.config.name }}
|
||||
path: artifact/bin
|
||||
|
||||
- name: Package app
|
||||
run: zip -m artifact/bin/flycast.nro.zip artifact/bin/flycast.nro
|
||||
if: hashFiles('artifact/bin/flycast.nro') != ''
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
id: aws-credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-access-key-id: AKIAJOZQS4H2PHQWYFCA
|
||||
aws-secret-access-key: ${{ secrets.S3_SECRET_KEY }}
|
||||
aws-region: us-east-2
|
||||
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push' && matrix.config.destDir != ''
|
||||
|
||||
- name: Upload to S3
|
||||
run: aws s3 sync artifact/bin s3://flycast-builds/${{ matrix.config.destDir }}/${GITHUB_REF#refs/}-$GITHUB_SHA --acl public-read --follow-symlinks
|
||||
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' }}
|
||||
@@ -0,0 +1,54 @@
|
||||
name: Windows UWP CI
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
submodules: true
|
||||
|
||||
- name: CMake
|
||||
run: |
|
||||
cmake -B build -DCMAKE_BUILD_TYPE=Release -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_NAME=WindowsStore -DCMAKE_SYSTEM_VERSION=10.0.22000.0
|
||||
cmake --build build --config Release -- /m
|
||||
shell: cmd
|
||||
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
|
||||
- name: Package app
|
||||
run: |
|
||||
mkdir build\artifact
|
||||
cd build\AppPackages\flycast\flycast_*_x64_Test
|
||||
mkdir tmp
|
||||
ren *.msix flycast.msix
|
||||
makeappx.exe unpack /p .\flycast.msix /d tmp
|
||||
copy ..\..\..\Release\*.dll tmp
|
||||
makeappx pack /d tmp /p ..\..\..\artifact\flycast.appx
|
||||
|
||||
- name: Sign app
|
||||
run: signtool sign /f shell\uwp\sign_cert.pfx /p '${{ secrets.SIGN_CERT_PWD }}' /v /fd SHA256 build\artifact\flycast.appx
|
||||
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push'
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: flycast-uwp
|
||||
path: build/artifact
|
||||
|
||||
- name: Configure AWS Credentials
|
||||
id: aws-credentials
|
||||
uses: aws-actions/configure-aws-credentials@v4
|
||||
with:
|
||||
aws-access-key-id: AKIAJOZQS4H2PHQWYFCA
|
||||
aws-secret-access-key: ${{ secrets.S3_SECRET_KEY }}
|
||||
aws-region: us-east-2
|
||||
if: github.repository == 'flyinghead/flycast' && github.event_name == 'push'
|
||||
|
||||
- name: Upload to S3
|
||||
run: aws s3 sync build/artifact s3://flycast-builds/xbox/${GITHUB_REF#refs/}-$GITHUB_SHA --acl public-read --follow-symlinks
|
||||
shell: bash
|
||||
if: ${{ steps.aws-credentials.outputs.aws-account-id != '' }}
|
||||
+11
-58
@@ -1,66 +1,19 @@
|
||||
.DS_Store
|
||||
*.class
|
||||
*.orig
|
||||
*build_obj
|
||||
Workdir/data
|
||||
Workdir/reicast*
|
||||
Workdir/vmu*
|
||||
Workdir/webui*
|
||||
Workdir/emu.cfg
|
||||
Workdir/lib*ant.properties
|
||||
build/
|
||||
artifact/
|
||||
|
||||
# iOS General
|
||||
# macOS
|
||||
.DS_Store
|
||||
*/build/*
|
||||
**/build/*
|
||||
*.pbxuser
|
||||
!default.pbxuser
|
||||
*.mode1v3
|
||||
!default.mode1v3
|
||||
*.mode2v3
|
||||
!default.mode2v3
|
||||
*.perspectivev3
|
||||
!default.perspectivev3
|
||||
xcuserdata
|
||||
profile
|
||||
*.moved-aside
|
||||
DerivedData
|
||||
*.hmap
|
||||
emulator.xccheckout
|
||||
reicast.xccheckout
|
||||
build/*
|
||||
*.so
|
||||
*Karen_angelXwind*
|
||||
local.properties
|
||||
ant.properties
|
||||
*build_obj
|
||||
*.d
|
||||
Workdir/data
|
||||
Workdir/reicast*
|
||||
Workdir/vmu*
|
||||
Workdir/webui*
|
||||
Workdir/emu.cfg
|
||||
Workdir/lib*ant.properties
|
||||
reicast-ios.xccheckout
|
||||
|
||||
# Linux General
|
||||
shell/linux/.map
|
||||
shell/linux/flycast.elf.map
|
||||
shell/linux/nosym-flycast.elf
|
||||
shell/linux/flycast.elf
|
||||
shell/linux/dispframe.elf
|
||||
shell/apple/emulator-ios/OpenMP/OpenMP.xcframework
|
||||
|
||||
# Visual Studio
|
||||
generated
|
||||
.vs
|
||||
|
||||
# Android Studio
|
||||
*.iml
|
||||
shell/android-studio/.gradle/
|
||||
shell/android-studio/flycast/.cxx/
|
||||
shell/android-studio/flycast/build/
|
||||
shell/android-studio/flycast/local.properties
|
||||
.vs/
|
||||
.vscode/
|
||||
out/
|
||||
|
||||
# JetBrains IDES
|
||||
.idea/
|
||||
cmake-build-*/
|
||||
|
||||
# Dependencies from .gitmodules
|
||||
core/deps/breakpad/
|
||||
core/deps/glslang/
|
||||
+171
@@ -0,0 +1,171 @@
|
||||
# DESCRIPTION: GitLab CI/CD for libRetro (NOT FOR GitLab-proper)
|
||||
|
||||
##############################################################################
|
||||
################################# BOILERPLATE ################################
|
||||
##############################################################################
|
||||
|
||||
# Core definitions
|
||||
.core-defs:
|
||||
variables:
|
||||
GIT_SUBMODULE_STRATEGY: recursive
|
||||
CORENAME: flycast
|
||||
CORE_ARGS: -DLIBRETRO=ON -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
.core-defs-linux:
|
||||
extends: .core-defs
|
||||
variables:
|
||||
CORE_ARGS: -DLIBRETRO=ON -DCMAKE_POSITION_INDEPENDENT_CODE=TRUE -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
.core-defs-osx-x64:
|
||||
extends: .core-defs
|
||||
variables:
|
||||
CORE_ARGS: -DLIBRETRO=ON -G Xcode -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64
|
||||
EXTRA_PATH: Release
|
||||
|
||||
.core-defs-osx-arm64:
|
||||
extends: .core-defs
|
||||
variables:
|
||||
CORE_ARGS: -DLIBRETRO=ON -G Xcode -DCMAKE_BUILD_TYPE=Release
|
||||
EXTRA_PATH: Release
|
||||
|
||||
.core-defs-ios-arm64:
|
||||
extends: .core-defs
|
||||
variables:
|
||||
CORE_ARGS: -DLIBRETRO=ON -DCMAKE_BUILD_TYPE=Release
|
||||
|
||||
.core-defs-android:
|
||||
extends: .core-defs
|
||||
script:
|
||||
- cmake $CORE_ARGS -DANDROID_PLATFORM=android-$API_LEVEL -DCMAKE_TOOLCHAIN_FILE=$NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_STL=c++_static -DANDROID_ABI=$ANDROID_ABI -DANDROID_ARM_MODE=arm "$CMAKE_SOURCE_ROOT" -B$BUILD_DIR
|
||||
- cmake --build $BUILD_DIR --target ${CORENAME}_libretro --config Release -- -j $NUMPROC
|
||||
- mv $BUILD_DIR/${CORENAME}_libretro.so $LIBNAME
|
||||
- if [ $STRIP_CORE_LIB -eq 1 ]; then $NDK_ROOT/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-strip $LIBNAME; fi
|
||||
variables:
|
||||
API_LEVEL: 18
|
||||
|
||||
# Inclusion templates, required for the build to work
|
||||
include:
|
||||
################################## DESKTOPS ################################
|
||||
# Windows
|
||||
- project: 'libretro-infrastructure/ci-templates'
|
||||
file: '/windows-cmake-mingw.yml'
|
||||
|
||||
# MacOS
|
||||
- project: 'libretro-infrastructure/ci-templates'
|
||||
file: 'osx-cmake-x86.yml'
|
||||
|
||||
# MacOS arm64
|
||||
- project: 'libretro-infrastructure/ci-templates'
|
||||
file: 'osx-cmake-arm64.yml'
|
||||
|
||||
# Linux
|
||||
- project: 'libretro-infrastructure/ci-templates'
|
||||
file: '/linux-cmake.yml'
|
||||
|
||||
################################## CELLULAR ################################
|
||||
# Android
|
||||
- project: 'libretro-infrastructure/ci-templates'
|
||||
file: '/android-cmake.yml'
|
||||
|
||||
# iOS arm64
|
||||
- project: 'libretro-infrastructure/ci-templates'
|
||||
file: '/ios-cmake.yml'
|
||||
|
||||
################################## CONSOLES ################################
|
||||
# Nintendo Switch
|
||||
# - project: 'libretro-infrastructure/ci-templates'
|
||||
# file: '/libnx-static.yml'
|
||||
|
||||
# tvOS arm64
|
||||
- project: 'libretro-infrastructure/ci-templates'
|
||||
file: '/tvos-cmake.yml'
|
||||
|
||||
# Stages for building
|
||||
stages:
|
||||
- build-prepare
|
||||
- build-shared
|
||||
# - build-static
|
||||
|
||||
##############################################################################
|
||||
#################################### STAGES ##################################
|
||||
##############################################################################
|
||||
#
|
||||
################################### DESKTOPS #################################
|
||||
# Windows 64-bit
|
||||
libretro-build-windows-x64:
|
||||
extends:
|
||||
- .libretro-windows-cmake-x86_64
|
||||
- .core-defs
|
||||
|
||||
# Windows 32-bit
|
||||
libretro-build-windows-i686:
|
||||
extends:
|
||||
- .libretro-windows-cmake-x86
|
||||
- .core-defs
|
||||
|
||||
# Linux 64-bit
|
||||
libretro-build-linux-x64:
|
||||
extends:
|
||||
- .libretro-linux-cmake-x86_64
|
||||
- .core-defs-linux
|
||||
|
||||
# Linux 32-bit
|
||||
libretro-build-linux-i686:
|
||||
extends:
|
||||
- .libretro-linux-cmake-x86
|
||||
- .core-defs-linux
|
||||
|
||||
# MacOS 64-bit
|
||||
libretro-build-osx-x64:
|
||||
extends:
|
||||
- .libretro-osx-cmake-x86
|
||||
- .core-defs-osx-x64
|
||||
|
||||
# MacOS arm 64-bit
|
||||
libretro-build-osx-arm64:
|
||||
extends:
|
||||
- .libretro-osx-cmake-arm64
|
||||
- .core-defs-osx-arm64
|
||||
|
||||
################################### CELLULAR #################################
|
||||
# Android ARMv7a
|
||||
android-armeabi-v7a:
|
||||
extends:
|
||||
- .libretro-android-cmake-armeabi-v7a
|
||||
- .core-defs-android
|
||||
|
||||
# Android ARMv8a
|
||||
android-arm64-v8a:
|
||||
extends:
|
||||
- .libretro-android-cmake-arm64-v8a
|
||||
- .core-defs-android
|
||||
|
||||
# Android 64-bit x86
|
||||
android-x86_64:
|
||||
extends:
|
||||
- .libretro-android-cmake-x86_64
|
||||
- .core-defs-android
|
||||
|
||||
# Android 32-bit x86
|
||||
android-x86:
|
||||
extends:
|
||||
- .libretro-android-cmake-x86
|
||||
- .core-defs-android
|
||||
|
||||
libretro-build-ios-arm64:
|
||||
extends:
|
||||
- .libretro-ios-cmake-arm64
|
||||
- .core-defs-ios-arm64
|
||||
|
||||
################################### CONSOLES #################################
|
||||
# Nintendo Switch
|
||||
#libretro-build-libnx-aarch64:
|
||||
# extends:
|
||||
# - .libretro-libnx-static-retroarch-master
|
||||
# - .core-defs
|
||||
|
||||
# tvOS arm64
|
||||
libretro-build-tvos-arm64:
|
||||
extends:
|
||||
- .libretro-tvos-cmake-arm64
|
||||
- .core-defs-ios-arm64
|
||||
+25
@@ -4,3 +4,28 @@
|
||||
[submodule "core/deps/libchdr"]
|
||||
path = core/deps/libchdr
|
||||
url = https://github.com/rtissera/libchdr.git
|
||||
ignore = dirty
|
||||
[submodule "core/deps/luabridge"]
|
||||
path = core/deps/luabridge
|
||||
url = https://github.com/vinniefalco/LuaBridge.git
|
||||
[submodule "core/deps/breakpad"]
|
||||
path = core/deps/breakpad
|
||||
url = https://github.com/flyinghead/mingw-breakpad
|
||||
[submodule "core/deps/Vulkan-Headers"]
|
||||
path = core/deps/Vulkan-Headers
|
||||
url = https://github.com/KhronosGroup/Vulkan-Headers.git
|
||||
[submodule "core/deps/VulkanMemoryAllocator"]
|
||||
path = core/deps/VulkanMemoryAllocator
|
||||
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
|
||||
[submodule "core/deps/glslang"]
|
||||
path = core/deps/glslang
|
||||
url = https://github.com/KhronosGroup/glslang.git
|
||||
[submodule "core/deps/oboe"]
|
||||
path = core/deps/oboe
|
||||
url = https://github.com/google/oboe.git
|
||||
[submodule "core/deps/Syphon"]
|
||||
path = core/deps/Syphon
|
||||
url = https://github.com/vkedwardli/Syphon-Framework.git
|
||||
[submodule "core/deps/Spout"]
|
||||
path = core/deps/Spout
|
||||
url = https://github.com/vkedwardli/Spout2.git
|
||||
+1649
-796
File diff suppressed because it is too large.
Load diff
@@ -1,11 +1,14 @@
|
||||
# Flycast
|
||||
|
||||
[](https://github.com/flyinghead/flycast/actions/workflows/c-cpp.yml)
|
||||
[](https://github.com/flyinghead/flycast/actions/workflows/android.yml)
|
||||
[](https://github.com/flyinghead/flycast/actions/workflows/c-cpp.yml)
|
||||
[](https://github.com/flyinghead/flycast/actions/workflows/switch.yml)
|
||||
[](https://github.com/flyinghead/flycast/actions/workflows/uwp.yml)
|
||||
[](https://github.com/flyinghead/flycast/actions/workflows/bsd.yml)
|
||||
|
||||

|
||||
|
||||
**Flycast** is a multi-platform Sega Dreamcast, Naomi and Atomiswave emulator derived from [**reicast**](https://reicast.com/).
|
||||
**Flycast** is a multi-platform Sega Dreamcast, Naomi, Naomi 2, and Atomiswave emulator derived from [**reicast**](https://github.com/skmp/reicast-emulator).
|
||||
|
||||
Information about configuration and supported features can be found on [**TheArcadeStriker's flycast wiki**](https://github.com/TheArcadeStriker/flycast-wiki/wiki).
|
||||
|
||||
@@ -13,24 +16,45 @@ Join us on our [**Discord server**](https://discord.gg/X8YWP8w) for a chat.
|
||||
|
||||
## Install
|
||||
|
||||
### Flatpak
|
||||
### Flatpak (Linux )
|
||||
|
||||
1. [Set up Flatpak](https://www.flatpak.org/setup/)
|
||||
1. [Set up Flatpak](https://www.flatpak.org/setup/).
|
||||
|
||||
2. Install Flycast from [Flathub](https://flathub.org/apps/details/org.flycast.Flycast)
|
||||
2. Install Flycast from [Flathub](https://flathub.org/apps/details/org.flycast.Flycast):
|
||||
|
||||
`flatpak install -y org.flycast.Flycast`
|
||||
|
||||
3. Run Flycast
|
||||
3. Run Flycast:
|
||||
|
||||
`flatpak run org.flycast.Flycast`
|
||||
|
||||
### Binaries
|
||||
### Homebrew (MacOS )
|
||||
|
||||
Get fresh builds for your system [on the builds page](https://flyinghead.github.io/flycast-builds/).
|
||||
1. [Set up Homebrew](https://brew.sh).
|
||||
|
||||
**New:** Now automated test results are available as well.
|
||||
2. Install Flycast via Homebrew:
|
||||
|
||||
## Disclaimer
|
||||
`brew install --cask flycast`
|
||||
|
||||
All code contritbuted to this fork is *not* bound by the Individual Contributor License Agreement of the upstream repository (https://github.com/reicast/reicast-emulator) and shall *not* be considered as a contribution to the upstream repository.
|
||||
### Xbox One/Series 
|
||||
|
||||
Grab the latest build from [**the builds page**](https://flyinghead.github.io/flycast-builds/), or the [**GitHub Actions**](https://github.com/flyinghead/flycast/actions/workflows/uwp.yml). Then install it using the **Xbox Device Portal**.
|
||||
|
||||
### Binaries      
|
||||
|
||||
Get fresh builds for your system [**on the builds page**](https://flyinghead.github.io/flycast-builds/).
|
||||
|
||||
**New:** Now automated test results are available as well.
|
||||
|
||||
### Build instructions:
|
||||
`git clone https://github.com/flyinghead/flycast.git`
|
||||
|
||||
`cd flycast`
|
||||
|
||||
`git submodule update --init --recursive`
|
||||
|
||||
`mkdir build && cd build`
|
||||
|
||||
`cmake ..`
|
||||
|
||||
`make`
|
||||
+1
-3
@@ -7,12 +7,10 @@ Here lies the core of our codebase. Everything that's OS inspecific rests here.
|
||||
### Some rudimentary categories are:
|
||||
- hw -- DC Hardware Components Implementation
|
||||
- nullDC.cpp -- Main entry points
|
||||
- emitter -- x86 code emitter
|
||||
- khronos -- OpenGL and Vulkan headers
|
||||
- oslib -- Audio drivers
|
||||
- cfg -- Configuration backend structure
|
||||
- reios -- (Our) Implementation of the DreamCast BIOS
|
||||
- deps -- External dependencies
|
||||
- imgread -- Content drivers
|
||||
- rec-* -- Recompilers
|
||||
- rend -- OpenGL and Vulkan renderers
|
||||
- rend -- Graphics renderers and UI
|
||||
@@ -23,30 +23,20 @@
|
||||
#include "deps/lzma/7zCrc.h"
|
||||
#include "deps/lzma/Alloc.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#define kInputBufSize ((size_t)1 << 18)
|
||||
|
||||
static bool crc_tables_generated;
|
||||
|
||||
bool SzArchive::Open(const char* path)
|
||||
bool SzArchive::Open(FILE *file)
|
||||
{
|
||||
SzArEx_Init(&szarchive);
|
||||
|
||||
File_Close(&archiveStream.file);
|
||||
File_Construct(&archiveStream.file);
|
||||
#ifdef USE_WINDOWS_FILE
|
||||
nowide::wstackstring wpath;
|
||||
if (!wpath.convert(path))
|
||||
return false;
|
||||
archiveStream.file.handle = CreateFileW(wpath.c_str(),
|
||||
GENERIC_READ, FILE_SHARE_READ, NULL,
|
||||
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
|
||||
if (archiveStream.file.handle == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
#else
|
||||
archiveStream.file.file = nowide::fopen(path, "rb");
|
||||
if (archiveStream.file.file == nullptr)
|
||||
return false;
|
||||
#endif
|
||||
archiveStream.file.file = file;
|
||||
|
||||
FileInStream_CreateVTable(&archiveStream);
|
||||
LookToRead2_CreateVTable(&lookStream, 0);
|
||||
lookStream.buf = (Byte *)ISzAlloc_Alloc(&g_Alloc, kInputBufSize);
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "deps/lzma/7zFile.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
class SzArchive : public Archive
|
||||
{
|
||||
@@ -38,9 +39,10 @@ public:
|
||||
ArchiveFile* OpenFile(const char* name) override;
|
||||
ArchiveFile *OpenFileByCrc(u32 crc) override;
|
||||
|
||||
private:
|
||||
bool Open(const char* path) override;
|
||||
protected:
|
||||
bool Open(FILE *file) override;
|
||||
|
||||
private:
|
||||
CSzArEx szarchive;
|
||||
UInt32 block_idx; /* it can have any value before first call (if outBuffer = 0) */
|
||||
Byte *out_buffer; /* it must be 0 before first call for each new archive. */
|
||||
@@ -53,16 +55,21 @@ private:
|
||||
class SzArchiveFile : public ArchiveFile
|
||||
{
|
||||
public:
|
||||
SzArchiveFile(u8 *data, u32 offset, u32 length) : data(data), offset(offset), length(length) {}
|
||||
SzArchiveFile(u8 *data, u32 offset, u32 length)
|
||||
: data(data), offset(offset), _length(length) {}
|
||||
u32 Read(void *buffer, u32 length) override
|
||||
{
|
||||
length = std::min(length, this->length);
|
||||
length = std::min(length, this->_length);
|
||||
memcpy(buffer, data + offset, length);
|
||||
return length;
|
||||
}
|
||||
|
||||
size_t length() override {
|
||||
return _length;
|
||||
}
|
||||
|
||||
private:
|
||||
u8 *data;
|
||||
u32 offset;
|
||||
u32 length;
|
||||
u32 _length;
|
||||
};
|
||||
+50
-32
@@ -25,11 +25,8 @@ ZipArchive::~ZipArchive()
|
||||
zip_close(zip);
|
||||
}
|
||||
|
||||
bool ZipArchive::Open(const char* path)
|
||||
bool ZipArchive::Open(FILE *file)
|
||||
{
|
||||
FILE *file = nowide::fopen(path, "rb");
|
||||
if (file == nullptr)
|
||||
return false;
|
||||
zip_error_t error;
|
||||
zip_source_t *source = zip_source_filep_create(file, 0, -1, &error);
|
||||
if (source == nullptr)
|
||||
@@ -37,7 +34,7 @@ bool ZipArchive::Open(const char* path)
|
||||
std::fclose(file);
|
||||
return false;
|
||||
}
|
||||
zip = zip_open_from_source(source, 0, NULL);
|
||||
zip = zip_open_from_source(source, 0, nullptr);
|
||||
if (zip == nullptr)
|
||||
zip_source_free(source);
|
||||
return zip != nullptr;
|
||||
@@ -45,46 +42,67 @@ bool ZipArchive::Open(const char* path)
|
||||
|
||||
ArchiveFile* ZipArchive::OpenFile(const char* name)
|
||||
{
|
||||
zip_file *zip_file = zip_fopen(zip, name, 0);
|
||||
if (zip_file == NULL)
|
||||
return NULL;
|
||||
|
||||
return new ZipArchiveFile(zip_file);
|
||||
zip_file_t *zip_file = zip_fopen(zip, name, 0);
|
||||
if (zip_file == nullptr)
|
||||
return nullptr;
|
||||
zip_stat_t stat;
|
||||
zip_stat(zip, name, 0, &stat);
|
||||
return new ZipArchiveFile(zip_file, stat.size);
|
||||
}
|
||||
|
||||
struct zip_file *zip_fopen_by_crc(struct zip *za, u32 crc, int flags)
|
||||
static zip_file *zip_fopen_by_crc(zip_t *za, u32 crc, int flags, zip_uint64_t& index)
|
||||
{
|
||||
int i, n;
|
||||
struct zip_stat stat;
|
||||
if (crc == 0)
|
||||
return nullptr;
|
||||
|
||||
if (crc == 0) {
|
||||
return NULL;
|
||||
}
|
||||
zip_int64_t n = zip_get_num_entries(za, 0);
|
||||
for (index = 0; index < (zip_uint64_t)n; index++)
|
||||
{
|
||||
zip_stat_t stat;
|
||||
if (zip_stat_index(za, index, flags, &stat) < -1)
|
||||
return nullptr;
|
||||
if (stat.crc == crc)
|
||||
return zip_fopen_index(za, index, flags);
|
||||
}
|
||||
|
||||
n = zip_get_num_files(za);
|
||||
for (i = 0; i < n; i++) {
|
||||
if (zip_stat_index(za, i, flags, &stat) < -1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (stat.crc == crc) {
|
||||
return zip_fopen_index(za, i, flags);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ArchiveFile* ZipArchive::OpenFileByCrc(u32 crc)
|
||||
{
|
||||
zip_file *zip_file = zip_fopen_by_crc(zip, crc, 0);
|
||||
if (zip_file == NULL)
|
||||
return NULL;
|
||||
zip_uint64_t index;
|
||||
zip_file_t *zip_file = zip_fopen_by_crc(zip, crc, 0, index);
|
||||
if (zip_file == nullptr)
|
||||
return nullptr;
|
||||
zip_stat_t stat;
|
||||
zip_stat_index(zip, index, 0, &stat);
|
||||
|
||||
return new ZipArchiveFile(zip_file);
|
||||
return new ZipArchiveFile(zip_file, stat.size);
|
||||
}
|
||||
|
||||
u32 ZipArchiveFile::Read(void* buffer, u32 length)
|
||||
{
|
||||
return zip_fread(zip_file, buffer, length);
|
||||
}
|
||||
|
||||
bool ZipArchive::Open(const void *data, size_t size)
|
||||
{
|
||||
zip_error_t error;
|
||||
zip_source_t *source = zip_source_buffer_create(data, size, 0, &error);
|
||||
if (source == nullptr)
|
||||
return false;
|
||||
zip = zip_open_from_source(source, 0, nullptr);
|
||||
if (zip == nullptr)
|
||||
zip_source_free(source);
|
||||
return zip != nullptr;
|
||||
}
|
||||
|
||||
ArchiveFile *ZipArchive::OpenFirstFile()
|
||||
{
|
||||
zip_file_t *zipFile = zip_fopen_index(zip, 0, 0);
|
||||
if (zipFile == nullptr)
|
||||
return nullptr;
|
||||
zip_stat_t stat;
|
||||
zip_stat_index(zip, 0, 0, &stat);
|
||||
return new ZipArchiveFile(zipFile, stat.size);
|
||||
}
|
||||
@@ -26,25 +26,35 @@
|
||||
class ZipArchive : public Archive
|
||||
{
|
||||
public:
|
||||
ZipArchive() : zip(NULL) {}
|
||||
~ZipArchive() override;
|
||||
|
||||
ArchiveFile* OpenFile(const char* name) override;
|
||||
ArchiveFile* OpenFileByCrc(u32 crc) override;
|
||||
|
||||
private:
|
||||
bool Open(const char* path) override;
|
||||
bool Open(const void *data, size_t size);
|
||||
ArchiveFile *OpenFirstFile();
|
||||
|
||||
struct zip *zip;
|
||||
protected:
|
||||
bool Open(FILE *file) override;
|
||||
|
||||
private:
|
||||
zip_t *zip = nullptr;
|
||||
};
|
||||
|
||||
class ZipArchiveFile : public ArchiveFile
|
||||
{
|
||||
public:
|
||||
ZipArchiveFile(struct zip_file *zip_file) : zip_file(zip_file) {}
|
||||
~ZipArchiveFile() override { zip_fclose(zip_file); }
|
||||
ZipArchiveFile(zip_file_t *zip_file, size_t length)
|
||||
: zip_file(zip_file), _length(length) {}
|
||||
~ZipArchiveFile() override {
|
||||
zip_fclose(zip_file);
|
||||
}
|
||||
u32 Read(void* buffer, u32 length) override;
|
||||
size_t length() override {
|
||||
return _length;
|
||||
}
|
||||
|
||||
private:
|
||||
struct zip_file *zip_file;
|
||||
zip_file_t *zip_file;
|
||||
size_t _length;
|
||||
};
|
||||
+49
-12
@@ -22,24 +22,61 @@
|
||||
#include "archive.h"
|
||||
#include "7zArchive.h"
|
||||
#include "ZipArchive.h"
|
||||
#include "oslib/storage.h"
|
||||
|
||||
Archive *OpenArchive(const char *path)
|
||||
Archive *OpenArchive(const std::string& path)
|
||||
{
|
||||
std::string base_path(path);
|
||||
|
||||
Archive *sz_archive = new SzArchive();
|
||||
if (sz_archive->Open(base_path.c_str()) || sz_archive->Open((base_path + ".7z").c_str()) || sz_archive->Open((base_path + ".7Z").c_str()))
|
||||
return sz_archive;
|
||||
delete sz_archive;
|
||||
|
||||
FILE *file = nullptr;
|
||||
hostfs::FileInfo fileInfo;
|
||||
try {
|
||||
fileInfo = hostfs::storage().getFileInfo(path);
|
||||
if (!fileInfo.isDirectory)
|
||||
file = hostfs::storage().openFile(path, "rb");
|
||||
} catch (const hostfs::StorageException& e) {
|
||||
}
|
||||
if (file == nullptr)
|
||||
{
|
||||
file = hostfs::storage().openFile(path + ".7z", "rb");
|
||||
if (file == nullptr)
|
||||
file = hostfs::storage().openFile(path + ".7Z", "rb");
|
||||
}
|
||||
if (file != nullptr)
|
||||
{
|
||||
Archive *sz_archive = new SzArchive();
|
||||
if (sz_archive->Open(file))
|
||||
return sz_archive;
|
||||
delete sz_archive;
|
||||
file = nullptr;
|
||||
}
|
||||
// Retry as a zip file
|
||||
try {
|
||||
if (!fileInfo.isDirectory)
|
||||
file = hostfs::storage().openFile(path, "rb");
|
||||
} catch (const hostfs::StorageException& e) {
|
||||
}
|
||||
if (file == nullptr)
|
||||
{
|
||||
file = hostfs::storage().openFile(path + ".zip", "rb");
|
||||
if (file == nullptr)
|
||||
{
|
||||
file = hostfs::storage().openFile(path + ".ZIP", "rb");
|
||||
if (file == nullptr)
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
Archive *zip_archive = new ZipArchive();
|
||||
if (zip_archive->Open(base_path.c_str()) || zip_archive->Open((base_path + ".zip").c_str()) || zip_archive->Open((base_path + ".ZIP").c_str()))
|
||||
if (zip_archive->Open(file))
|
||||
return zip_archive;
|
||||
delete zip_archive;
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool Archive::Open(const char* path)
|
||||
{
|
||||
FILE *file = nowide::fopen(path, "rb");
|
||||
if (file == nullptr)
|
||||
return false;
|
||||
return Open(file);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ class ArchiveFile
|
||||
public:
|
||||
virtual ~ArchiveFile() = default;
|
||||
virtual u32 Read(void *buffer, u32 length) = 0;
|
||||
virtual size_t length() = 0;
|
||||
};
|
||||
|
||||
class Archive
|
||||
@@ -36,10 +37,13 @@ public:
|
||||
virtual ArchiveFile *OpenFile(const char *name) = 0;
|
||||
virtual ArchiveFile *OpenFileByCrc(u32 crc) = 0;
|
||||
|
||||
friend Archive *OpenArchive(const char *path);
|
||||
protected:
|
||||
virtual bool Open(FILE *file) = 0;
|
||||
|
||||
private:
|
||||
virtual bool Open(const char *name) = 0;
|
||||
bool Open(const char *name);
|
||||
|
||||
friend Archive *OpenArchive(const std::string& path);
|
||||
};
|
||||
|
||||
Archive *OpenArchive(const char *path);
|
||||
Archive *OpenArchive(const std::string& path);
|
||||
+29
-7
@@ -19,11 +19,14 @@
|
||||
#include "rzip.h"
|
||||
#include <zlib.h>
|
||||
|
||||
#include <cstring>
|
||||
|
||||
const u8 RZipHeader[8] = { '#', 'R', 'Z', 'I', 'P', 'v', 1, '#' };
|
||||
|
||||
bool RZipFile::Open(const std::string& path, bool write)
|
||||
{
|
||||
verify(file == nullptr);
|
||||
this->write = write;
|
||||
|
||||
file = nowide::fopen(path.c_str(), write ? "wb" : "rb");
|
||||
if (file == nullptr)
|
||||
@@ -39,10 +42,27 @@ bool RZipFile::Open(const std::string& path, bool write)
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
// savestates created on 32-bit platforms used to have a 32-bit size
|
||||
if (size >> 32 != 0)
|
||||
{
|
||||
size &= 0xffffffff;
|
||||
std::fseek(file, -4, SEEK_CUR);
|
||||
}
|
||||
chunk = new u8[maxChunkSize];
|
||||
chunkIndex = 0;
|
||||
chunkSize = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
maxChunkSize = 1_MB;
|
||||
if (std::fwrite(RZipHeader, sizeof(RZipHeader), 1, file) != 1
|
||||
|| std::fwrite(&maxChunkSize, sizeof(maxChunkSize), 1, file) != 1
|
||||
|| std::fwrite(&size, sizeof(size), 1, file) != 1)
|
||||
{
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -51,6 +71,11 @@ void RZipFile::Close()
|
||||
{
|
||||
if (file != nullptr)
|
||||
{
|
||||
if (write)
|
||||
{
|
||||
std::fseek(file, sizeof(RZipHeader) + sizeof(maxChunkSize), SEEK_SET);
|
||||
std::fwrite(&size, sizeof(size), 1, file);
|
||||
}
|
||||
std::fclose(file);
|
||||
file = nullptr;
|
||||
if (chunk != nullptr)
|
||||
@@ -64,6 +89,7 @@ void RZipFile::Close()
|
||||
size_t RZipFile::Read(void *data, size_t length)
|
||||
{
|
||||
verify(file != nullptr);
|
||||
verify(!write);
|
||||
|
||||
u8 *p = (u8 *)data;
|
||||
size_t rv = 0;
|
||||
@@ -93,7 +119,7 @@ size_t RZipFile::Read(void *data, size_t length)
|
||||
delete [] zipped;
|
||||
chunkSize = (u32)tl;
|
||||
}
|
||||
u32 l = std::min(chunkSize - chunkIndex, (u32)length);
|
||||
u32 l = std::min(chunkSize - chunkIndex, (u32)(length - rv));
|
||||
memcpy(p, chunk + chunkIndex, l);
|
||||
p += l;
|
||||
chunkIndex += l;
|
||||
@@ -106,13 +132,9 @@ size_t RZipFile::Read(void *data, size_t length)
|
||||
size_t RZipFile::Write(const void *data, size_t length)
|
||||
{
|
||||
verify(file != nullptr);
|
||||
verify(std::ftell(file) == 0);
|
||||
verify(write);
|
||||
|
||||
maxChunkSize = 1024 * 1024;
|
||||
if (std::fwrite(RZipHeader, sizeof(RZipHeader), 1, file) != 1
|
||||
|| std::fwrite(&maxChunkSize, sizeof(maxChunkSize), 1, file) != 1
|
||||
|| std::fwrite(&length, sizeof(length), 1, file) != 1)
|
||||
return 0;
|
||||
size += length;
|
||||
const u8 *p = (const u8 *)data;
|
||||
// compression output buffer must be 0.1% larger + 12 bytes
|
||||
uLongf maxZippedSize = maxChunkSize + maxChunkSize / 1000 + 12;
|
||||
|
||||
+3
-1
@@ -32,12 +32,14 @@ public:
|
||||
size_t Size() const { return size; }
|
||||
size_t Read(void *data, size_t length);
|
||||
size_t Write(const void *data, size_t length);
|
||||
FILE *rawFile() const { return file; }
|
||||
|
||||
private:
|
||||
FILE *file = nullptr;
|
||||
size_t size = 0;
|
||||
u64 size = 0;
|
||||
u32 maxChunkSize = 0;
|
||||
u8 *chunk = nullptr;
|
||||
u32 chunkSize = 0;
|
||||
u32 chunkIndex = 0;
|
||||
bool write = false;
|
||||
};
|
||||
@@ -0,0 +1,358 @@
|
||||
#if USE_ALSA
|
||||
#include "audiostream.h"
|
||||
#include <alsa/asoundlib.h>
|
||||
#include "cfg/cfg.h"
|
||||
#include "cfg/option.h"
|
||||
|
||||
class AlsaAudioBackend : public AudioBackend
|
||||
{
|
||||
snd_pcm_t *handle = nullptr;
|
||||
bool pcm_blocking = true;
|
||||
snd_pcm_uframes_t buffer_size = 0;
|
||||
snd_pcm_uframes_t period_size = 0;
|
||||
snd_pcm_t *handle_record = nullptr;
|
||||
|
||||
public:
|
||||
AlsaAudioBackend()
|
||||
: AudioBackend("alsa", "Advanced Linux Sound Architecture") {}
|
||||
|
||||
bool init() override
|
||||
{
|
||||
snd_pcm_hw_params_t *params;
|
||||
|
||||
std::string device = cfgLoadStr("alsa", "device", "");
|
||||
|
||||
int rc = -1;
|
||||
if (!device.empty() && device != "auto") {
|
||||
rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0);
|
||||
if (rc < 0)
|
||||
WARN_LOG(AUDIO, "ALSA: Cannot open device %s. Trying auto", device.c_str());
|
||||
}
|
||||
if (rc < 0)
|
||||
{
|
||||
INFO_LOG(AUDIO, "ALSA: trying to determine audio device");
|
||||
|
||||
// trying default device
|
||||
device = "default";
|
||||
rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0);
|
||||
|
||||
// "default" didn't work, try first device
|
||||
if (rc < 0)
|
||||
{
|
||||
device = "plughw:0,0,0";
|
||||
rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0);
|
||||
|
||||
if (rc < 0)
|
||||
{
|
||||
device = "plughw:0,0";
|
||||
rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// first didn't work, try second
|
||||
if (rc < 0)
|
||||
{
|
||||
device = "plughw:1,0";
|
||||
rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0);
|
||||
}
|
||||
|
||||
// try pulse audio backend
|
||||
if (rc < 0)
|
||||
{
|
||||
device = "pulse";
|
||||
rc = snd_pcm_open(&handle, device.c_str(), SND_PCM_STREAM_PLAYBACK, 0);
|
||||
}
|
||||
|
||||
if (rc < 0)
|
||||
INFO_LOG(AUDIO, "ALSA: unable to automatically determine audio device.");
|
||||
}
|
||||
|
||||
if (rc < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: unable to open PCM device %s: %s", device.c_str(), snd_strerror(rc));
|
||||
return false;
|
||||
}
|
||||
|
||||
INFO_LOG(AUDIO, "ALSA: Successfully initialized \"%s\"", device.c_str());
|
||||
|
||||
/* Allocate a hardware parameters object. */
|
||||
snd_pcm_hw_params_alloca(¶ms);
|
||||
|
||||
/* Fill it in with default values. */
|
||||
rc=snd_pcm_hw_params_any(handle, params);
|
||||
if (rc < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Error:snd_pcm_hw_params_any %s", snd_strerror(rc));
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Set the desired hardware parameters. */
|
||||
|
||||
/* Interleaved mode */
|
||||
rc=snd_pcm_hw_params_set_access(handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
if (rc < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Error:snd_pcm_hw_params_set_access %s", snd_strerror(rc));
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Signed 16-bit little-endian format */
|
||||
rc=snd_pcm_hw_params_set_format(handle, params, SND_PCM_FORMAT_S16_LE);
|
||||
if (rc < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Error:snd_pcm_hw_params_set_format %s", snd_strerror(rc));
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Two channels (stereo) */
|
||||
rc=snd_pcm_hw_params_set_channels(handle, params, 2);
|
||||
if (rc < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Error:snd_pcm_hw_params_set_channels %s", snd_strerror(rc));
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
|
||||
// 44100 samples/second
|
||||
rc = snd_pcm_hw_params_set_rate(handle, params, 44100, 0);
|
||||
if (rc < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Error:snd_pcm_hw_params_set_rate %s", snd_strerror(rc));
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Period size (512)
|
||||
period_size = std::min(SAMPLE_COUNT, (u32)config::AudioBufferSize / 4);
|
||||
rc = snd_pcm_hw_params_set_period_size_near(handle, params, &period_size, nullptr);
|
||||
if (rc < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Error:snd_pcm_hw_params_set_periods_near %s", snd_strerror(rc));
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
INFO_LOG(AUDIO, "ALSA: period size set to %zd", (size_t)period_size);
|
||||
|
||||
// Sample buffer size
|
||||
buffer_size = config::AudioBufferSize;
|
||||
rc = snd_pcm_hw_params_set_buffer_size_near(handle, params, &buffer_size);
|
||||
if (rc < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Error:snd_pcm_hw_params_set_buffer_size_near %s", snd_strerror(rc));
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
INFO_LOG(AUDIO, "ALSA: buffer size set to %ld", buffer_size);
|
||||
|
||||
/* Write the parameters to the driver */
|
||||
rc = snd_pcm_hw_params(handle, params);
|
||||
if (rc < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Unable to set hw parameters: %s", snd_strerror(rc));
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool initRecord(u32 sampling_freq) override
|
||||
{
|
||||
int err;
|
||||
if ((err = snd_pcm_open(&handle_record, "default", SND_PCM_STREAM_CAPTURE, 0)) < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Cannot open default audio capture device: %s", snd_strerror(err));
|
||||
return false;
|
||||
}
|
||||
snd_pcm_hw_params_t *hw_params;
|
||||
if ((err = snd_pcm_hw_params_malloc(&hw_params)) < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Cannot allocate hardware parameter structure: %s", snd_strerror(err));
|
||||
snd_pcm_close(handle_record);
|
||||
return false;
|
||||
}
|
||||
if ((err = snd_pcm_hw_params_any(handle_record, hw_params)) < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Cannot initialize hardware parameter structure: %s", snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
snd_pcm_close(handle_record);
|
||||
return false;
|
||||
}
|
||||
if ((err = snd_pcm_hw_params_set_access(handle_record, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Cannot set access type: %s\n", snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
snd_pcm_close(handle_record);
|
||||
return false;
|
||||
}
|
||||
if ((err = snd_pcm_hw_params_set_format(handle_record, hw_params, SND_PCM_FORMAT_S16_LE)) < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Cannot set sample format: %s", snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
snd_pcm_close(handle_record);
|
||||
return false;
|
||||
}
|
||||
if ((err = snd_pcm_hw_params_set_rate(handle_record, hw_params, sampling_freq, 0)) < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Cannot set sample rate to %d Hz: %s", sampling_freq, snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
snd_pcm_close(handle_record);
|
||||
return false;
|
||||
}
|
||||
if ((err = snd_pcm_hw_params_set_channels(handle_record, hw_params, 1)) < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Cannot set channel count: %s", snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
snd_pcm_close(handle_record);
|
||||
return false;
|
||||
}
|
||||
if ((err = snd_pcm_hw_params(handle_record, hw_params)) < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Cannot set parameters: %s", snd_strerror(err));
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
snd_pcm_close(handle_record);
|
||||
return false;
|
||||
}
|
||||
snd_pcm_hw_params_free(hw_params);
|
||||
snd_pcm_nonblock(handle_record, 1);
|
||||
if ((err = snd_pcm_prepare(handle_record)) < 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "ALSA: Cannot prepare device: %s", snd_strerror(err));
|
||||
snd_pcm_close(handle_record);
|
||||
return false;
|
||||
}
|
||||
INFO_LOG(AUDIO, "ALSA: Successfully initialized capture device");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void termRecord() override
|
||||
{
|
||||
snd_pcm_close(handle_record);
|
||||
}
|
||||
|
||||
u32 record(void* frame, u32 samples) override
|
||||
{
|
||||
int err = snd_pcm_readi(handle_record, frame, samples);
|
||||
if (err < (int)samples)
|
||||
{
|
||||
if (err < 0)
|
||||
{
|
||||
DEBUG_LOG(AUDIO, "ALSA: Recording error: %s", snd_strerror(err));
|
||||
err = 0;
|
||||
err = snd_pcm_prepare(handle_record);
|
||||
}
|
||||
u8 *buffer = (u8 *)frame + err;
|
||||
memset(buffer, 0, (samples - err) * 2);
|
||||
}
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
u32 push(const void* frame, u32 samples, bool wait) override
|
||||
{
|
||||
if (wait != pcm_blocking) {
|
||||
snd_pcm_nonblock(handle, wait ? 0 : 1);
|
||||
pcm_blocking = wait;
|
||||
}
|
||||
|
||||
int rc = snd_pcm_writei(handle, frame, samples);
|
||||
if (rc < 0)
|
||||
{
|
||||
snd_pcm_recover(handle, rc, 1);
|
||||
if (rc == -EPIPE)
|
||||
{
|
||||
// EPIPE means underrun
|
||||
// Write some silence then our samples
|
||||
const size_t silence_size = buffer_size - samples;
|
||||
void *silence = alloca(silence_size * 4);
|
||||
memset(silence, 0, silence_size * 4);
|
||||
snd_pcm_writei(handle, silence, silence_size);
|
||||
snd_pcm_writei(handle, frame, samples);
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void term() override
|
||||
{
|
||||
snd_pcm_drop(handle);
|
||||
snd_pcm_close(handle);
|
||||
}
|
||||
|
||||
std::vector<std::string> getDeviceList()
|
||||
{
|
||||
std::vector<std::string> result;
|
||||
|
||||
char **hints;
|
||||
int err = snd_device_name_hint(-1, "pcm", (void***)&hints);
|
||||
|
||||
// Error initializing ALSA
|
||||
if (err != 0)
|
||||
return result;
|
||||
|
||||
// special value to automatically detect on initialization
|
||||
result.emplace_back("auto");
|
||||
|
||||
char** n = hints;
|
||||
while (*n != NULL)
|
||||
{
|
||||
// Get the type (NULL/Input/Output)
|
||||
char *type = snd_device_name_get_hint(*n, "IOID");
|
||||
char *name = snd_device_name_get_hint(*n, "NAME");
|
||||
|
||||
if (name != NULL)
|
||||
{
|
||||
// We only want output or special devices (like "default" or "pulse")
|
||||
// TODO Only those with type == NULL?
|
||||
if (type == NULL || strcmp(type, "Output") == 0)
|
||||
{
|
||||
// TODO Check if device works (however we need to hash the resulting list then)
|
||||
/*snd_pcm_t *handle;
|
||||
int rc = snd_pcm_open(&handle, name, SND_PCM_STREAM_PLAYBACK, 0);
|
||||
|
||||
if (rc == 0)
|
||||
{
|
||||
result.push_back(name);
|
||||
snd_pcm_close(handle);
|
||||
}
|
||||
*/
|
||||
|
||||
result.emplace_back(name);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (type != NULL)
|
||||
free(type);
|
||||
|
||||
if (name != NULL)
|
||||
free(name);
|
||||
|
||||
n++;
|
||||
}
|
||||
|
||||
snd_device_name_free_hint((void**)hints);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
Option* getOptions(int *count) override
|
||||
{
|
||||
*count = 1;
|
||||
static Option result;
|
||||
|
||||
result.name = "device";
|
||||
result.caption = "Device";
|
||||
result.type = Option::list;
|
||||
result.values = getDeviceList();
|
||||
|
||||
return &result;
|
||||
}
|
||||
};
|
||||
static AlsaAudioBackend alsaBackend;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,308 @@
|
||||
/*
|
||||
Simple Core Audio backend for osx (and maybe ios?)
|
||||
Based off various audio core samples and dolphin's code
|
||||
|
||||
This is part of the Reicast project, please consult the
|
||||
LICENSE file for licensing & related information
|
||||
|
||||
This could do with some locking logic to avoid
|
||||
race conditions, and some variable length buffer
|
||||
logic to support chunk sizes other than 512 bytes
|
||||
|
||||
It does work on my macmini though
|
||||
*/
|
||||
#if defined(__APPLE__)
|
||||
#include "audiostream.h"
|
||||
#include "cfg/option.h"
|
||||
#include "stdclass.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <AudioUnit/AudioUnit.h>
|
||||
#include <AudioToolbox/AudioQueue.h>
|
||||
|
||||
class CoreAudioBackend : public AudioBackend
|
||||
{
|
||||
AudioUnit audioUnit;
|
||||
|
||||
u32 BUFSIZE = 0;
|
||||
u8 *samples_temp = nullptr;
|
||||
|
||||
std::atomic<int> samples_wptr;
|
||||
std::atomic<int> samples_rptr;
|
||||
cResetEvent bufferEmpty;
|
||||
|
||||
// input buffer and indexes
|
||||
u8 samples_input[2400];
|
||||
static constexpr size_t InputBufSize = sizeof(samples_input);
|
||||
std::atomic<int> input_wptr;
|
||||
std::atomic<int> input_rptr;
|
||||
AudioQueueRef recordQueue;
|
||||
|
||||
static OSStatus renderCallback(void* ctx, AudioUnitRenderActionFlags* flags, const AudioTimeStamp* ts,
|
||||
UInt32 bus, UInt32 frames, AudioBufferList* abl)
|
||||
{
|
||||
CoreAudioBackend *backend = (CoreAudioBackend *)ctx;
|
||||
for (int i = 0; i < abl->mNumberBuffers; i++)
|
||||
{
|
||||
int size = abl->mBuffers[i].mDataByteSize;
|
||||
u8 *outBuffer = (u8 *)abl->mBuffers[i].mData;
|
||||
while (size != 0)
|
||||
{
|
||||
int avail = (backend->samples_wptr - backend->samples_rptr + backend->BUFSIZE) % backend->BUFSIZE;
|
||||
if (avail == 0)
|
||||
{
|
||||
//printf("Core Audio: buffer underrun %d bytes (%d)", size, abl->mBuffers[i].mDataByteSize);
|
||||
memset(outBuffer, '\0', size);
|
||||
return noErr;
|
||||
}
|
||||
avail = std::min(avail, size);
|
||||
avail = std::min(avail, (int)backend->BUFSIZE - backend->samples_rptr);
|
||||
memcpy(outBuffer, backend->samples_temp + backend->samples_rptr, avail);
|
||||
backend->samples_rptr = (backend->samples_rptr + avail) % backend->BUFSIZE;
|
||||
size -= avail;
|
||||
outBuffer += avail;
|
||||
// Set the mutex to allow writing
|
||||
backend->bufferEmpty.Set();
|
||||
}
|
||||
}
|
||||
|
||||
return noErr;
|
||||
}
|
||||
|
||||
public:
|
||||
CoreAudioBackend()
|
||||
: AudioBackend("coreaudio", "Core Audio") {}
|
||||
|
||||
bool init() override
|
||||
{
|
||||
OSStatus err;
|
||||
AURenderCallbackStruct callback_struct;
|
||||
AudioStreamBasicDescription format;
|
||||
AudioComponentDescription desc;
|
||||
AudioComponent component;
|
||||
|
||||
desc.componentType = kAudioUnitType_Output;
|
||||
#if !defined(TARGET_IPHONE)
|
||||
desc.componentSubType = kAudioUnitSubType_DefaultOutput;
|
||||
#else
|
||||
desc.componentSubType = kAudioUnitSubType_RemoteIO;
|
||||
#endif
|
||||
desc.componentFlags = 0;
|
||||
desc.componentFlagsMask = 0;
|
||||
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
|
||||
component = AudioComponentFindNext(nullptr, &desc);
|
||||
|
||||
if (component == nullptr) {
|
||||
ERROR_LOG(AUDIO, "coreaudio: AudioComponentFindNext failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
err = AudioComponentInstanceNew(component, &audioUnit);
|
||||
if (err != noErr) {
|
||||
ERROR_LOG(AUDIO, "coreaudio: AudioComponentInstanceNew failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
FillOutASBDForLPCM(format, 44100,
|
||||
2, 16, 16, false, false, false);
|
||||
err = AudioUnitSetProperty(audioUnit,
|
||||
kAudioUnitProperty_StreamFormat,
|
||||
kAudioUnitScope_Input, 0, &format,
|
||||
sizeof(AudioStreamBasicDescription));
|
||||
if (err != noErr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "coreaudio: AudioUnitSetProperty(kAudioUnitProperty_StreamFormat) failed");
|
||||
AudioComponentInstanceDispose(audioUnit);
|
||||
return false;
|
||||
}
|
||||
|
||||
callback_struct.inputProc = renderCallback;
|
||||
callback_struct.inputProcRefCon = this;
|
||||
err = AudioUnitSetProperty(audioUnit,
|
||||
kAudioUnitProperty_SetRenderCallback,
|
||||
kAudioUnitScope_Input, 0, &callback_struct,
|
||||
sizeof callback_struct);
|
||||
if (err != noErr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "coreaudio: AudioUnitSetProperty(kAudioUnitProperty_SetRenderCallback) failed");
|
||||
AudioComponentInstanceDispose(audioUnit);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
err = AudioUnitSetParameter(audioUnit,
|
||||
kHALOutputParam_Volume,
|
||||
kAudioUnitParameterFlag_Output, 0,
|
||||
1, 0);
|
||||
verify(err == noErr);
|
||||
*/
|
||||
|
||||
err = AudioUnitInitialize(audioUnit);
|
||||
if (err != noErr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "coreaudio: AudioUnitInitialize failed");
|
||||
AudioComponentInstanceDispose(audioUnit);
|
||||
return false;
|
||||
}
|
||||
|
||||
BUFSIZE = config::AudioBufferSize * 4;
|
||||
samples_temp = new u8[BUFSIZE]();
|
||||
samples_rptr = 0;
|
||||
samples_wptr = 0;
|
||||
|
||||
err = AudioOutputUnitStart(audioUnit);
|
||||
if (err != noErr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "coreaudio: AudioOutputUnitStart failed");
|
||||
AudioUnitUninitialize(audioUnit);
|
||||
AudioComponentInstanceDispose(audioUnit);
|
||||
return false;
|
||||
}
|
||||
|
||||
bufferEmpty.Set();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 push(const void* frame, u32 samples, bool wait) override
|
||||
{
|
||||
int size = samples * 4;
|
||||
while (size != 0)
|
||||
{
|
||||
int avail = (samples_rptr - samples_wptr - 4 + BUFSIZE) % BUFSIZE;
|
||||
if (avail == 0)
|
||||
{
|
||||
if (!wait)
|
||||
break;
|
||||
bufferEmpty.Wait();
|
||||
continue;
|
||||
}
|
||||
avail = std::min(avail, size);
|
||||
avail = std::min(avail, (int)BUFSIZE - samples_wptr);
|
||||
memcpy(&samples_temp[samples_wptr], frame, avail);
|
||||
samples_wptr = (samples_wptr + avail) % BUFSIZE;
|
||||
frame = (u8 *)frame + avail;
|
||||
size -= avail;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void term() override
|
||||
{
|
||||
AudioOutputUnitStop(audioUnit);
|
||||
AudioUnitUninitialize(audioUnit);
|
||||
AudioComponentInstanceDispose(audioUnit);
|
||||
bufferEmpty.Set();
|
||||
delete [] samples_temp;
|
||||
samples_temp = nullptr;
|
||||
}
|
||||
|
||||
static void recordCallback(void *inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer,
|
||||
const AudioTimeStamp *inStartTime, UInt32 frameSize, const AudioStreamPacketDescription *dataFormat)
|
||||
{
|
||||
//DEBUG_LOG(AUDIO, "AudioQueue callback: wptr %d rptr %d bytes %d", (int)input_wptr, (int)input_rptr, inBuffer->mAudioDataByteSize);
|
||||
CoreAudioBackend *backend = (CoreAudioBackend *)inUserData;
|
||||
UInt32 size = inBuffer->mAudioDataByteSize;
|
||||
UInt32 freeSpace = (backend->input_rptr - backend->input_wptr - 2 + InputBufSize) % InputBufSize;
|
||||
if (size > freeSpace)
|
||||
{
|
||||
DEBUG_LOG(AUDIO, "coreaudio: record overrun %d bytes", size - freeSpace);
|
||||
size = freeSpace;
|
||||
}
|
||||
while (size != 0)
|
||||
{
|
||||
UInt32 chunk = std::min(size, (UInt32)(InputBufSize - backend->input_wptr));
|
||||
memcpy(backend->samples_input + backend->input_wptr, inBuffer->mAudioData, chunk);
|
||||
backend->input_wptr = (backend->input_wptr + chunk) % InputBufSize;
|
||||
size -= chunk;
|
||||
}
|
||||
AudioQueueEnqueueBuffer(backend->recordQueue, inBuffer, 0, nullptr);
|
||||
}
|
||||
|
||||
void termRecord() override
|
||||
{
|
||||
if (recordQueue != nullptr)
|
||||
{
|
||||
AudioQueueStop(recordQueue, true);
|
||||
AudioQueueDispose(recordQueue, true);
|
||||
recordQueue = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
bool initRecord(u32 sampling_freq) override
|
||||
{
|
||||
AudioStreamBasicDescription desc{};
|
||||
desc.mFormatID = kAudioFormatLinearPCM;
|
||||
desc.mSampleRate = (double)sampling_freq;
|
||||
desc.mChannelsPerFrame = 1;
|
||||
desc.mBitsPerChannel = 16;
|
||||
desc.mBytesPerPacket = desc.mBytesPerFrame = 2;
|
||||
desc.mFramesPerPacket = 1;
|
||||
desc.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger | kLinearPCMFormatFlagIsPacked;
|
||||
desc.mReserved = 0;
|
||||
|
||||
OSStatus err = AudioQueueNewInput(&desc,
|
||||
recordCallback,
|
||||
this,
|
||||
nullptr,
|
||||
kCFRunLoopCommonModes,
|
||||
0,
|
||||
&recordQueue);
|
||||
if (err != noErr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "AudioQueueNewInput failed: %d", err);
|
||||
return false;
|
||||
}
|
||||
|
||||
AudioQueueBufferRef buffers[2];
|
||||
for (UInt32 i = 0; i < std::size(buffers) && err == noErr; i++)
|
||||
{
|
||||
err = AudioQueueAllocateBuffer(recordQueue, 480, &buffers[i]);
|
||||
if (err == noErr)
|
||||
err = AudioQueueEnqueueBuffer(recordQueue, buffers[i], 0, nullptr);
|
||||
}
|
||||
input_wptr = 0;
|
||||
input_rptr = 0;
|
||||
if (err == noErr)
|
||||
err = AudioQueueStart(recordQueue, nullptr);
|
||||
if (err != noErr)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "AudioQueue init failed: %d", err);
|
||||
termRecord();
|
||||
return false;
|
||||
}
|
||||
INFO_LOG(AUDIO, "AudioQueue initialized - sample rate %f", desc.mSampleRate);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 record(void* frame, u32 samples) override
|
||||
{
|
||||
// DEBUG_LOG(AUDIO, "coreaudio_record: wptr %d rptr %d", (int)input_wptr, (int)input_rptr);
|
||||
u32 size = samples * 2;
|
||||
while (size != 0)
|
||||
{
|
||||
u32 avail = (input_wptr - input_rptr + InputBufSize) % InputBufSize;
|
||||
if (avail == 0)
|
||||
{
|
||||
DEBUG_LOG(AUDIO, "coreaudio: record underrun %d bytes", size);
|
||||
break;
|
||||
}
|
||||
avail = std::min(avail, size);
|
||||
avail = std::min(avail, (u32)(InputBufSize - input_rptr));
|
||||
|
||||
memcpy(frame, &samples_input[input_rptr], avail);
|
||||
frame = (u8 *)frame + avail;
|
||||
input_rptr = (input_rptr + avail) % InputBufSize;
|
||||
size -= avail;
|
||||
}
|
||||
|
||||
return samples - size / 2;
|
||||
}
|
||||
};
|
||||
static CoreAudioBackend coreAudioBackend;
|
||||
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,240 @@
|
||||
#include "build.h"
|
||||
#if defined(_WIN32) && !defined(TARGET_UWP)
|
||||
#include "audiostream.h"
|
||||
#include "cfg/option.h"
|
||||
#include <initguid.h>
|
||||
#include <dsound.h>
|
||||
#include <vector>
|
||||
#include <atomic>
|
||||
#include <thread>
|
||||
#include "stdclass.h"
|
||||
#include "windows/comptr.h"
|
||||
|
||||
HWND getNativeHwnd();
|
||||
#define verifyc(x) verify(!FAILED(x))
|
||||
|
||||
#ifdef __CRT_UUID_DECL
|
||||
__CRT_UUID_DECL(IDirectSoundBuffer8, 0x6825A449,0x7524,0x4D82,0x92,0x0F,0x50,0xE3,0x6A,0xB3,0xAB,0x1E);
|
||||
__CRT_UUID_DECL(IDirectSoundNotify, 0xB0210783,0x89cd,0x11d0,0xAF,0x08,0x00,0xA0,0xC9,0x25,0xCD,0x16);
|
||||
__CRT_UUID_DECL(IDirectSoundCaptureBuffer8, 0x00990DF4,0x0DBB,0x4872,0x83,0x3E,0x6D,0x30,0x3E,0x80,0xAE,0xB6);
|
||||
#else
|
||||
struct __declspec(uuid("{6825A449-7524-4D82-920F-50E36AB3AB1E}")) IDirectSoundBuffer8;
|
||||
struct __declspec(uuid("{B0210783-89cd-11d0-AF08-00A0C925CD16}")) IDirectSoundNotify;
|
||||
struct __declspec(uuid("{00990DF4-0DBB-4872-833E-6D303E80AEB6}")) IDirectSoundCaptureBuffer8;
|
||||
#endif
|
||||
|
||||
class DirectSoundBackend : public AudioBackend
|
||||
{
|
||||
ComPtr<IDirectSound8> dsound;
|
||||
ComPtr<IDirectSoundBuffer8> buffer;
|
||||
std::vector<HANDLE> notificationEvents;
|
||||
|
||||
ComPtr<IDirectSoundCapture8> dcapture;
|
||||
ComPtr<IDirectSoundCaptureBuffer8> capture_buffer;
|
||||
|
||||
std::atomic_bool audioThreadRunning;
|
||||
std::thread audioThread;
|
||||
cResetEvent pushWait;
|
||||
|
||||
static constexpr u32 SAMPLE_BYTES = SAMPLE_COUNT * 4;
|
||||
|
||||
RingBuffer ringBuffer;
|
||||
|
||||
u32 notificationOffset(int index) {
|
||||
return index * SAMPLE_BYTES;
|
||||
}
|
||||
|
||||
void audioThreadMain()
|
||||
{
|
||||
audioThreadRunning = true;
|
||||
while (true)
|
||||
{
|
||||
u32 rv = WaitForMultipleObjects(notificationEvents.size(), ¬ificationEvents[0], false, 100);
|
||||
|
||||
if (!audioThreadRunning)
|
||||
break;
|
||||
if (rv == WAIT_TIMEOUT || rv == WAIT_FAILED)
|
||||
continue;
|
||||
rv -= WAIT_OBJECT_0;
|
||||
|
||||
void *p1, *p2;
|
||||
DWORD sz1, sz2;
|
||||
|
||||
if (SUCCEEDED(buffer->Lock(notificationOffset(rv), SAMPLE_BYTES, &p1, &sz1, &p2, &sz2, 0)))
|
||||
{
|
||||
if (!ringBuffer.read((u8*)p1, sz1))
|
||||
memset(p1, 0, sz1);
|
||||
if (sz2 != 0)
|
||||
{
|
||||
if (!ringBuffer.read((u8*)p2, sz2))
|
||||
memset(p2, 0, sz2);
|
||||
}
|
||||
buffer->Unlock(p1, sz1, p2, sz2);
|
||||
pushWait.Set();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
DirectSoundBackend()
|
||||
: AudioBackend("directsound", "Microsoft DirectSound") {}
|
||||
|
||||
bool init() override
|
||||
{
|
||||
if (FAILED(DirectSoundCreate8(NULL, &dsound.get(), NULL))) {
|
||||
ERROR_LOG(AUDIO, "DirectSound8 initialization failed");
|
||||
return false;
|
||||
}
|
||||
if (FAILED(dsound->SetCooperativeLevel(getNativeHwnd(), DSSCL_PRIORITY))) {
|
||||
ERROR_LOG(AUDIO, "DirectSound8 SetCooperativeLevel failed");
|
||||
dsound.reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set up WAV format structure.
|
||||
WAVEFORMATEX wfx;
|
||||
memset(&wfx, 0, sizeof(WAVEFORMATEX));
|
||||
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
||||
wfx.nChannels = 2;
|
||||
wfx.nSamplesPerSec = 44100;
|
||||
wfx.nBlockAlign = 4;
|
||||
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
||||
wfx.wBitsPerSample = 16;
|
||||
|
||||
// Set up DSBUFFERDESC structure.
|
||||
DSBUFFERDESC desc;
|
||||
memset(&desc, 0, sizeof(DSBUFFERDESC));
|
||||
desc.dwSize = sizeof(DSBUFFERDESC);
|
||||
desc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLPOSITIONNOTIFY | DSBCAPS_GLOBALFOCUS;
|
||||
desc.dwBufferBytes = SAMPLE_BYTES * 2;
|
||||
desc.lpwfxFormat = &wfx;
|
||||
|
||||
// Create the buffer
|
||||
ComPtr<IDirectSoundBuffer> buffer_;
|
||||
if (FAILED(dsound->CreateSoundBuffer(&desc, &buffer_.get(), 0))
|
||||
|| FAILED(buffer_.as(buffer)))
|
||||
{
|
||||
ERROR_LOG(AUDIO, "DirectSound8 CreateSoundBuffer failed");
|
||||
dsound.reset();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set up notifications
|
||||
ComPtr<IDirectSoundNotify> bufferNotify;
|
||||
verifyc(buffer.as(bufferNotify));
|
||||
notificationEvents.clear();
|
||||
std::vector<DSBPOSITIONNOTIFY> posNotify;
|
||||
for (int i = 0; notificationOffset(i) < desc.dwBufferBytes; i++)
|
||||
{
|
||||
notificationEvents.push_back(CreateEvent(nullptr, false, false, nullptr));
|
||||
posNotify.push_back({ notificationOffset(i), notificationEvents.back() });
|
||||
}
|
||||
bufferNotify->SetNotificationPositions(posNotify.size(), &posNotify[0]);
|
||||
|
||||
// Clear the buffers
|
||||
void *p1, *p2;
|
||||
DWORD sz1, sz2;
|
||||
verifyc(buffer->Lock(0, desc.dwBufferBytes, &p1, &sz1, &p2, &sz2, 0));
|
||||
verify(p2 == nullptr);
|
||||
memset(p1, 0, sz1);
|
||||
verifyc(buffer->Unlock(p1, sz1, p2, sz2));
|
||||
ringBuffer.setCapacity(config::AudioBufferSize * 4);
|
||||
|
||||
// Start the thread
|
||||
audioThread = std::thread(&DirectSoundBackend::audioThreadMain, this);
|
||||
|
||||
// Play the buffer !
|
||||
if (FAILED(buffer->Play(0, 0, DSBPLAY_LOOPING)))
|
||||
{
|
||||
ERROR_LOG(AUDIO, "DirectSound8 Play failed");
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
INFO_LOG(AUDIO, "DirectSound playback started");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 push(const void* frame, u32 samples, bool wait) override
|
||||
{
|
||||
while (!ringBuffer.write((const u8 *)frame, samples * 4) && wait)
|
||||
pushWait.Wait();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void term() override
|
||||
{
|
||||
audioThreadRunning = false;
|
||||
audioThread.join();
|
||||
buffer->Stop();
|
||||
|
||||
for (HANDLE event : notificationEvents)
|
||||
CloseHandle(event);
|
||||
buffer.reset();
|
||||
dsound.reset();
|
||||
INFO_LOG(AUDIO, "DirectSound playback stopped");
|
||||
}
|
||||
|
||||
bool initRecord(u32 sampling_freq) override
|
||||
{
|
||||
if (FAILED(DirectSoundCaptureCreate8(&DSDEVID_DefaultVoiceCapture, &dcapture.get(), NULL)))
|
||||
{
|
||||
ERROR_LOG(AUDIO, "DirectSound capture device creation failed");
|
||||
return false;
|
||||
}
|
||||
HRESULT hr;
|
||||
WAVEFORMATEX wfx =
|
||||
{ WAVE_FORMAT_PCM, 1, sampling_freq, sampling_freq * 2, 2, 16, 0 };
|
||||
// wFormatTag, nChannels, nSamplesPerSec, nAvgBytesPerSec,
|
||||
// nBlockAlign, wBitsPerSample, cbSize
|
||||
|
||||
DSCBUFFERDESC dscbd;
|
||||
dscbd.dwSize = sizeof(DSCBUFFERDESC);
|
||||
dscbd.dwFlags = 0;
|
||||
dscbd.dwBufferBytes = 480 * 2;
|
||||
dscbd.dwReserved = 0;
|
||||
dscbd.lpwfxFormat = &wfx;
|
||||
dscbd.dwFXCount = 0;
|
||||
dscbd.lpDSCFXDesc = NULL;
|
||||
|
||||
ComPtr<IDirectSoundCaptureBuffer> pDSCB;
|
||||
if (FAILED(hr = dcapture->CreateCaptureBuffer(&dscbd, &pDSCB.get(), NULL)))
|
||||
{
|
||||
ERROR_LOG(AUDIO, "DirectSound capture buffer creation failed");
|
||||
dcapture.reset();
|
||||
return false;
|
||||
}
|
||||
pDSCB.as(capture_buffer);
|
||||
capture_buffer->Start(DSCBSTART_LOOPING);
|
||||
INFO_LOG(AUDIO, "DirectSound capture device and buffer created");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 record(void *buffer, u32 samples) override
|
||||
{
|
||||
DWORD readPos;
|
||||
capture_buffer->GetCurrentPosition(NULL, &readPos);
|
||||
void *p1, *p2;
|
||||
DWORD p1bytes, p2bytes;
|
||||
capture_buffer->Lock(readPos, samples * 2, &p1, &p1bytes, &p2, &p2bytes, 0);
|
||||
memcpy(buffer, p1, p1bytes);
|
||||
if (p2bytes > 0)
|
||||
memcpy((u8 *)buffer + p1bytes, p2, p2bytes);
|
||||
capture_buffer->Unlock(p1, p1bytes, p2, p2bytes);
|
||||
return (p1bytes + p2bytes) / 2;
|
||||
}
|
||||
|
||||
void termRecord() override
|
||||
{
|
||||
if (!dcapture)
|
||||
return;
|
||||
capture_buffer->Stop();
|
||||
capture_buffer.reset();
|
||||
dcapture.reset();
|
||||
}
|
||||
};
|
||||
static DirectSoundBackend directSoundBackend;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,54 @@
|
||||
#ifdef USE_LIBAO
|
||||
#include "audiostream.h"
|
||||
#include <ao/ao.h>
|
||||
|
||||
class LibAOBackend : public AudioBackend
|
||||
{
|
||||
ao_device *aodevice = nullptr;
|
||||
|
||||
public:
|
||||
LibAOBackend()
|
||||
: AudioBackend("libao", "libao") {}
|
||||
|
||||
bool init() override
|
||||
{
|
||||
ao_initialize();
|
||||
|
||||
ao_sample_format aoformat {};
|
||||
aoformat.bits = 16;
|
||||
aoformat.channels = 2;
|
||||
aoformat.rate = 44100;
|
||||
aoformat.byte_format = AO_FMT_LITTLE;
|
||||
|
||||
aodevice = ao_open_live(ao_default_driver_id(), &aoformat, NULL); // Live output
|
||||
if (aodevice == nullptr)
|
||||
aodevice = ao_open_live(ao_driver_id("null"), &aoformat, NULL);
|
||||
if (aodevice == nullptr) {
|
||||
ERROR_LOG(AUDIO, "Cannot open libao driver");
|
||||
ao_shutdown();
|
||||
}
|
||||
|
||||
return aodevice != nullptr;
|
||||
}
|
||||
|
||||
u32 push(const void* frame, u32 samples, bool wait) override
|
||||
{
|
||||
if (aodevice != nullptr)
|
||||
ao_play(aodevice, (char*)frame, samples * 4);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void term() override
|
||||
{
|
||||
if (aodevice != nullptr)
|
||||
{
|
||||
ao_close(aodevice);
|
||||
aodevice = nullptr;
|
||||
ao_shutdown();
|
||||
}
|
||||
}
|
||||
};
|
||||
static LibAOBackend libAOBackend;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,51 @@
|
||||
#include "audiostream.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
class NullAudioBackend : public AudioBackend
|
||||
{
|
||||
using the_clock = std::chrono::high_resolution_clock;
|
||||
|
||||
public:
|
||||
NullAudioBackend()
|
||||
: AudioBackend("null", "No Audio") {}
|
||||
|
||||
bool init() override
|
||||
{
|
||||
last_time = the_clock::time_point();
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 push(const void* frame, u32 samples, bool wait) override
|
||||
{
|
||||
if (wait)
|
||||
{
|
||||
if (last_time.time_since_epoch() != the_clock::duration::zero())
|
||||
{
|
||||
auto fduration = std::chrono::nanoseconds(1000000000L * samples / 44100);
|
||||
auto duration = fduration - (the_clock::now() - last_time);
|
||||
std::this_thread::sleep_for(duration);
|
||||
last_time += fduration;
|
||||
}
|
||||
else
|
||||
last_time = the_clock::now();
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool initRecord(u32 sampling_freq) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 record(void *buffer, u32 samples) override
|
||||
{
|
||||
memset(buffer, 0, samples * 2);
|
||||
return samples;
|
||||
}
|
||||
|
||||
private:
|
||||
the_clock::time_point last_time;
|
||||
};
|
||||
static NullAudioBackend nullBackend;
|
||||
@@ -0,0 +1,200 @@
|
||||
/*
|
||||
Copyright 2021 flyinghead
|
||||
|
||||
This file is part of Flycast.
|
||||
|
||||
Flycast is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
Flycast is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifdef USE_OBOE
|
||||
#include "audiostream.h"
|
||||
#include "cfg/option.h"
|
||||
#include <oboe/Oboe.h>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include "stdclass.h"
|
||||
|
||||
class OboeBackend : AudioBackend
|
||||
{
|
||||
RingBuffer ringBuffer;
|
||||
cResetEvent pushWait;
|
||||
|
||||
std::shared_ptr<oboe::AudioStream> stream;
|
||||
std::shared_ptr<oboe::AudioStream> recordStream;
|
||||
|
||||
class AudioCallback : public oboe::AudioStreamDataCallback
|
||||
{
|
||||
public:
|
||||
AudioCallback(OboeBackend *backend) : backend(backend) {}
|
||||
|
||||
oboe::DataCallbackResult onAudioReady(oboe::AudioStream *audioStream, void *audioData, int32_t numFrames) override
|
||||
{
|
||||
if (!backend->ringBuffer.read((u8 *)audioData, numFrames * 4))
|
||||
// underrun
|
||||
memset(audioData, 0, numFrames * 4);
|
||||
backend->pushWait.Set();
|
||||
|
||||
return oboe::DataCallbackResult::Continue;
|
||||
}
|
||||
|
||||
OboeBackend *backend;
|
||||
};
|
||||
AudioCallback audioCallback;
|
||||
|
||||
class AudioErrorCallback : public oboe::AudioStreamErrorCallback
|
||||
{
|
||||
public:
|
||||
AudioErrorCallback(OboeBackend *backend) : backend(backend) {}
|
||||
|
||||
void onErrorAfterClose(oboe::AudioStream *stream, oboe::Result error) override
|
||||
{
|
||||
// Only attempt to recover if init was successful
|
||||
if (backend->stream != nullptr)
|
||||
{
|
||||
WARN_LOG(AUDIO, "Audio device lost. Attempting to reopen the audio stream");
|
||||
// the oboe stream is already closed so make sure we don't close it twice
|
||||
backend->stream.reset();
|
||||
backend->term();
|
||||
backend->init();
|
||||
}
|
||||
}
|
||||
|
||||
OboeBackend *backend;
|
||||
};
|
||||
AudioErrorCallback errorCallback;
|
||||
|
||||
public:
|
||||
OboeBackend()
|
||||
: AudioBackend("Oboe", "Automatic AAudio / OpenSL selection"), audioCallback(this), errorCallback(this) {}
|
||||
|
||||
bool init() override
|
||||
{
|
||||
// Actual capacity is size-1 to avoid overrun so add one buffer
|
||||
ringBuffer.setCapacity((config::AudioBufferSize + SAMPLE_COUNT) * 4);
|
||||
|
||||
oboe::AudioStreamBuilder builder;
|
||||
oboe::Result result = builder.setDirection(oboe::Direction::Output)
|
||||
->setPerformanceMode(oboe::PerformanceMode::LowLatency)
|
||||
->setSharingMode(oboe::SharingMode::Exclusive)
|
||||
->setFormat(oboe::AudioFormat::I16)
|
||||
->setChannelCount(oboe::ChannelCount::Stereo)
|
||||
->setSampleRate(44100)
|
||||
->setFramesPerCallback(SAMPLE_COUNT)
|
||||
->setDataCallback(&audioCallback)
|
||||
->setErrorCallback(&errorCallback)
|
||||
->setUsage(oboe::Usage::Game)
|
||||
->openStream(stream);
|
||||
if (result != oboe::Result::OK)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "Oboe open stream failed: %s", oboe::convertToText(result));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (stream->getAudioApi() == oboe::AudioApi::AAudio && config::AudioBufferSize < 1764)
|
||||
{
|
||||
// Reduce internal buffer for low latency (< 40 ms)
|
||||
int bufSize = stream->getBufferSizeInFrames();
|
||||
int burst = stream->getFramesPerBurst();
|
||||
if (bufSize - burst > SAMPLE_COUNT)
|
||||
{
|
||||
while (bufSize - burst > SAMPLE_COUNT)
|
||||
bufSize -= burst;
|
||||
stream->setBufferSizeInFrames(bufSize);
|
||||
}
|
||||
}
|
||||
|
||||
stream->requestStart();
|
||||
NOTICE_LOG(AUDIO, "Oboe driver started. stream capacity: %d frames, size: %d frames, frames/callback: %d, frames/burst: %d",
|
||||
stream->getBufferCapacityInFrames(), stream->getBufferSizeInFrames(),
|
||||
stream->getFramesPerCallback(), stream->getFramesPerBurst());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void term() override
|
||||
{
|
||||
NOTICE_LOG(AUDIO, "Oboe driver stopping");
|
||||
if (stream != nullptr)
|
||||
{
|
||||
// Don't let the AudioErrorCallback term/reinit while we are stopping
|
||||
// This won't prevent shit to hit the fan if it's already in the process
|
||||
// of doing so but this is a pretty rare event and happens on devices
|
||||
// that have audio issues already.
|
||||
auto localStream = stream;
|
||||
stream.reset();
|
||||
localStream->stop();
|
||||
localStream->close();
|
||||
}
|
||||
}
|
||||
|
||||
u32 push(const void* frame, u32 samples, bool wait) override
|
||||
{
|
||||
while (!ringBuffer.write((const u8 *)frame, samples * 4) && wait)
|
||||
pushWait.Wait();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void termRecord() override
|
||||
{
|
||||
if (recordStream != nullptr)
|
||||
{
|
||||
recordStream->stop();
|
||||
recordStream->close();
|
||||
recordStream.reset();
|
||||
}
|
||||
NOTICE_LOG(AUDIO, "Oboe recorder stopped");
|
||||
}
|
||||
|
||||
bool initRecord(u32 sampling_freq) override
|
||||
{
|
||||
oboe::AudioStreamBuilder builder;
|
||||
oboe::Result result = builder.setDirection(oboe::Direction::Input)
|
||||
->setPerformanceMode(oboe::PerformanceMode::None)
|
||||
->setSharingMode(oboe::SharingMode::Exclusive)
|
||||
->setFormat(oboe::AudioFormat::I16)
|
||||
->setChannelCount(oboe::ChannelCount::Mono)
|
||||
->setSampleRate(sampling_freq)
|
||||
->openStream(recordStream);
|
||||
if (result != oboe::Result::OK)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "Oboe open record stream failed: %s", oboe::convertToText(result));
|
||||
return false;
|
||||
}
|
||||
recordStream->requestStart();
|
||||
NOTICE_LOG(AUDIO, "Oboe recorder started. stream capacity: %d frames",
|
||||
stream->getBufferCapacityInFrames());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 record(void *data, u32 samples) override
|
||||
{
|
||||
if (recordStream == nullptr)
|
||||
return 0;
|
||||
oboe::ResultWithValue<int32_t> result = recordStream->read(data, samples, 0);
|
||||
if (result == oboe::Result::ErrorDisconnected)
|
||||
{
|
||||
WARN_LOG(AUDIO, "Recording device lost. Attempting to reopen the audio stream");
|
||||
u32 sampleRate = recordStream->getSampleRate();
|
||||
termRecord();
|
||||
initRecord(sampleRate);
|
||||
}
|
||||
return std::max(0, result.value());
|
||||
}
|
||||
};
|
||||
static OboeBackend oboeBackend;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,337 @@
|
||||
#if USE_OMX
|
||||
#include "audiostream.h"
|
||||
#include "cfg/option.h"
|
||||
#include <IL/OMX_Broadcom.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#define PORT_INDEX 100
|
||||
#define OUTPUT_FREQ 44100
|
||||
|
||||
class OMXAudioBackend : public AudioBackend
|
||||
{
|
||||
OMX_HANDLETYPE omx_handle = nullptr;
|
||||
OMX_STATETYPE omx_state = OMX_StateInvalid;
|
||||
size_t audio_buffer_idx = 0;
|
||||
OMX_BUFFERHEADERTYPE** audio_buffers = nullptr;
|
||||
u32 latency_max = 0;
|
||||
u32 buffer_count = 0;
|
||||
u32 buffer_size = 0;
|
||||
u32 buffer_length = 0;
|
||||
pthread_mutex_t audio_lock;
|
||||
pthread_cond_t omx_state_cond;
|
||||
|
||||
static OMX_ERRORTYPE eventHandler(
|
||||
OMX_IN OMX_HANDLETYPE hComponent,
|
||||
OMX_IN OMX_PTR pAppData,
|
||||
OMX_IN OMX_EVENTTYPE eEvent,
|
||||
OMX_IN OMX_U32 nData1,
|
||||
OMX_IN OMX_U32 nData2,
|
||||
OMX_IN OMX_PTR pEventData)
|
||||
{
|
||||
OMXAudioBackend *backend = (OMXAudioBackend *)pAddData;
|
||||
pthread_mutex_lock(&backend->audio_lock);
|
||||
if(eEvent == OMX_EventCmdComplete && nData1 == OMX_CommandStateSet)
|
||||
{
|
||||
backend->omx_state = (OMX_STATETYPE)nData2;
|
||||
pthread_cond_signal(&backend->omx_state_cond);
|
||||
}
|
||||
pthread_mutex_unlock(&backend->audio_lock);
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE emptyBufferDone(
|
||||
OMX_IN OMX_HANDLETYPE hComponent,
|
||||
OMX_IN OMX_PTR pAppData,
|
||||
OMX_IN OMX_BUFFERHEADERTYPE* pBuffer)
|
||||
{
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
static OMX_ERRORTYPE fillBufferDone(
|
||||
OMX_OUT OMX_HANDLETYPE hComponent,
|
||||
OMX_OUT OMX_PTR pAppData,
|
||||
OMX_OUT OMX_BUFFERHEADERTYPE* pBuffer)
|
||||
{
|
||||
return OMX_ErrorNone;
|
||||
}
|
||||
|
||||
void waitForState(OMX_STATETYPE state)
|
||||
{
|
||||
pthread_mutex_lock(&audio_lock);
|
||||
while(omx_state != state)
|
||||
pthread_cond_wait(&omx_state_cond, &audio_lock);
|
||||
pthread_mutex_unlock(&audio_lock);
|
||||
}
|
||||
|
||||
u32 getLatency()
|
||||
{
|
||||
OMX_PARAM_U32TYPE param;
|
||||
memset(¶m, 0, sizeof(OMX_PARAM_U32TYPE));
|
||||
param.nSize = sizeof(OMX_PARAM_U32TYPE);
|
||||
param.nVersion.nVersion = OMX_VERSION;
|
||||
param.nPortIndex = PORT_INDEX;
|
||||
|
||||
OMX_ERRORTYPE error = OMX_GetConfig(omx_handle, OMX_IndexConfigAudioRenderingLatency, ¶m);
|
||||
if(error != OMX_ErrorNone)
|
||||
WARN_LOG(AUDIO, "OMX: failed to get OMX configuration (OMX_IndexConfigAudioRenderingLatency). Error 0x%X", error);
|
||||
|
||||
return param.nU32 * 1000 / OUTPUT_FREQ;
|
||||
}
|
||||
|
||||
public:
|
||||
OMXAudioBackend()
|
||||
: AudioBackend("omx", "OpenMAX IL") {}
|
||||
|
||||
bool init() override
|
||||
{
|
||||
OMX_ERRORTYPE error;
|
||||
|
||||
error = OMX_Init();
|
||||
if (error != OMX_ErrorNone)
|
||||
{
|
||||
WARN_LOG(AUDIO, "OMX: OMX_Init() failed. Error 0x%X", error);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Initialize settings
|
||||
latency_max = config::OmxAudioLatency;
|
||||
buffer_size = config::AudioBufferSize * 4;
|
||||
buffer_count = 2 + OUTPUT_FREQ * latency_max / (buffer_size * 1000);
|
||||
|
||||
OMX_CALLBACKTYPE callbacks;
|
||||
callbacks.EventHandler = eventHandler;
|
||||
callbacks.EmptyBufferDone = emptyBufferDone;
|
||||
callbacks.FillBufferDone = fillBufferDone;
|
||||
|
||||
error = OMX_GetHandle(&omx_handle, (OMX_STRING)"OMX.broadcom.audio_render", this, &callbacks);
|
||||
if (error != OMX_ErrorNone)
|
||||
{
|
||||
WARN_LOG(AUDIO, "OMX: OMX_GetHandle() failed. Error 0x%X", error);
|
||||
OMX_Deinit();
|
||||
return false;
|
||||
}
|
||||
|
||||
OMX_PARAM_PORTDEFINITIONTYPE param;
|
||||
memset(¶m, 0, sizeof(OMX_PARAM_PORTDEFINITIONTYPE));
|
||||
param.nSize = sizeof(OMX_PARAM_PORTDEFINITIONTYPE);
|
||||
param.nVersion.nVersion = OMX_VERSION;
|
||||
param.nPortIndex = PORT_INDEX;
|
||||
param.nBufferSize = buffer_size;
|
||||
param.nBufferCountActual = buffer_count;
|
||||
param.format.audio.eEncoding = OMX_AUDIO_CodingPCM;
|
||||
|
||||
error = OMX_SetParameter(omx_handle, OMX_IndexParamPortDefinition, ¶m);
|
||||
if (error != OMX_ErrorNone)
|
||||
{
|
||||
WARN_LOG(AUDIO, "OMX: failed to set OMX_IndexParamPortDefinition. Error 0x%X", error);
|
||||
OMX_Deinit();
|
||||
return false;
|
||||
}
|
||||
|
||||
OMX_AUDIO_PARAM_PCMMODETYPE pcm;
|
||||
memset(&pcm, 0, sizeof(OMX_AUDIO_PARAM_PCMMODETYPE));
|
||||
pcm.nSize = sizeof(OMX_AUDIO_PARAM_PCMMODETYPE);
|
||||
pcm.nVersion.nVersion = OMX_VERSION;
|
||||
pcm.nPortIndex = PORT_INDEX;
|
||||
pcm.nChannels = 2;
|
||||
pcm.eNumData = OMX_NumericalDataSigned;
|
||||
pcm.eEndian = OMX_EndianLittle;
|
||||
pcm.nSamplingRate = OUTPUT_FREQ;
|
||||
pcm.bInterleaved = OMX_TRUE;
|
||||
pcm.nBitPerSample = 16;
|
||||
pcm.ePCMMode = OMX_AUDIO_PCMModeLinear;
|
||||
pcm.eChannelMapping[1] = OMX_AUDIO_ChannelRF;
|
||||
pcm.eChannelMapping[0] = OMX_AUDIO_ChannelLF;
|
||||
|
||||
error = OMX_SetParameter(omx_handle, OMX_IndexParamAudioPcm, &pcm);
|
||||
if (error != OMX_ErrorNone)
|
||||
{
|
||||
WARN_LOG(AUDIO, "OMX: failed to set OMX_IndexParamAudioPcm. Error 0x%X", error);
|
||||
OMX_Deinit();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Disable all ports
|
||||
error = OMX_SendCommand(omx_handle, OMX_CommandPortDisable, PORT_INDEX, NULL);
|
||||
if (error != OMX_ErrorNone)
|
||||
WARN_LOG(AUDIO, "OMX: failed to do OMX_CommandPortDisable. Error 0x%X", error);
|
||||
|
||||
OMX_PORT_PARAM_TYPE param2;
|
||||
memset(¶m2, 0, sizeof(OMX_PORT_PARAM_TYPE));
|
||||
param2.nSize = sizeof(OMX_PORT_PARAM_TYPE);
|
||||
param2.nVersion.nVersion = OMX_VERSION;
|
||||
error = OMX_GetParameter(omx_handle, OMX_IndexParamOtherInit, ¶m2);
|
||||
if (error != OMX_ErrorNone)
|
||||
{
|
||||
WARN_LOG(AUDIO, "OMX: failed to get OMX_IndexParamOtherInit. Error 0x%X", error);
|
||||
}
|
||||
else
|
||||
{
|
||||
for(u32 i = 0; i < param2.nPorts; i++)
|
||||
{
|
||||
u32 port = param2.nStartPortNumber + i;
|
||||
error = OMX_SendCommand(omx_handle, OMX_CommandPortDisable, port, NULL);
|
||||
if(error != OMX_ErrorNone)
|
||||
WARN_LOG(AUDIO, "OMX: failed to do OMX_CommandPortDisable on port %u. Error 0x%X", port, error);
|
||||
}
|
||||
}
|
||||
|
||||
// Go into idle state
|
||||
error = OMX_SendCommand(omx_handle, OMX_CommandStateSet, OMX_StateIdle, NULL);
|
||||
if (error != OMX_ErrorNone)
|
||||
{
|
||||
WARN_LOG(AUDIO, "OMX: failed to set OMX_CommandStateSet. Error 0x%X", error);
|
||||
OMX_Deinit();
|
||||
return false;
|
||||
}
|
||||
waitForState(OMX_StateIdle);
|
||||
|
||||
// Check if we're in a state able to recieve buffers
|
||||
OMX_STATETYPE state;
|
||||
error = OMX_GetState(omx_handle, &state);
|
||||
if (error != OMX_ErrorNone || !(state == OMX_StateIdle || state == OMX_StateExecuting || state == OMX_StatePause))
|
||||
{
|
||||
WARN_LOG(AUDIO, "OMX: state is incorrect. State 0x%X; Error 0x%X", state, error);
|
||||
OMX_Deinit();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create audio buffers
|
||||
INFO_LOG(AUDIO, "OMX: creating %u buffers", buffer_count);
|
||||
|
||||
// Enable port
|
||||
error = OMX_SendCommand(omx_handle, OMX_CommandPortEnable, PORT_INDEX, NULL);
|
||||
if (error != OMX_ErrorNone)
|
||||
WARN_LOG(AUDIO, "OMX: failed to do OMX_CommandPortEnable. Error 0x%X", error);
|
||||
|
||||
// Free audio buffers if they're allocated
|
||||
if (audio_buffers != NULL)
|
||||
delete[] audio_buffers;
|
||||
|
||||
// Allocate buffers
|
||||
audio_buffers = new OMX_BUFFERHEADERTYPE*[buffer_count];
|
||||
for (size_t i = 0; i < buffer_count; i++)
|
||||
{
|
||||
error = OMX_AllocateBuffer(omx_handle, &audio_buffers[i], PORT_INDEX, NULL, buffer_size);
|
||||
if (error != OMX_ErrorNone)
|
||||
{
|
||||
WARN_LOG(AUDIO, "OMX: failed to allocate buffer[%u]. Error 0x%X", i, error);
|
||||
OMX_Deinit();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Set state to executing
|
||||
error = OMX_SendCommand(omx_handle, OMX_CommandStateSet, OMX_StateExecuting, NULL);
|
||||
if (error != OMX_ErrorNone)
|
||||
{
|
||||
WARN_LOG(AUDIO, "OMX: failed to do OMX_CommandStateSet. Error 0x%X", error);
|
||||
OMX_Deinit();
|
||||
return false;
|
||||
}
|
||||
waitForState(OMX_StateExecuting);
|
||||
|
||||
// Empty buffers
|
||||
for (size_t i = 0; i < buffer_count; i++)
|
||||
{
|
||||
memset(audio_buffers[i]->pBuffer, 0, buffer_size);
|
||||
audio_buffers[i]->nOffset = 0;
|
||||
audio_buffers[i]->nFilledLen = buffer_size;
|
||||
|
||||
error = OMX_EmptyThisBuffer(omx_handle, audio_buffers[i]);
|
||||
if(error != OMX_ErrorNone)
|
||||
WARN_LOG(AUDIO, "OMX: failed to empty buffer[%u]. Error 0x%X", i, error);
|
||||
}
|
||||
|
||||
const char* output_device = "local";
|
||||
if (config::OmxAudioHdmi)
|
||||
output_device = (const char*)"hdmi";
|
||||
|
||||
// Set audio destination
|
||||
OMX_CONFIG_BRCMAUDIODESTINATIONTYPE ar_dest;
|
||||
memset(&ar_dest, 0, sizeof(ar_dest));
|
||||
ar_dest.nSize = sizeof(OMX_CONFIG_BRCMAUDIODESTINATIONTYPE);
|
||||
ar_dest.nVersion.nVersion = OMX_VERSION;
|
||||
strcpy((char *)ar_dest.sName, output_device);
|
||||
error = OMX_SetConfig(omx_handle, OMX_IndexConfigBrcmAudioDestination, &ar_dest);
|
||||
if (error != OMX_ErrorNone)
|
||||
{
|
||||
WARN_LOG(AUDIO, "OMX: failed to set OMX configuration (OMX_IndexConfigBrcmAudioDestination). Error 0x%X", error);
|
||||
OMX_Deinit();
|
||||
return false;
|
||||
}
|
||||
|
||||
audio_buffer_idx = 0;
|
||||
buffer_length = 0;
|
||||
|
||||
INFO_LOG(AUDIO, "OMX: audio output to '%s'", ar_dest.sName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 push(const void* frame, u32 samples, bool wait) override
|
||||
{
|
||||
if(audio_buffers == NULL)
|
||||
return 1;
|
||||
|
||||
size_t data_size = samples * 4;
|
||||
|
||||
while(data_size > 0)
|
||||
{
|
||||
size_t copy_size = std::min(buffer_size - buffer_length, data_size);
|
||||
|
||||
// Don't have more than maximum audio latency
|
||||
u32 latency = getLatency();
|
||||
if(latency > latency_max)
|
||||
{
|
||||
usleep((latency - latency_max) * 1000);
|
||||
}
|
||||
else if(latency == 0)
|
||||
{
|
||||
INFO_LOG(AUDIO, "OMX: underrun occurred");
|
||||
}
|
||||
|
||||
memcpy(audio_buffers[audio_buffer_idx]->pBuffer + buffer_length, frame, copy_size);
|
||||
buffer_length += copy_size;
|
||||
frame = (char *)frame + copy_size;
|
||||
|
||||
// Flush buffer and swap
|
||||
if(buffer_length >= buffer_size)
|
||||
{
|
||||
audio_buffers[audio_buffer_idx]->nOffset = 0;
|
||||
audio_buffers[audio_buffer_idx]->nFilledLen = buffer_size;
|
||||
|
||||
OMX_ERRORTYPE error = OMX_EmptyThisBuffer(omx_handle, audio_buffers[audio_buffer_idx]);
|
||||
if(error != OMX_ErrorNone)
|
||||
INFO_LOG(AUDIO, "OMX: failed to empty buffer[%u]. Error 0x%X", audio_buffer_idx, error);
|
||||
|
||||
audio_buffer_idx = (audio_buffer_idx + 1) % buffer_count;
|
||||
buffer_length = 0;
|
||||
}
|
||||
|
||||
data_size -= copy_size;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void term() override
|
||||
{
|
||||
OMX_ERRORTYPE error;
|
||||
|
||||
// Is there anything else that needs to be done for omx?
|
||||
|
||||
error = OMX_Deinit();
|
||||
if(error != OMX_ErrorNone)
|
||||
WARN_LOG(AUDIO, "OMX: OMX_Deinit() failed. Error 0x%X", error);
|
||||
|
||||
if(audio_buffers != NULL)
|
||||
{
|
||||
delete[] audio_buffers;
|
||||
audio_buffers = NULL;
|
||||
}
|
||||
}
|
||||
};
|
||||
static OMXAudioBackend omxAudioBackend;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,116 @@
|
||||
#ifdef USE_OSS
|
||||
#include "audiostream.h"
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/soundcard.h>
|
||||
#include <unistd.h>
|
||||
|
||||
class OSSAudioBackend : public AudioBackend
|
||||
{
|
||||
int audioFD = -1;
|
||||
int recordFD = -1;
|
||||
|
||||
public:
|
||||
OSSAudioBackend()
|
||||
: AudioBackend("oss", "Open Sound System") {}
|
||||
|
||||
bool init() override
|
||||
{
|
||||
audioFD = open("/dev/dsp", O_WRONLY);
|
||||
if (audioFD < 0)
|
||||
{
|
||||
WARN_LOG(AUDIO, "Couldn't open /dev/dsp.");
|
||||
return false;
|
||||
}
|
||||
INFO_LOG(AUDIO, "sound enabled, dsp opened for write");
|
||||
int tmp=44100;
|
||||
int err_ret;
|
||||
err_ret=ioctl(audioFD,SNDCTL_DSP_SPEED,&tmp);
|
||||
INFO_LOG(AUDIO, "set Frequency to %i, return %i (rate=%i)", 44100, err_ret, tmp);
|
||||
int channels=2;
|
||||
err_ret=ioctl(audioFD, SNDCTL_DSP_CHANNELS, &channels);
|
||||
INFO_LOG(AUDIO, "set dsp to stereo (%i => %i)", channels, err_ret);
|
||||
int format=AFMT_S16_LE;
|
||||
err_ret=ioctl(audioFD, SNDCTL_DSP_SETFMT, &format);
|
||||
INFO_LOG(AUDIO, "set dsp to %s audio (%i/%i => %i)", "16bits signed", AFMT_S16_LE, format, err_ret);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 push(const void* frame, u32 samples, bool wait) override
|
||||
{
|
||||
write(audioFD, frame, samples * 4);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void term() override
|
||||
{
|
||||
if (audioFD >= 0)
|
||||
close(audioFD);
|
||||
audioFD = -1;
|
||||
}
|
||||
|
||||
// recording untested
|
||||
|
||||
bool initRecord(u32 sampling_freq) override
|
||||
{
|
||||
recordFD = open("/dev/dsp", O_RDONLY);
|
||||
if (recordFD < 0)
|
||||
{
|
||||
INFO_LOG(AUDIO, "OSS: can't open default audio capture device");
|
||||
return false;
|
||||
}
|
||||
int tmp = AFMT_S16_NE; // Native 16 bits
|
||||
if (ioctl(recordFD, SNDCTL_DSP_SETFMT, &tmp) == -1 || tmp != AFMT_S16_NE)
|
||||
{
|
||||
INFO_LOG(AUDIO, "OSS: can't set sample format");
|
||||
close(recordFD);
|
||||
recordFD = -1;
|
||||
return false;
|
||||
}
|
||||
tmp = 1;
|
||||
if (ioctl(recordFD, SNDCTL_DSP_CHANNELS, &tmp) == -1)
|
||||
{
|
||||
INFO_LOG(AUDIO, "OSS: can't set channel count");
|
||||
close(recordFD);
|
||||
recordFD = -1;
|
||||
return false;
|
||||
}
|
||||
tmp = sampling_freq;
|
||||
if (ioctl(recordFD, SNDCTL_DSP_SPEED, &tmp) == -1)
|
||||
{
|
||||
INFO_LOG(AUDIO, "OSS: can't set sample rate");
|
||||
close(recordFD);
|
||||
recordFD = -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void termRecord() override
|
||||
{
|
||||
if (recordFD >= 0)
|
||||
close(recordFD);
|
||||
recordFD = -1;
|
||||
}
|
||||
|
||||
u32 record(void *buffer, u32 samples) override
|
||||
{
|
||||
samples *= 2;
|
||||
int l = read(recordFD, buffer, samples);
|
||||
if (l < (int)samples)
|
||||
{
|
||||
if (l < 0)
|
||||
{
|
||||
INFO_LOG(AUDIO, "OSS: Recording error");
|
||||
l = 0;
|
||||
}
|
||||
memset((u8 *)buffer + l, 0, samples - l);
|
||||
}
|
||||
return l / 2;
|
||||
}
|
||||
};
|
||||
static OSSAudioBackend ossAudioBackend;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,252 @@
|
||||
#ifdef USE_PULSEAUDIO
|
||||
#include "audiostream.h"
|
||||
#include "cfg/option.h"
|
||||
#include <pulse/pulseaudio.h>
|
||||
|
||||
class PulseAudioBackend : public AudioBackend
|
||||
{
|
||||
pa_threaded_mainloop *mainloop = nullptr;
|
||||
pa_context *context = nullptr;
|
||||
pa_stream *stream = nullptr;
|
||||
pa_stream *record_stream = nullptr;
|
||||
|
||||
static void context_state_cb(pa_context *c, void *userdata)
|
||||
{
|
||||
PulseAudioBackend *backend = (PulseAudioBackend *)userdata;
|
||||
switch (pa_context_get_state(c))
|
||||
{
|
||||
case PA_CONTEXT_READY:
|
||||
case PA_CONTEXT_TERMINATED:
|
||||
case PA_CONTEXT_FAILED:
|
||||
pa_threaded_mainloop_signal(backend->mainloop, 0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void stream_request_cb(pa_stream *s, size_t length, void *userdata)
|
||||
{
|
||||
PulseAudioBackend *backend = (PulseAudioBackend *)userdata;
|
||||
pa_threaded_mainloop_signal(backend->mainloop, 0);
|
||||
}
|
||||
|
||||
public:
|
||||
PulseAudioBackend()
|
||||
: AudioBackend("pulse", "PulseAudio") {}
|
||||
|
||||
bool init() override
|
||||
{
|
||||
mainloop = pa_threaded_mainloop_new();
|
||||
if (!mainloop)
|
||||
{
|
||||
WARN_LOG(AUDIO, "PulseAudio: pa_threaded_mainloop_new failed");
|
||||
return false;
|
||||
}
|
||||
context = pa_context_new(pa_threaded_mainloop_get_api(mainloop), "flycast");
|
||||
if (!context)
|
||||
{
|
||||
WARN_LOG(AUDIO, "PulseAudio: pa_context_new failed");
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
pa_context_set_state_callback(context, context_state_cb, this);
|
||||
|
||||
if (pa_context_connect(context, nullptr, PA_CONTEXT_NOFLAGS, nullptr) < 0)
|
||||
{
|
||||
WARN_LOG(AUDIO, "PulseAudio: pa_context_connect failed");
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
if (pa_threaded_mainloop_start(mainloop) < 0)
|
||||
{
|
||||
WARN_LOG(AUDIO, "PulseAudio: pa_threaded_mainloop_start failed");
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
pa_threaded_mainloop_wait(mainloop);
|
||||
|
||||
if (pa_context_get_state(context) != PA_CONTEXT_READY)
|
||||
{
|
||||
WARN_LOG(AUDIO, "PulseAudio: context isn't ready");
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
pa_sample_spec spec{ PA_SAMPLE_S16LE, 44100, 2 };
|
||||
|
||||
stream = pa_stream_new(context, "audio", &spec, NULL);
|
||||
if (!stream)
|
||||
{
|
||||
WARN_LOG(AUDIO, "PulseAudio: pa_stream_new failed");
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
|
||||
//pa_stream_set_state_callback(stream, stream_state_cb, this);
|
||||
pa_stream_set_write_callback(stream, stream_request_cb, this);
|
||||
//pa_stream_set_latency_update_callback(stream, stream_latency_update_cb, this);
|
||||
//pa_stream_set_underflow_callback(stream, underrun_update_cb, this);
|
||||
//pa_stream_set_buffer_attr_callback(stream, buffer_attr_cb, this);
|
||||
|
||||
pa_buffer_attr buffer_attr;
|
||||
buffer_attr.maxlength = -1;
|
||||
buffer_attr.tlength = pa_usec_to_bytes(config::AudioBufferSize * PA_USEC_PER_SEC / 44100, &spec);
|
||||
buffer_attr.prebuf = -1;
|
||||
buffer_attr.minreq = -1;
|
||||
buffer_attr.fragsize = -1;
|
||||
|
||||
if (pa_stream_connect_playback(stream, nullptr, &buffer_attr, PA_STREAM_ADJUST_LATENCY, nullptr, nullptr) < 0)
|
||||
{
|
||||
WARN_LOG(AUDIO, "PulseAudio: pa_stream_connect_playback failed");
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
|
||||
pa_threaded_mainloop_wait(mainloop);
|
||||
|
||||
if (pa_stream_get_state(stream) != PA_STREAM_READY)
|
||||
{
|
||||
WARN_LOG(AUDIO, "PulseAudio: stream isn't ready");
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
term();
|
||||
return false;
|
||||
}
|
||||
|
||||
const pa_buffer_attr *server_attr = pa_stream_get_buffer_attr(stream);
|
||||
if (server_attr)
|
||||
DEBUG_LOG(AUDIO, "PulseAudio: requested %d samples buffer, got %d", buffer_attr.tlength / 4, server_attr->tlength / 4);
|
||||
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
u32 push(const void* frame, u32 samples, bool wait) override
|
||||
{
|
||||
const u8 *buf = (const u8 *)frame;
|
||||
size_t size = samples * 4;
|
||||
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
while (size)
|
||||
{
|
||||
size_t writable = std::min(size, pa_stream_writable_size(stream));
|
||||
|
||||
if (writable)
|
||||
{
|
||||
pa_stream_write(stream, buf, writable, NULL, 0, PA_SEEK_RELATIVE);
|
||||
buf += writable;
|
||||
size -= writable;
|
||||
}
|
||||
else if (wait)
|
||||
pa_threaded_mainloop_wait(mainloop);
|
||||
else
|
||||
break;
|
||||
}
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void term() override
|
||||
{
|
||||
if (mainloop)
|
||||
pa_threaded_mainloop_stop(mainloop);
|
||||
|
||||
if (stream)
|
||||
{
|
||||
pa_stream_disconnect(stream);
|
||||
pa_stream_unref(stream);
|
||||
stream = nullptr;
|
||||
}
|
||||
if (context)
|
||||
{
|
||||
pa_context_disconnect(context);
|
||||
pa_context_unref(context);
|
||||
context = nullptr;
|
||||
}
|
||||
|
||||
if (mainloop)
|
||||
pa_threaded_mainloop_free(mainloop);
|
||||
mainloop = nullptr;
|
||||
}
|
||||
|
||||
bool initRecord(u32 sampling_freq) override
|
||||
{
|
||||
pa_sample_spec spec{ PA_SAMPLE_S16LE, sampling_freq, 1 };
|
||||
|
||||
record_stream = pa_stream_new(context, "record", &spec, NULL);
|
||||
if (!record_stream)
|
||||
{
|
||||
INFO_LOG(AUDIO, "PulseAudio: pa_stream_new failed");
|
||||
return false;
|
||||
}
|
||||
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
|
||||
pa_buffer_attr buffer_attr;
|
||||
buffer_attr.fragsize = 240 * 2;
|
||||
buffer_attr.maxlength = buffer_attr.fragsize * 2;
|
||||
|
||||
if (pa_stream_connect_record(record_stream, nullptr, &buffer_attr, PA_STREAM_NOFLAGS) < 0)
|
||||
{
|
||||
INFO_LOG(AUDIO, "PulseAudio: pa_stream_connect_record failed");
|
||||
pa_stream_unref(record_stream);
|
||||
record_stream = nullptr;
|
||||
return false;
|
||||
}
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
INFO_LOG(AUDIO, "PulseAudio: Successfully initialized capture device");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void termRecord() override
|
||||
{
|
||||
if (record_stream != nullptr)
|
||||
{
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
pa_stream_disconnect(record_stream);
|
||||
pa_stream_unref(record_stream);
|
||||
record_stream = nullptr;
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
}
|
||||
}
|
||||
|
||||
u32 record(void *buffer, u32 samples) override
|
||||
{
|
||||
if (record_stream == nullptr)
|
||||
return 0;
|
||||
pa_threaded_mainloop_lock(mainloop);
|
||||
const void *data;
|
||||
size_t size;
|
||||
if (pa_stream_peek(record_stream, &data, &size) < 0)
|
||||
{
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
DEBUG_LOG(AUDIO, "PulseAudio: pa_stream_peek error");
|
||||
return 0;
|
||||
}
|
||||
if (size == 0)
|
||||
{
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
return 0;
|
||||
}
|
||||
size = std::min((size_t)samples * 2, size);
|
||||
if (data != nullptr)
|
||||
memcpy(buffer, data, size);
|
||||
else
|
||||
memset(buffer, 0, size);
|
||||
pa_stream_drop(record_stream);
|
||||
pa_threaded_mainloop_unlock(mainloop);
|
||||
|
||||
return size / 2;
|
||||
}
|
||||
};
|
||||
static PulseAudioBackend pulseAudioBackend;
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,243 @@
|
||||
#if defined(USE_SDL_AUDIO)
|
||||
|
||||
#include <SDL.h>
|
||||
#include "audiostream.h"
|
||||
#include "cfg/option.h"
|
||||
#include "stdclass.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <mutex>
|
||||
|
||||
class SDLAudioBackend : AudioBackend
|
||||
{
|
||||
SDL_AudioDeviceID audiodev {};
|
||||
bool needs_resampling = false;
|
||||
cResetEvent read_wait;
|
||||
std::mutex stream_mutex;
|
||||
uint32_t *sample_buffer;
|
||||
unsigned sample_buffer_size = 0;
|
||||
unsigned sample_count = 0;
|
||||
SDL_AudioCVT audioCvt;
|
||||
|
||||
SDL_AudioDeviceID recorddev {};
|
||||
u8 recordbuf[480 * 4];
|
||||
std::atomic<size_t> rec_read;
|
||||
std::atomic<size_t> rec_write;
|
||||
|
||||
static void audioCallback(void* userdata, Uint8* stream, int len)
|
||||
{
|
||||
SDLAudioBackend *backend = (SDLAudioBackend *)userdata;
|
||||
|
||||
backend->stream_mutex.lock();
|
||||
// Wait until there's enough samples to feed the kraken
|
||||
unsigned oslen = len / sizeof(uint32_t);
|
||||
unsigned islen = backend->needs_resampling ? std::ceil(oslen / backend->audioCvt.len_ratio) : oslen;
|
||||
|
||||
if (backend->sample_count < islen)
|
||||
{
|
||||
// No data, just output a bit of silence for the underrun
|
||||
memset(stream, 0, len);
|
||||
backend->stream_mutex.unlock();
|
||||
backend->read_wait.Set();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!backend->needs_resampling) {
|
||||
// Just copy bytes for this case.
|
||||
memcpy(stream, &backend->sample_buffer[0], len);
|
||||
}
|
||||
else
|
||||
{
|
||||
SDL_AudioCVT& cvt = backend->audioCvt;
|
||||
cvt.len = islen * sizeof(uint32_t);
|
||||
memcpy(cvt.buf, &backend->sample_buffer[0], cvt.len);
|
||||
SDL_ConvertAudio(&cvt);
|
||||
memcpy(stream, cvt.buf, cvt.len_cvt);
|
||||
}
|
||||
|
||||
// Move samples in the buffer and consume them
|
||||
memmove(&backend->sample_buffer[0], &backend->sample_buffer[islen], (backend->sample_count - islen) * sizeof(uint32_t));
|
||||
backend->sample_count -= islen;
|
||||
|
||||
backend->stream_mutex.unlock();
|
||||
backend->read_wait.Set();
|
||||
}
|
||||
|
||||
public:
|
||||
SDLAudioBackend()
|
||||
: AudioBackend("sdl2", "Simple DirectMedia Layer 2 Audio") {}
|
||||
|
||||
bool init() override
|
||||
{
|
||||
if (!SDL_WasInit(SDL_INIT_AUDIO))
|
||||
{
|
||||
if (SDL_InitSubSystem(SDL_INIT_AUDIO)) {
|
||||
ERROR_LOG(AUDIO, "SDL2 error initializing audio subsystem: %s", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
sample_buffer_size = std::max<u32>(SAMPLE_COUNT * 2, config::AudioBufferSize);
|
||||
sample_buffer = new uint32_t[sample_buffer_size]();
|
||||
sample_count = 0;
|
||||
|
||||
// Support 44.1KHz (native) but also upsampling to 48KHz
|
||||
SDL_AudioSpec wav_spec, out_spec;
|
||||
memset(&wav_spec, 0, sizeof(wav_spec));
|
||||
wav_spec.freq = 44100;
|
||||
wav_spec.format = AUDIO_S16;
|
||||
wav_spec.channels = 2;
|
||||
wav_spec.samples = SAMPLE_COUNT * 2; // Must be power of two
|
||||
wav_spec.callback = audioCallback;
|
||||
wav_spec.userdata = this;
|
||||
needs_resampling = false;
|
||||
|
||||
// Try 44.1KHz which should be faster since it's native.
|
||||
audiodev = SDL_OpenAudioDevice(NULL, 0, &wav_spec, &out_spec, 0);
|
||||
if (audiodev == 0)
|
||||
{
|
||||
INFO_LOG(AUDIO, "SDL2: SDL_OpenAudioDevice failed: %s", SDL_GetError());
|
||||
needs_resampling = true;
|
||||
wav_spec.freq = 48000;
|
||||
audiodev = SDL_OpenAudioDevice(NULL, 0, &wav_spec, &out_spec, 0);
|
||||
if (audiodev == 0)
|
||||
ERROR_LOG(AUDIO, "SDL2: SDL_OpenAudioDevice failed: %s", SDL_GetError());
|
||||
else
|
||||
{
|
||||
INFO_LOG(AUDIO, "SDL2: Using resampling to 48 KHz");
|
||||
int ret = SDL_BuildAudioCVT(&audioCvt, AUDIO_S16, 2, 44100, AUDIO_S16, 2, 48000);
|
||||
if (ret != 1 || audioCvt.needed == 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "SDL2: can't build audio converter: %s", SDL_GetError());
|
||||
SDL_CloseAudioDevice(audiodev);
|
||||
audiodev = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
audioCvt.buf = new u8[SAMPLE_COUNT * 2 * sizeof(uint32_t) * audioCvt.len_mult];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return audiodev != 0;
|
||||
}
|
||||
|
||||
u32 push(const void* frame, u32 samples, bool wait) override
|
||||
{
|
||||
// Unpause the device shall it be paused.
|
||||
if (SDL_GetAudioDeviceStatus(audiodev) != SDL_AUDIO_PLAYING)
|
||||
SDL_PauseAudioDevice(audiodev, 0);
|
||||
|
||||
// If wait, then wait for the buffer to be smaller than a certain size.
|
||||
stream_mutex.lock();
|
||||
if (wait) {
|
||||
while (sample_count + samples > sample_buffer_size) {
|
||||
stream_mutex.unlock();
|
||||
read_wait.Wait();
|
||||
stream_mutex.lock();
|
||||
}
|
||||
}
|
||||
|
||||
// Copy as many samples as possible, drop any remaining (this should not happen usually)
|
||||
unsigned free_samples = sample_buffer_size - sample_count;
|
||||
unsigned tocopy = samples < free_samples ? samples : free_samples;
|
||||
memcpy(&sample_buffer[sample_count], frame, tocopy * sizeof(uint32_t));
|
||||
sample_count += tocopy;
|
||||
stream_mutex.unlock();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
void term() override
|
||||
{
|
||||
if (audiodev)
|
||||
{
|
||||
// Stop audio playback.
|
||||
SDL_PauseAudioDevice(audiodev, 1);
|
||||
read_wait.Set();
|
||||
SDL_CloseAudioDevice(audiodev);
|
||||
audiodev = SDL_AudioDeviceID();
|
||||
}
|
||||
delete [] sample_buffer;
|
||||
sample_buffer = nullptr;
|
||||
if (needs_resampling)
|
||||
{
|
||||
delete [] audioCvt.buf;
|
||||
audioCvt.buf = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
static void recordCallback(void *userdata, u8 *stream, int len)
|
||||
{
|
||||
SDLAudioBackend *backend = (SDLAudioBackend *)userdata;
|
||||
DEBUG_LOG(AUDIO, "SDL2: sdl2_record_cb len %d write %zd read %zd", len, (size_t)backend->rec_write, (size_t)backend->rec_read);
|
||||
while (len > 0)
|
||||
{
|
||||
size_t plen = std::min((size_t)len, sizeof(backend->recordbuf) - backend->rec_write);
|
||||
memcpy(&backend->recordbuf[backend->rec_write], stream, plen);
|
||||
len -= plen;
|
||||
backend->rec_write = (backend->rec_write + plen) % sizeof(backend->recordbuf);
|
||||
stream += plen;
|
||||
}
|
||||
}
|
||||
|
||||
bool initRecord(u32 sampling_freq) override
|
||||
{
|
||||
rec_write = 0;
|
||||
rec_read = 0;
|
||||
|
||||
SDL_AudioSpec wav_spec, out_spec;
|
||||
memset(&wav_spec, 0, sizeof(wav_spec));
|
||||
wav_spec.freq = sampling_freq;
|
||||
wav_spec.format = AUDIO_S16;
|
||||
wav_spec.channels = 1;
|
||||
wav_spec.samples = 256; // Must be power of two
|
||||
wav_spec.callback = recordCallback;
|
||||
wav_spec.userdata = this;
|
||||
recorddev = SDL_OpenAudioDevice(NULL, 1, &wav_spec, &out_spec, 0);
|
||||
if (recorddev == 0)
|
||||
{
|
||||
ERROR_LOG(AUDIO, "SDL2: Cannot open audio capture device: %s", SDL_GetError());
|
||||
return false;
|
||||
}
|
||||
SDL_PauseAudioDevice(recorddev, 0);
|
||||
INFO_LOG(AUDIO, "SDL2: opened audio capture device");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void termRecord() override
|
||||
{
|
||||
if (recorddev != 0)
|
||||
{
|
||||
SDL_PauseAudioDevice(recorddev, 1);
|
||||
SDL_CloseAudioDevice(recorddev);
|
||||
recorddev = 0;
|
||||
}
|
||||
}
|
||||
|
||||
u32 record(void* frame, u32 samples) override
|
||||
{
|
||||
u32 count = 0;
|
||||
samples *= 2;
|
||||
while (samples > 0)
|
||||
{
|
||||
u32 avail = std::min(rec_write - rec_read, sizeof(recordbuf) - rec_read);
|
||||
if (avail == 0)
|
||||
break;
|
||||
avail = std::min(avail, samples);
|
||||
memcpy((u8 *)frame + count, &recordbuf[rec_read], avail);
|
||||
rec_read = (rec_read + avail) % sizeof(recordbuf);
|
||||
samples -= avail;
|
||||
count += avail;
|
||||
}
|
||||
DEBUG_LOG(AUDIO, "SDL2: sdl2_record len %d ret %d write %zd read %zd", samples * 2, count, (size_t)rec_write, (size_t)rec_read);
|
||||
|
||||
return count / 2;
|
||||
}
|
||||
};
|
||||
static SDLAudioBackend sdlAudioBackend;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
#include "audiostream.h"
|
||||
#include "cfg/option.h"
|
||||
|
||||
struct SoundFrame { s16 l; s16 r; };
|
||||
|
||||
static SoundFrame Buffer[SAMPLE_COUNT];
|
||||
static u32 writePtr; // next sample index
|
||||
|
||||
static AudioBackend *currentBackend;
|
||||
std::vector<AudioBackend *> *AudioBackend::backends;
|
||||
|
||||
static bool audio_recording_started;
|
||||
static bool eight_khz;
|
||||
|
||||
AudioBackend *AudioBackend::getBackend(const std::string& slug)
|
||||
{
|
||||
if (backends == nullptr)
|
||||
return nullptr;
|
||||
if (slug == "auto")
|
||||
{
|
||||
// Prefer sdl2 if available and avoid the null driver
|
||||
AudioBackend *sdlBackend = nullptr;
|
||||
AudioBackend *autoBackend = nullptr;
|
||||
for (auto backend : *backends)
|
||||
{
|
||||
if (backend->slug == "sdl2")
|
||||
sdlBackend = backend;
|
||||
if (backend->slug != "null" && autoBackend == nullptr)
|
||||
autoBackend = backend;
|
||||
}
|
||||
if (sdlBackend != nullptr)
|
||||
autoBackend = sdlBackend;
|
||||
if (autoBackend == nullptr)
|
||||
autoBackend = backends->front();
|
||||
INFO_LOG(AUDIO, "Auto-selected audio backend \"%s\" (%s).", autoBackend->slug.c_str(), autoBackend->name.c_str());
|
||||
|
||||
return autoBackend;
|
||||
}
|
||||
for (auto backend : *backends)
|
||||
{
|
||||
if (backend->slug == slug)
|
||||
return backend;
|
||||
}
|
||||
WARN_LOG(AUDIO, "WARNING: Audio backend \"%s\" not found!", slug.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void WriteSample(s16 r, s16 l)
|
||||
{
|
||||
Buffer[writePtr].r = r * config::AudioVolume.dbPower();
|
||||
Buffer[writePtr].l = l * config::AudioVolume.dbPower();
|
||||
|
||||
if (++writePtr == SAMPLE_COUNT)
|
||||
{
|
||||
if (currentBackend != nullptr)
|
||||
currentBackend->push(Buffer, SAMPLE_COUNT, config::LimitFPS);
|
||||
writePtr = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void InitAudio()
|
||||
{
|
||||
TermAudio();
|
||||
|
||||
std::string slug = config::AudioBackend;
|
||||
currentBackend = AudioBackend::getBackend(slug);
|
||||
if (currentBackend == nullptr && slug != "auto")
|
||||
{
|
||||
slug = "auto";
|
||||
currentBackend = AudioBackend::getBackend(slug);
|
||||
}
|
||||
if (currentBackend != nullptr)
|
||||
{
|
||||
INFO_LOG(AUDIO, "Initializing audio backend \"%s\" (%s)...", currentBackend->slug.c_str(), currentBackend->name.c_str());
|
||||
if (!currentBackend->init())
|
||||
{
|
||||
currentBackend = nullptr;
|
||||
if (slug != "auto")
|
||||
{
|
||||
WARN_LOG(AUDIO, "Audio driver %s failed to initialize. Defaulting to 'auto'", slug.c_str());
|
||||
slug = "auto";
|
||||
currentBackend = AudioBackend::getBackend(slug);
|
||||
if (!currentBackend->init())
|
||||
currentBackend = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (currentBackend == nullptr)
|
||||
{
|
||||
WARN_LOG(AUDIO, "Running without audio!");
|
||||
return;
|
||||
}
|
||||
|
||||
if (audio_recording_started)
|
||||
{
|
||||
// Restart recording
|
||||
audio_recording_started = false;
|
||||
StartAudioRecording(eight_khz);
|
||||
}
|
||||
}
|
||||
|
||||
void TermAudio()
|
||||
{
|
||||
if (currentBackend == nullptr)
|
||||
return;
|
||||
|
||||
// Save recording state before stopping
|
||||
bool rec_started = audio_recording_started;
|
||||
StopAudioRecording();
|
||||
audio_recording_started = rec_started;
|
||||
currentBackend->term();
|
||||
INFO_LOG(AUDIO, "Terminating audio backend \"%s\" (%s)...", currentBackend->slug.c_str(), currentBackend->name.c_str());
|
||||
currentBackend = nullptr;
|
||||
}
|
||||
|
||||
void StartAudioRecording(bool eight_khz)
|
||||
{
|
||||
::eight_khz = eight_khz;
|
||||
if (currentBackend != nullptr)
|
||||
audio_recording_started = currentBackend->initRecord(eight_khz ? 8000 : 11025);
|
||||
else
|
||||
// might be called between TermAudio/InitAudio
|
||||
audio_recording_started = true;
|
||||
}
|
||||
|
||||
u32 RecordAudio(void *buffer, u32 samples)
|
||||
{
|
||||
if (!audio_recording_started || currentBackend == nullptr)
|
||||
return 0;
|
||||
return currentBackend->record(buffer, samples);
|
||||
}
|
||||
|
||||
void StopAudioRecording()
|
||||
{
|
||||
// might be called between TermAudio/InitAudio
|
||||
if (audio_recording_started && currentBackend != nullptr)
|
||||
currentBackend->termRecord();
|
||||
audio_recording_started = false;
|
||||
}
|
||||
@@ -0,0 +1,131 @@
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class AudioBackend
|
||||
{
|
||||
public:
|
||||
virtual ~AudioBackend() = default;
|
||||
|
||||
virtual bool init() = 0;
|
||||
virtual u32 push(const void *data, u32 frames, bool wait) = 0;
|
||||
virtual void term() {}
|
||||
|
||||
struct Option {
|
||||
std::string name;
|
||||
std::string caption;
|
||||
enum { integer, checkbox, list } type;
|
||||
|
||||
int minValue;
|
||||
int maxValue;
|
||||
std::vector<std::string> values;
|
||||
};
|
||||
virtual const Option *getOptions(int *count) {
|
||||
*count = 0;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
virtual bool initRecord(u32 sampling_freq) { return false; }
|
||||
virtual u32 record(void *, u32) { return 0; }
|
||||
virtual void termRecord() {}
|
||||
|
||||
std::string slug;
|
||||
std::string name;
|
||||
|
||||
static size_t getCount() { return backends == nullptr ? 0 : backends->size(); }
|
||||
static AudioBackend *getBackend(size_t index) { return backends == nullptr ? nullptr : (*backends)[index]; }
|
||||
static AudioBackend *getBackend(const std::string& slug);
|
||||
|
||||
protected:
|
||||
AudioBackend(const std::string& slug, const std::string& name)
|
||||
: slug(slug), name(name) {
|
||||
registerAudioBackend(this);
|
||||
}
|
||||
|
||||
private:
|
||||
static void registerAudioBackend(AudioBackend *backend)
|
||||
{
|
||||
if (backends == nullptr)
|
||||
backends = new std::vector<AudioBackend *>();
|
||||
backends->push_back(backend);
|
||||
std::sort(backends->begin(), backends->end(), [](AudioBackend *b1, AudioBackend *b2) { return b1->slug < b2->slug; });
|
||||
}
|
||||
|
||||
static std::vector<AudioBackend *> *backends;
|
||||
};
|
||||
|
||||
void InitAudio();
|
||||
void TermAudio();
|
||||
void WriteSample(s16 right, s16 left);
|
||||
|
||||
void StartAudioRecording(bool eight_khz);
|
||||
u32 RecordAudio(void *buffer, u32 samples);
|
||||
void StopAudioRecording();
|
||||
|
||||
constexpr u32 SAMPLE_COUNT = 512; // AudioBackend::push() is always called with that many frames
|
||||
|
||||
class RingBuffer
|
||||
{
|
||||
std::vector<u8> buffer;
|
||||
std::atomic_int readCursor { 0 };
|
||||
std::atomic_int writeCursor { 0 };
|
||||
|
||||
u32 readSize() {
|
||||
return (u32)((writeCursor - readCursor + buffer.size()) % buffer.size());
|
||||
}
|
||||
u32 writeSize() {
|
||||
return (u32)((readCursor - writeCursor + buffer.size() - 1) % buffer.size());
|
||||
}
|
||||
|
||||
public:
|
||||
bool write(const u8 *data, u32 size)
|
||||
{
|
||||
if (size > writeSize())
|
||||
return false;
|
||||
u32 wc = writeCursor;
|
||||
u32 chunkSize = std::min<u32>(size, (u32)buffer.size() - wc);
|
||||
memcpy(&buffer[wc], data, chunkSize);
|
||||
wc = (wc + chunkSize) % buffer.size();
|
||||
size -= chunkSize;
|
||||
if (size > 0)
|
||||
{
|
||||
data += chunkSize;
|
||||
memcpy(&buffer[wc], data, size);
|
||||
wc = (wc + size) % buffer.size();
|
||||
}
|
||||
writeCursor = wc;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool read(u8 *data, u32 size)
|
||||
{
|
||||
if (size > readSize())
|
||||
return false;
|
||||
u32 rc = readCursor;
|
||||
u32 chunkSize = std::min<u32>(size, (u32)buffer.size() - rc);
|
||||
memcpy(data, &buffer[rc], chunkSize);
|
||||
rc = (rc + chunkSize) % buffer.size();
|
||||
size -= chunkSize;
|
||||
if (size > 0)
|
||||
{
|
||||
data += chunkSize;
|
||||
memcpy(data, &buffer[rc], size);
|
||||
rc = (rc + size) % buffer.size();
|
||||
}
|
||||
readCursor = rc;
|
||||
return true;
|
||||
}
|
||||
|
||||
void setCapacity(size_t size)
|
||||
{
|
||||
std::fill(buffer.begin(), buffer.end(), 0);
|
||||
buffer.resize(size);
|
||||
readCursor = 0;
|
||||
writeCursor = 0;
|
||||
}
|
||||
};
|
||||
+35
-167
@@ -1,134 +1,16 @@
|
||||
/*
|
||||
reicast build options
|
||||
|
||||
Reicast can support a lot of stuff, and this is an attempt
|
||||
to organize the build time options
|
||||
|
||||
Option categories
|
||||
|
||||
BUILD_* - BUILD_COMPILER, etc...
|
||||
definitions about the build machine
|
||||
|
||||
HOST_*
|
||||
definitions about the host machine
|
||||
|
||||
FEAT_*
|
||||
definitions about the features that this build targets
|
||||
This is higly related to HOST_*, but it's for options that might
|
||||
or might not be avaiable depending on the target host, or that
|
||||
features that are irrelevant of the host
|
||||
|
||||
Eg, Alsa, Pulse Audio and OSS might sense as HOST dedinitions
|
||||
but it usually makes more sense to detect them as runtime. In
|
||||
that context, HOST_ALSA makes no sense because the host might
|
||||
or might not have alsa installed/ running
|
||||
|
||||
MMU makes no sense as a HOST definition at all, so it should
|
||||
be FEAT_HAS_MMU
|
||||
|
||||
TARGET_*
|
||||
A preconfigured default. Eg TARGET_WIN86.
|
||||
|
||||
Naming of options, option values, and how to use them
|
||||
|
||||
for options that makes sense to have a list of values
|
||||
{CATEGORY}_{OPTION}
|
||||
{OPTION}_{VALUE}
|
||||
|
||||
eg.
|
||||
BUILD_COMPILER == COMPILER_GCC, HOST_CPU != CPU_X64, ...
|
||||
|
||||
for options that are boolean
|
||||
{CATEGORY}_IS_{OPTION} or {CATEGORY}_HAS_{OPTION}
|
||||
|
||||
Evaluates to 0 or 1
|
||||
|
||||
If an configuration cannot be neatly split into a set of
|
||||
of orthogonal options, then it makes sense to break things
|
||||
to "sets" or have a hierarchy of options.
|
||||
|
||||
Example
|
||||
-------
|
||||
|
||||
In the beggining it made sense to have an audio backend
|
||||
per operating system. It made sense to have it depend
|
||||
on HOST_OS and seleect DirectSound or alsa.
|
||||
|
||||
// no option needed
|
||||
|
||||
Then, as android was introduced, which also uses OS_LINUX
|
||||
atm, the audio could have been made an option. It could be
|
||||
a HOST_* option, or FEAT_* one. I'd prefer FEAT_*.
|
||||
FEAT_* makes more sense as future wise we might want
|
||||
to support multiple backends.
|
||||
|
||||
FEAT_AUDIO_BACKEND
|
||||
AUDIO_BACKEND_NONE
|
||||
AUDIO_BACKEND_DS
|
||||
AUDIO_BACKEND_ALSA
|
||||
AUDIO_BACKEND_ANDROID
|
||||
|
||||
Used like
|
||||
#if FEAT_AUDIO_BACKEND == AUDIO_BACKEND_DS ....
|
||||
|
||||
At some point, we might have multiple audio backends that
|
||||
can be compiled in and autodetected/selected at runtime.
|
||||
In that case, it might make sense to have the options like
|
||||
|
||||
FEAT_HAS_ALSA
|
||||
FEAT_HAS_DIRECTSOUND
|
||||
FEAT_HAS_ANDROID_AUDIO
|
||||
|
||||
or
|
||||
FEAT_HAS_AUDIO_ALSA
|
||||
FEAT_HAS_AUDIO_DS
|
||||
FEAT_HAS_AUDIO_ANDROID
|
||||
|
||||
The none option might or might not make sense. In this
|
||||
case it can be removed, as it should always be avaiable.
|
||||
|
||||
Guidelines
|
||||
----------
|
||||
|
||||
General rule of thumb, don't overcomplicate things. Start
|
||||
with a simple option, and then make it more complicated
|
||||
as new uses apply (see the example above)
|
||||
|
||||
Don't use too long names, don't use too cryptic names.
|
||||
Most team developers should be able to understand or
|
||||
figure out most of the acronyms used.
|
||||
|
||||
Try to be consistent on the acronyms across all definitions
|
||||
|
||||
Code shouldn't depend on build level options whenever possible
|
||||
|
||||
Generally, the file should compile even if the option/module is
|
||||
disabled. This makes makefiles etc much easier to write
|
||||
|
||||
TARGET_* options should generally only be used in this file
|
||||
|
||||
The current source is *not* good example of these guidelines
|
||||
|
||||
We'll try to be smart and figure out some options/defaults on this file
|
||||
but this shouldn't get too complicated
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
//#define STRICT_MODE
|
||||
#ifndef STRICT_MODE
|
||||
#define FAST_MMU
|
||||
#define USE_WINCE_HACK
|
||||
#endif
|
||||
|
||||
#define DC_PLATFORM_MASK 7
|
||||
#define DC_PLATFORM_DREAMCAST 0 /* Works, for the most part */
|
||||
#define DC_PLATFORM_DEV_UNIT 1 /* This is missing hardware */
|
||||
#define DC_PLATFORM_NAOMI 2 /* Works, for the most part */
|
||||
#define DC_PLATFORM_NAOMI2 3 /* Needs to be done, 2xsh4 + 2xpvr + custom TNL */
|
||||
#define DC_PLATFORM_ATOMISWAVE 4 /* Works, for the most part */
|
||||
#define DC_PLATFORM_HIKARU 5 /* Needs to be done, 2xsh4, 2x aica , custom vpu */
|
||||
#define DC_PLATFORM_AURORA 6 /* Needs to be done, Uses newer 300 mhz sh4 + 150 mhz pvr mbx SoC */
|
||||
#define DC_PLATFORM_DREAMCAST 0
|
||||
#define DC_PLATFORM_DEV_UNIT 1
|
||||
#define DC_PLATFORM_NAOMI 2
|
||||
#define DC_PLATFORM_NAOMI2 3
|
||||
#define DC_PLATFORM_ATOMISWAVE 4
|
||||
#define DC_PLATFORM_SYSTEMSP 5
|
||||
|
||||
//HOST_CPU
|
||||
#define CPU_X86 0x20000001
|
||||
@@ -139,13 +21,10 @@
|
||||
#define CPU_PPC 0x20000006
|
||||
#define CPU_PPC64 0x20000007
|
||||
#define CPU_ARM64 0x20000008
|
||||
#define CPU_MIPS64 0x20000009
|
||||
|
||||
//FEAT_SHREC, FEAT_AREC, FEAT_DSPREC
|
||||
#define DYNAREC_NONE 0x40000001
|
||||
#define DYNAREC_JIT 0x40000002
|
||||
#define DYNAREC_CPP 0x40000003
|
||||
|
||||
|
||||
//automatic
|
||||
|
||||
@@ -175,19 +54,17 @@
|
||||
#define FEAT_DSPREC DYNAREC_NONE
|
||||
#endif
|
||||
|
||||
#if defined(TARGET_NO_JIT)
|
||||
#define FEAT_SHREC DYNAREC_CPP
|
||||
#define FEAT_AREC DYNAREC_NONE
|
||||
#define FEAT_DSPREC DYNAREC_NONE
|
||||
#ifdef __SWITCH__
|
||||
#define FEAT_NO_RWX_PAGES
|
||||
#endif
|
||||
|
||||
//defaults
|
||||
|
||||
#ifndef FEAT_SHREC
|
||||
#if HOST_CPU == CPU_MIPS
|
||||
#define FEAT_SHREC DYNAREC_NONE
|
||||
#else
|
||||
#if HOST_CPU == CPU_ARM || HOST_CPU == CPU_ARM64 || HOST_CPU == CPU_X86 || HOST_CPU == CPU_X64
|
||||
#define FEAT_SHREC DYNAREC_JIT
|
||||
#else
|
||||
#define FEAT_SHREC DYNAREC_NONE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -200,30 +77,13 @@
|
||||
#endif
|
||||
|
||||
#ifndef FEAT_DSPREC
|
||||
#if HOST_CPU == CPU_X86 || HOST_CPU == CPU_ARM64 || HOST_CPU == CPU_X64
|
||||
#if HOST_CPU == CPU_ARM || HOST_CPU == CPU_ARM64 || HOST_CPU == CPU_X86 || HOST_CPU == CPU_X64
|
||||
#define FEAT_DSPREC DYNAREC_JIT
|
||||
#else
|
||||
#define FEAT_DSPREC DYNAREC_NONE
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HOST_CPU == CPU_X64 || HOST_CPU == CPU_ARM64
|
||||
#define HOST_64BIT_CPU
|
||||
#endif
|
||||
|
||||
#define USE_MINIUPNPC
|
||||
|
||||
// Compiler Related
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#define ATTR_USED __attribute__((used))
|
||||
#define ATTR_UNUSED __attribute__((used))
|
||||
#else
|
||||
#define ATTR_USED
|
||||
#define ATTR_UNUSED
|
||||
#endif
|
||||
|
||||
|
||||
// Some restrictions on FEAT_NO_RWX_PAGES
|
||||
#if defined(FEAT_NO_RWX_PAGES) && FEAT_SHREC == DYNAREC_JIT
|
||||
#if HOST_CPU != CPU_X64 && HOST_CPU != CPU_ARM64
|
||||
@@ -231,22 +91,30 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
|
||||
#define TARGET_UWP
|
||||
#endif
|
||||
#ifdef HAVE_D3D11
|
||||
#define USE_DX11
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(LIBRETRO) && !defined(TARGET_NO_EXCEPTIONS)
|
||||
#define USE_GGPO
|
||||
#endif
|
||||
|
||||
#if !defined(__ANDROID__) && !defined(TARGET_IPHONE) && !defined(TARGET_UWP) \
|
||||
&& !defined(__SWITCH__) && !defined(LIBRETRO) && !defined(__NetBSD__) && !defined(__OpenBSD__)
|
||||
#define NAOMI_MULTIBOARD
|
||||
#endif
|
||||
|
||||
// TARGET PLATFORM
|
||||
|
||||
#define RAM_SIZE_MAX (32*1024*1024)
|
||||
#define VRAM_SIZE_MAX (16*1024*1024)
|
||||
#define ARAM_SIZE_MAX (8*1024*1024)
|
||||
|
||||
#define GD_CLOCK 33868800 //GDROM XTAL -- 768fs
|
||||
|
||||
#define AICA_CORE_CLOCK (GD_CLOCK*4/3) //[45158400] GD->PLL 3:4 -> AICA CORE -- 1024fs
|
||||
#define ADAC_CLOCK (AICA_CORE_CLOCK/4) //[11289600] 44100*256, AICA CORE -> PLL 4:1 -> ADAC -- 256fs
|
||||
#define AICA_ARM_CLOCK (AICA_CORE_CLOCK/2) //[22579200] AICA CORE -> PLL 2:1 -> ARM
|
||||
#define AICA_SDRAM_CLOCK (GD_CLOCK*2) //[67737600] GD-> PLL 2 -> SDRAM
|
||||
#define SH4_MAIN_CLOCK (200*1000*1000) //[200000000] XTal(13.5) -> PLL (33.3) -> PLL 1:6 (200)
|
||||
#define SH4_RAM_CLOCK (100*1000*1000) //[100000000] XTal(13.5) -> PLL (33.3) -> PLL 1:3 (100) , also suplied to HOLLY chip
|
||||
#define G2_BUS_CLOCK (25*1000*1000) //[25000000] from Holly, from SH4_RAM_CLOCK w/ 2 2:1 plls
|
||||
#define GD_CLOCK 33868800 //GDROM XTAL -- 768fs
|
||||
#define AICA_CORE_CLOCK (GD_CLOCK * 4 / 3) //[45158400] GD->PLL 3:4 -> AICA CORE -- 1024fs
|
||||
#define AICA_ARM_CLOCK (AICA_CORE_CLOCK / 2) //[22579200] AICA CORE -> PLL 2:1 -> ARM
|
||||
#define SH4_MAIN_CLOCK (200 * 1000 * 1000) //[200000000] XTal(13.5) -> PLL (33.3) -> PLL 1:6 (200)
|
||||
#define G2_BUS_CLOCK (25 * 1000 * 1000) //[25000000] from Holly, from SH4_RAM_CLOCK w/ 2 2:1 plls
|
||||
|
||||
#if defined(GLES) && !defined(GLES3) && !defined(GLES2)
|
||||
// Only use GL ES 2.0 API functions
|
||||
|
||||
@@ -82,6 +82,13 @@ s32 cfgLoadInt(const std::string& section, const std::string& key, s32 def)
|
||||
return cfgdb.get_int(section, key, def);
|
||||
}
|
||||
|
||||
int64_t cfgLoadInt64(const std::string& section, const std::string& key, int64_t def) {
|
||||
return cfgdb.get_int64(section, key, def);
|
||||
}
|
||||
void cfgSaveInt64(const std::string& section, const std::string& key, int64_t value) {
|
||||
cfgdb.set_int64(section, key, value);
|
||||
}
|
||||
|
||||
void cfgSaveBool(const std::string& section, const std::string& key, bool value)
|
||||
{
|
||||
cfgSaveStr(section, key, value ? "yes" : "no");
|
||||
@@ -112,6 +119,11 @@ void cfgDeleteSection(const std::string& section)
|
||||
cfgdb.delete_section(section);
|
||||
}
|
||||
|
||||
void cfgDeleteEntry(const std::string& section, const std::string& key)
|
||||
{
|
||||
cfgdb.delete_entry(section, key);
|
||||
}
|
||||
|
||||
void cfgSetAutoSave(bool autoSave)
|
||||
{
|
||||
::autoSave = autoSave;
|
||||
|
||||
+4
-1
@@ -5,6 +5,8 @@
|
||||
bool cfgOpen();
|
||||
s32 cfgLoadInt(const std::string& section, const std::string& key, s32 def);
|
||||
void cfgSaveInt(const std::string& section, const std::string& key, s32 value);
|
||||
int64_t cfgLoadInt64(const std::string& section, const std::string& key, int64_t def);
|
||||
void cfgSaveInt64(const std::string& section, const std::string& key, int64_t value);
|
||||
std::string cfgLoadStr(const std::string& section, const std::string& key, const std::string& def);
|
||||
void cfgSaveStr(const std::string& section, const std::string& key, const std::string& value);
|
||||
void cfgSaveBool(const std::string& section, const std::string& key, bool value);
|
||||
@@ -12,8 +14,9 @@ bool cfgLoadBool(const std::string& section, const std::string& key, bool def);
|
||||
void cfgSetVirtual(const std::string& section, const std::string& key, const std::string& value);
|
||||
bool cfgIsVirtual(const std::string& section, const std::string& key);
|
||||
|
||||
bool ParseCommandLine(int argc, char *argv[]);
|
||||
void ParseCommandLine(int argc, char *argv[]);
|
||||
|
||||
void cfgSetAutoSave(bool autoSave);
|
||||
bool cfgHasSection(const std::string& section);
|
||||
void cfgDeleteSection(const std::string& section);
|
||||
void cfgDeleteEntry(const std::string& section, const std::string& key);
|
||||
+48
-71
@@ -1,92 +1,66 @@
|
||||
/*
|
||||
Command line parsing
|
||||
~yay~
|
||||
|
||||
Nothing too interesting here, really
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cctype>
|
||||
#include <cstring>
|
||||
|
||||
#include "cfg/cfg.h"
|
||||
#include "stdclass.h"
|
||||
|
||||
char* trim_ws(char* str)
|
||||
{
|
||||
if (str==0 || strlen(str)==0)
|
||||
return 0;
|
||||
|
||||
while(*str)
|
||||
{
|
||||
if (!isspace(*str))
|
||||
break;
|
||||
str++;
|
||||
}
|
||||
|
||||
size_t l=strlen(str);
|
||||
|
||||
if (l==0)
|
||||
return 0;
|
||||
|
||||
while(l>0)
|
||||
{
|
||||
if (!isspace(str[l-1]))
|
||||
break;
|
||||
str[l-1]=0;
|
||||
l--;
|
||||
}
|
||||
|
||||
if (l==0)
|
||||
return 0;
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
int setconfig(char** arg,int cl)
|
||||
static int setconfig(char *arg[], int cl)
|
||||
{
|
||||
int rv=0;
|
||||
for(;;)
|
||||
|
||||
if (cl < 1)
|
||||
{
|
||||
if (cl<1)
|
||||
WARN_LOG(COMMON, "-config : invalid number of parameters, format is section:key=value,section:key=value,...");
|
||||
return rv;
|
||||
}
|
||||
|
||||
std::string value(arg[1]);
|
||||
for(;;)
|
||||
{
|
||||
auto seppos = value.find(':');
|
||||
if (seppos == std::string::npos)
|
||||
{
|
||||
WARN_LOG(COMMON, "-config : invalid number of parameters, format is section:key=value");
|
||||
return rv;
|
||||
WARN_LOG(COMMON, "-config : invalid parameter %s, format is section:key=value,section:key=value,...", value.c_str());
|
||||
break;
|
||||
}
|
||||
char* sep=strstr(arg[1],":");
|
||||
if (sep==0)
|
||||
auto eqpos = value.find('=', seppos);
|
||||
if (eqpos == std::string::npos)
|
||||
{
|
||||
WARN_LOG(COMMON, "-config : invalid parameter %s, format is section:key=value", arg[1]);
|
||||
return rv;
|
||||
}
|
||||
char* value=strstr(sep+1,"=");
|
||||
if (value==0)
|
||||
{
|
||||
WARN_LOG(COMMON, "-config : invalid parameter %s, format is section:key=value", arg[1]);
|
||||
return rv;
|
||||
WARN_LOG(COMMON, "-config : invalid parameter %s, format is section:key=value,section:key=value,...", value.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
*sep++=0;
|
||||
*value++=0;
|
||||
auto commapos = value.find(',', eqpos);
|
||||
|
||||
char* sect=trim_ws(arg[1]);
|
||||
char* key=trim_ws(sep);
|
||||
value=trim_ws(value);
|
||||
std::string sect = trim_ws(value.substr(0, seppos));
|
||||
std::string key = trim_ws(value.substr(seppos + 1, eqpos - seppos - 1));
|
||||
auto endofcurrent = (commapos == std::string::npos) ? value.size() : commapos;
|
||||
std::string next = (commapos == std::string::npos) ? "" : trim_ws(value.substr(endofcurrent + 1, value.size() - endofcurrent));
|
||||
value = trim_ws(value.substr(eqpos + 1, endofcurrent - eqpos - 1));
|
||||
|
||||
if (sect==0 || key==0)
|
||||
if (sect.empty() || key.empty())
|
||||
{
|
||||
WARN_LOG(COMMON, "-config : invalid parameter, format is section:key=value");
|
||||
return rv;
|
||||
WARN_LOG(COMMON, "-config : invalid parameter, format is section:key=value,section:key=value,...");
|
||||
break;
|
||||
}
|
||||
|
||||
const char* constval = value;
|
||||
if (constval==0)
|
||||
constval="";
|
||||
INFO_LOG(COMMON, "Virtual cfg %s:%s=%s", sect, key, value);
|
||||
INFO_LOG(COMMON, "Virtual cfg %s:%s=%s", sect.c_str(), key.c_str(), value.c_str());
|
||||
|
||||
cfgSetVirtual(sect,key,value);
|
||||
rv++;
|
||||
cfgSetVirtual(sect, key, value);
|
||||
|
||||
if (cl>=3 && stricmp(arg[2],",")==0)
|
||||
if (commapos == std::string::npos)
|
||||
rv++;
|
||||
|
||||
if (commapos != std::string::npos)
|
||||
{
|
||||
value = next;
|
||||
continue;
|
||||
}
|
||||
else if (cl>=3 && strcmp(arg[2],",")==0)
|
||||
{
|
||||
cl-=2;
|
||||
arg+=2;
|
||||
@@ -112,9 +86,9 @@ static int showhelp()
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool ParseCommandLine(int argc,char* argv[])
|
||||
void ParseCommandLine(int argc,char* argv[])
|
||||
{
|
||||
settings.imgread.ImagePath[0] = '\0';
|
||||
settings.content.path.clear();
|
||||
int cl=argc-2;
|
||||
char** arg=argv+1;
|
||||
while(cl>=0)
|
||||
@@ -136,6 +110,10 @@ bool ParseCommandLine(int argc,char* argv[])
|
||||
cl--;
|
||||
}
|
||||
#endif
|
||||
else if ((*arg)[0] == '-')
|
||||
{
|
||||
WARN_LOG(COMMON, "Ignoring unknown command line option '%s'", *arg);
|
||||
}
|
||||
else
|
||||
{
|
||||
char* extension = strrchr(*arg, '.');
|
||||
@@ -145,22 +123,21 @@ bool ParseCommandLine(int argc,char* argv[])
|
||||
|| stricmp(extension, ".gdi") == 0 || stricmp(extension, ".cue") == 0))
|
||||
{
|
||||
INFO_LOG(COMMON, "Using '%s' as cd image", *arg);
|
||||
strcpy(settings.imgread.ImagePath, *arg);
|
||||
settings.content.path = *arg;
|
||||
}
|
||||
else if (extension && stricmp(extension, ".elf") == 0)
|
||||
{
|
||||
INFO_LOG(COMMON, "Using '%s' as reios elf file", *arg);
|
||||
cfgSetVirtual("config", "bios.UseReios", "yes");
|
||||
strcpy(settings.imgread.ImagePath, *arg);
|
||||
settings.content.path = *arg;
|
||||
}
|
||||
else
|
||||
{
|
||||
INFO_LOG(COMMON, "Using '%s' as rom", *arg);
|
||||
strcpy(settings.imgread.ImagePath, *arg);
|
||||
settings.content.path = *arg;
|
||||
}
|
||||
}
|
||||
arg++;
|
||||
cl--;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
+56
-69
@@ -1,7 +1,7 @@
|
||||
#include "ini.h"
|
||||
#include "types.h"
|
||||
#include <sstream>
|
||||
|
||||
char* trim_ws(char* str);
|
||||
#include "stdclass.h"
|
||||
|
||||
namespace emucfg {
|
||||
|
||||
@@ -24,6 +24,14 @@ int ConfigEntry::get_int()
|
||||
}
|
||||
}
|
||||
|
||||
int64_t ConfigEntry::get_int64()
|
||||
{
|
||||
int base = 10;
|
||||
if (strstr(this->value.c_str(), "0x") != nullptr)
|
||||
base = 16;
|
||||
return (int64_t)strtoll(this->value.c_str(), nullptr, base);
|
||||
}
|
||||
|
||||
bool ConfigEntry::get_bool()
|
||||
{
|
||||
if (stricmp(this->value.c_str(), "yes") == 0 ||
|
||||
@@ -158,6 +166,19 @@ int ConfigFile::get_int(const std::string& section_name, const std::string& entr
|
||||
}
|
||||
}
|
||||
|
||||
int64_t ConfigFile::get_int64(const std::string& section_name, const std::string& entry_name, int64_t default_value)
|
||||
{
|
||||
ConfigEntry* entry = this->get_entry(section_name, entry_name);
|
||||
if (entry == NULL)
|
||||
{
|
||||
return default_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
return entry->get_int64();
|
||||
}
|
||||
}
|
||||
|
||||
bool ConfigFile::get_bool(const std::string& section_name, const std::string& entry_name, bool default_value)
|
||||
{
|
||||
ConfigEntry* entry = this->get_entry(section_name, entry_name);
|
||||
@@ -188,6 +209,13 @@ void ConfigFile::set_int(const std::string& section_name, const std::string& ent
|
||||
this->set(section_name, entry_name, str_value.str(), is_virtual);
|
||||
}
|
||||
|
||||
void ConfigFile::set_int64(const std::string& section_name, const std::string& entry_name, int64_t value, bool is_virtual)
|
||||
{
|
||||
std::stringstream str_value;
|
||||
str_value << value;
|
||||
this->set(section_name, entry_name, str_value.str(), is_virtual);
|
||||
}
|
||||
|
||||
void ConfigFile::set_bool(const std::string& section_name, const std::string& entry_name, bool value, bool is_virtual)
|
||||
{
|
||||
std::string str_value = (value ? "yes" : "no");
|
||||
@@ -196,94 +224,53 @@ void ConfigFile::set_bool(const std::string& section_name, const std::string& en
|
||||
|
||||
void ConfigFile::parse(FILE* file)
|
||||
{
|
||||
if(file == NULL)
|
||||
{
|
||||
if (file == nullptr)
|
||||
return;
|
||||
}
|
||||
|
||||
char line[512];
|
||||
char current_section[512] = { '\0' };
|
||||
std::string section;
|
||||
int cline = 0;
|
||||
while(file && !feof(file))
|
||||
while (true)
|
||||
{
|
||||
if (std::fgets(line, 512, file) == NULL || std::feof(file))
|
||||
{
|
||||
if (std::fgets(line, sizeof(line), file) == nullptr)
|
||||
break;
|
||||
}
|
||||
|
||||
cline++;
|
||||
|
||||
if (strlen(line) < 3)
|
||||
std::string s(line);
|
||||
s = trim_ws(s, " \r\n");
|
||||
if (s.empty())
|
||||
continue;
|
||||
if (s.length() >= 3 && s[0] == '[' && s[s.length() - 1] == ']')
|
||||
{
|
||||
section = s.substr(1, s.length() - 2);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (line[strlen(line)-1] == '\r' ||
|
||||
line[strlen(line)-1] == '\n')
|
||||
auto eqpos = s.find('=');
|
||||
if (eqpos == std::string::npos)
|
||||
{
|
||||
line[strlen(line)-1] = '\0';
|
||||
}
|
||||
|
||||
char* tl = trim_ws(line);
|
||||
|
||||
if (tl[0] == '[' && tl[strlen(tl)-1] == ']')
|
||||
{
|
||||
tl[strlen(tl)-1] = '\0';
|
||||
|
||||
// FIXME: Data loss if buffer is too small
|
||||
strncpy(current_section, tl+1, sizeof(current_section));
|
||||
current_section[sizeof(current_section) - 1] = '\0';
|
||||
|
||||
trim_ws(current_section);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (strlen(current_section) == 0)
|
||||
{
|
||||
continue; //no open section
|
||||
}
|
||||
|
||||
char* separator = strstr(tl, "=");
|
||||
|
||||
if (!separator)
|
||||
{
|
||||
WARN_LOG(COMMON, "Malformed entry on config - ignoring @ %d(%s)", cline, tl);
|
||||
continue;
|
||||
}
|
||||
|
||||
*separator = '\0';
|
||||
|
||||
char* name = trim_ws(tl);
|
||||
char* value = trim_ws(separator + 1);
|
||||
if (name == NULL || value == NULL)
|
||||
{
|
||||
//printf("Malformed entry on config - ignoring @ %d(%s)\n",cline, tl);
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->set(std::string(current_section), std::string(name), std::string(value));
|
||||
}
|
||||
WARN_LOG(COMMON, "Malformed entry on config - ignoring line %d: %s", cline, s.c_str());
|
||||
continue;
|
||||
}
|
||||
std::string property = trim_ws(s.substr(0, eqpos));
|
||||
std::string value = trim_ws(s.substr(eqpos + 1));
|
||||
if (value.length() >= 2 && value[0] == '"' && value[value.length() - 1] == '"')
|
||||
value = value.substr(1, value.length() - 2);
|
||||
set(section, property, value);
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigFile::save(FILE* file)
|
||||
{
|
||||
for (const auto& section_it : this->sections)
|
||||
for (const auto& [section_name, section] : this->sections)
|
||||
{
|
||||
const std::string& section_name = section_it.first;
|
||||
const ConfigSection& section = section_it.second;
|
||||
if (!section_name.empty())
|
||||
std::fprintf(file, "[%s]\n", section_name.c_str());
|
||||
|
||||
std::fprintf(file, "[%s]\n", section_name.c_str());
|
||||
|
||||
for (const auto& entry_it : section.entries)
|
||||
for (const auto& [entry_name, entry] : section.entries)
|
||||
{
|
||||
const std::string& entry_name = entry_it.first;
|
||||
const ConfigEntry& entry = entry_it.second;
|
||||
std::fprintf(file, "%s = %s\n", entry_name.c_str(), entry.get_string().c_str());
|
||||
}
|
||||
|
||||
std::fputs("\n", file);
|
||||
if (!section_name.empty())
|
||||
std::fputc('\n', file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+7
-1
@@ -1,6 +1,9 @@
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
|
||||
namespace emucfg {
|
||||
|
||||
@@ -9,6 +12,7 @@ struct ConfigEntry {
|
||||
const std::string& get_string() const;
|
||||
int get_int();
|
||||
bool get_bool();
|
||||
int64_t get_int64();
|
||||
};
|
||||
|
||||
struct ConfigSection {
|
||||
@@ -39,10 +43,12 @@ struct ConfigFile {
|
||||
/* getting values */
|
||||
std::string get(const std::string& section_name, const std::string& entry_name, const std::string& default_value = "");
|
||||
int get_int(const std::string& section_name, const std::string& entry_name, int default_value = 0);
|
||||
int64_t get_int64(const std::string& section_name, const std::string& entry_name, int64_t default_value = 0);
|
||||
bool get_bool(const std::string& section_name, const std::string& entry_name, bool default_value = false);
|
||||
/* setting values */
|
||||
void set(const std::string& section_name, const std::string& entry_name, const std::string& value, bool is_virtual = false);
|
||||
void set_int(const std::string& section_name, const std::string& entry_name, int value, bool is_virtual = false);
|
||||
void set_int64(const std::string& section_name, const std::string& entry_name, int64_t value, bool is_virtual = false);
|
||||
void set_bool(const std::string& section_name, const std::string& entry_name, bool value, bool is_virtual = false);
|
||||
|
||||
void delete_section(const std::string& section_name);
|
||||
|
||||
+64
-7
@@ -17,14 +17,15 @@
|
||||
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "option.h"
|
||||
#include "network/naomi_network.h"
|
||||
#include "debug/gdb_server.h"
|
||||
|
||||
namespace config {
|
||||
|
||||
// Dynarec
|
||||
|
||||
Option<bool> DynarecEnabled("Dynarec.Enabled", true);
|
||||
Option<bool> DynarecIdleSkip("Dynarec.idleskip", true);
|
||||
Option<bool> DynarecSafeMode("Dynarec.safe-mode");
|
||||
Option<int> Sh4Clock("Sh4Clock", 200);
|
||||
|
||||
// General
|
||||
|
||||
@@ -32,14 +33,17 @@ Option<int> Cable("Dreamcast.Cable", 3); // TV Composite
|
||||
Option<int> Region("Dreamcast.Region", 1); // USA
|
||||
Option<int> Broadcast("Dreamcast.Broadcast", 0); // NTSC
|
||||
Option<int> Language("Dreamcast.Language", 1); // English
|
||||
Option<bool> FullMMU("Dreamcast.FullMMU");
|
||||
Option<bool> ForceWindowsCE("Dreamcast.ForceWindowsCE");
|
||||
Option<bool> AutoSavestate("Dreamcast.AutoSavestate");
|
||||
Option<bool> AutoLoadState("Dreamcast.AutoLoadState");
|
||||
Option<bool> AutoSaveState("Dreamcast.AutoSaveState");
|
||||
Option<int, false> SavestateSlot("Dreamcast.SavestateSlot");
|
||||
Option<bool> ForceFreePlay("ForceFreePlay", true);
|
||||
Option<bool, false> FetchBoxart("FetchBoxart", true);
|
||||
Option<bool, false> BoxartDisplayMode("BoxartDisplayMode", true);
|
||||
Option<int, false> UIScaling("UIScaling", 100);
|
||||
|
||||
// Sound
|
||||
|
||||
Option<bool> DSPEnabled("aica.DSPEnabled", false);
|
||||
Option<bool> DisableSound("aica.NoSound");
|
||||
#if HOST_CPU == CPU_ARM
|
||||
Option<int> AudioBufferSize("aica.BufferSize", 5644); // 128 ms
|
||||
#else
|
||||
@@ -54,6 +58,8 @@ Option<bool> AutoLatency("aica.AutoLatency",
|
||||
);
|
||||
|
||||
OptionString AudioBackend("backend", "auto", "audio");
|
||||
AudioVolumeOption AudioVolume;
|
||||
Option<bool> VmuSound("VmuSound", false, "audio");
|
||||
|
||||
// Rendering
|
||||
|
||||
@@ -75,7 +81,11 @@ Option<bool> Fog("rend.Fog", true);
|
||||
Option<bool> FloatVMUs("rend.FloatVMUs");
|
||||
Option<bool> Rotate90("rend.Rotate90");
|
||||
Option<bool> PerStripSorting("rend.PerStripSorting");
|
||||
Option<bool> DelayFrameSwapping("rend.DelayFrameSwapping");
|
||||
#ifdef __APPLE__
|
||||
Option<bool> DelayFrameSwapping("rend.DelayFrameSwapping", false);
|
||||
#else
|
||||
Option<bool> DelayFrameSwapping("rend.DelayFrameSwapping", true);
|
||||
#endif
|
||||
Option<bool> WidescreenGameHacks("rend.WidescreenGameHacks");
|
||||
std::array<Option<int>, 4> CrosshairColor {
|
||||
Option<int>("rend.CrossHairColor1"),
|
||||
@@ -83,22 +93,49 @@ std::array<Option<int>, 4> CrosshairColor {
|
||||
Option<int>("rend.CrossHairColor3"),
|
||||
Option<int>("rend.CrossHairColor4"),
|
||||
};
|
||||
Option<int> CrosshairSize("rend.CrosshairSize", 40);
|
||||
Option<int> SkipFrame("ta.skip");
|
||||
Option<int> MaxThreads("pvr.MaxThreads", 3);
|
||||
Option<int> AutoSkipFrame("pvr.AutoSkipFrame", 0);
|
||||
Option<int> RenderResolution("rend.Resolution", 480);
|
||||
Option<bool> VSync("rend.vsync", true);
|
||||
Option<int64_t> PixelBufferSize("rend.PixelBufferSize", 512_MB);
|
||||
Option<int> AnisotropicFiltering("rend.AnisotropicFiltering", 1);
|
||||
Option<int> TextureFiltering("rend.TextureFiltering", 0); // Default
|
||||
Option<bool> ThreadedRendering("rend.ThreadedRendering", true);
|
||||
Option<bool> DupeFrames("rend.DupeFrames", false);
|
||||
Option<int> PerPixelLayers("rend.PerPixelLayers", 32);
|
||||
Option<bool> NativeDepthInterpolation("rend.NativeDepthInterpolation", false);
|
||||
Option<bool> EmulateFramebuffer("rend.EmulateFramebuffer", false);
|
||||
Option<bool> FixUpscaleBleedingEdge("rend.FixUpscaleBleedingEdge", true);
|
||||
#ifdef VIDEO_ROUTING
|
||||
Option<bool, false> VideoRouting("rend.VideoRouting", false);
|
||||
Option<bool, false> VideoRoutingScale("rend.VideoRoutingScale", false);
|
||||
Option<int, false> VideoRoutingVRes("rend.VideoRoutingVRes", 720);
|
||||
#endif
|
||||
|
||||
// Misc
|
||||
|
||||
Option<bool> SerialConsole("Debug.SerialConsoleEnabled");
|
||||
Option<bool> SerialPTY("Debug.SerialPTY");
|
||||
Option<bool> GDB("Debug.GDBEnabled");
|
||||
Option<int> GDBPort("Debug.GDBPort", debugger::DEFAULT_PORT);
|
||||
Option<bool> GDBWaitForConnection("Debug.GDBWaitForConnection");
|
||||
Option<bool> UseReios("UseReios");
|
||||
Option<bool> FastGDRomLoad("FastGDRomLoad", false);
|
||||
Option<bool> RamMod32MB("Dreamcast.RamMod32MB", false);
|
||||
|
||||
Option<bool> OpenGlChecks("OpenGlChecks", false, "validate");
|
||||
|
||||
Option<std::vector<std::string>, false> ContentPath("Dreamcast.ContentPath");
|
||||
Option<bool, false> HideLegacyNaomiRoms("Dreamcast.HideLegacyNaomiRoms", true);
|
||||
Option<bool, false> UploadCrashLogs("UploadCrashLogs", true);
|
||||
|
||||
// Profiler
|
||||
Option<bool> ProfilerEnabled("Profiler.Enabled");
|
||||
Option<bool> ProfilerDrawToGUI("Profiler.DrawGUI");
|
||||
Option<bool> ProfilerOutputTTY("Profiler.OutputTTY");
|
||||
Option<float> ProfilerFrameWarningTime("Profiler.FrameWarningTime", 1.0f / 55.0f);
|
||||
|
||||
// Network
|
||||
|
||||
@@ -106,7 +143,19 @@ Option<bool> NetworkEnable("Enable", false, "network");
|
||||
Option<bool> ActAsServer("ActAsServer", false, "network");
|
||||
OptionString DNS("DNS", "46.101.91.123", "network");
|
||||
OptionString NetworkServer("server", "", "network");
|
||||
Option<int> LocalPort("LocalPort", NaomiNetwork::SERVER_PORT, "network");
|
||||
Option<bool> EmulateBBA("EmulateBBA", false, "network");
|
||||
Option<bool> EnableUPnP("EnableUPnP", true, "network");
|
||||
Option<bool> GGPOEnable("GGPO", false, "network");
|
||||
Option<int> GGPODelay("GGPODelay", 0, "network");
|
||||
Option<bool> NetworkStats("Stats", true, "network");
|
||||
Option<int> GGPOAnalogAxes("GGPOAnalogAxes", 0, "network");
|
||||
Option<bool> GGPOChat("GGPOChat", true, "network");
|
||||
Option<bool> GGPOChatTimeoutToggle("GGPOChatTimeoutToggle", true, "network");
|
||||
Option<int> GGPOChatTimeout("GGPOChatTimeout", 10, "network");
|
||||
Option<bool> NetworkOutput("NetworkOutput", false, "network");
|
||||
Option<int> MultiboardSlaves("MultiboardSlaves", 1, "network");
|
||||
Option<bool> BattleCableEnable("BattleCable", false, "network");
|
||||
|
||||
#ifdef SUPPORT_DISPMANX
|
||||
Option<bool> DispmanxMaintainAspect("maintain_aspect", true, "dispmanx");
|
||||
@@ -141,5 +190,13 @@ std::array<std::array<Option<MapleDeviceType>, 2>, 4> MapleExpansionDevices {
|
||||
Option<MapleDeviceType>("device4.1", MDT_None, "input"),
|
||||
Option<MapleDeviceType>("device4.2", MDT_None, "input"),
|
||||
};
|
||||
Option<bool> PerGameVmu("PerGameVmu", false, "config");
|
||||
#ifdef _WIN32
|
||||
Option<bool, false> UseRawInput("RawInput", false, "input");
|
||||
#endif
|
||||
|
||||
#ifdef USE_LUA
|
||||
Option<std::string, false> LuaFileName("LuaFileName", "flycast.lua");
|
||||
#endif
|
||||
|
||||
} // namespace config
|
||||
+217
-79
@@ -20,8 +20,13 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <array>
|
||||
#include <cmath>
|
||||
#include <type_traits>
|
||||
#include "cfg.h"
|
||||
#include "hw/maple/maple_cfg.h"
|
||||
#ifdef LIBRETRO
|
||||
#include <libretro.h>
|
||||
#endif
|
||||
|
||||
namespace config {
|
||||
|
||||
@@ -33,6 +38,10 @@ public:
|
||||
virtual void reset() = 0;
|
||||
};
|
||||
|
||||
#ifdef LIBRETRO
|
||||
#include "option_lr.h"
|
||||
#else
|
||||
|
||||
class Settings {
|
||||
public:
|
||||
void reset() {
|
||||
@@ -62,10 +71,6 @@ public:
|
||||
cfgSetAutoSave(true);
|
||||
}
|
||||
|
||||
const std::string& getGameId() const {
|
||||
return gameId;
|
||||
}
|
||||
|
||||
void setGameId(const std::string& gameId) {
|
||||
this->gameId = gameId;
|
||||
}
|
||||
@@ -96,10 +101,6 @@ private:
|
||||
friend class Option;
|
||||
};
|
||||
|
||||
// Missing in C++11
|
||||
template <bool B, typename T = void>
|
||||
using enable_if_t = typename std::enable_if<B, T>::type;
|
||||
|
||||
template<typename T, bool PerGameOption = true>
|
||||
class Option : public BaseOption {
|
||||
public:
|
||||
@@ -117,7 +118,7 @@ public:
|
||||
|
||||
void load() override {
|
||||
if (PerGameOption && settings.hasPerGameConfig())
|
||||
set(doLoad(settings.getGameId(), section + "." + name));
|
||||
set(doLoad(settings.gameId, section + "." + name));
|
||||
else
|
||||
{
|
||||
set(doLoad(section, name));
|
||||
@@ -138,10 +139,14 @@ public:
|
||||
else if (PerGameOption && settings.hasPerGameConfig())
|
||||
{
|
||||
if (value == doLoad(section, name))
|
||||
{
|
||||
// delete existing per-game option if any
|
||||
cfgDeleteEntry(settings.gameId, section + "." + name);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (PerGameOption && settings.hasPerGameConfig())
|
||||
doSave(settings.getGameId(), section + "." + name);
|
||||
doSave(settings.gameId, section + "." + name);
|
||||
else
|
||||
doSave(section, name);
|
||||
}
|
||||
@@ -149,8 +154,8 @@ public:
|
||||
T& get() { return value; }
|
||||
void set(T v) { value = v; }
|
||||
|
||||
void override(T v) {
|
||||
verify(PerGameOption);
|
||||
void override(T v)
|
||||
{
|
||||
overriddenDefault = v;
|
||||
overridden = true;
|
||||
value = v;
|
||||
@@ -165,40 +170,47 @@ public:
|
||||
|
||||
protected:
|
||||
template <typename U = T>
|
||||
enable_if_t<std::is_same<U, bool>::value, T>
|
||||
std::enable_if_t<std::is_same_v<U, bool>, T>
|
||||
doLoad(const std::string& section, const std::string& name) const
|
||||
{
|
||||
return cfgLoadBool(section, name, value);
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
enable_if_t<(std::is_integral<U>::value || std::is_enum<U>::value)
|
||||
&& !std::is_same<U, bool>::value, T>
|
||||
std::enable_if_t<std::is_same<U, int64_t>::value, T>
|
||||
doLoad(const std::string& section, const std::string& name) const
|
||||
{
|
||||
return cfgLoadInt64(section, name, value);
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
std::enable_if_t<(std::is_integral_v<U> || std::is_enum_v<U>)
|
||||
&& !std::is_same_v<U, bool> && !std::is_same_v<U, int64_t>, T>
|
||||
doLoad(const std::string& section, const std::string& name) const
|
||||
{
|
||||
return (T)cfgLoadInt(section, name, (int)value);
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
enable_if_t<std::is_same<U, std::string>::value, T>
|
||||
std::enable_if_t<std::is_same_v<U, std::string>, T>
|
||||
doLoad(const std::string& section, const std::string& name) const
|
||||
{
|
||||
return cfgLoadStr(section, name, value);
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
enable_if_t<std::is_same<float, U>::value, T>
|
||||
std::enable_if_t<std::is_same_v<float, U>, T>
|
||||
doLoad(const std::string& section, const std::string& name) const
|
||||
{
|
||||
std::string strValue = cfgLoadStr(section, name, "");
|
||||
if (strValue.empty())
|
||||
return value;
|
||||
else
|
||||
return atof(strValue.c_str());
|
||||
return (float)atof(strValue.c_str());
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
enable_if_t<std::is_same<std::vector<std::string>, U>::value, T>
|
||||
std::enable_if_t<std::is_same_v<std::vector<std::string>, U>, T>
|
||||
doLoad(const std::string& section, const std::string& name) const
|
||||
{
|
||||
std::string paths = cfgLoadStr(section, name, "");
|
||||
@@ -208,42 +220,85 @@ protected:
|
||||
std::vector<std::string> newValue;
|
||||
while (true)
|
||||
{
|
||||
std::string::size_type end = paths.find(';', start);
|
||||
if (end == std::string::npos)
|
||||
end = paths.size();
|
||||
if (start != end)
|
||||
newValue.push_back(paths.substr(start, end - start));
|
||||
if (end == paths.size())
|
||||
break;
|
||||
start = end + 1;
|
||||
if (paths[start] == '"')
|
||||
{
|
||||
std::string v;
|
||||
start++;
|
||||
while (true)
|
||||
{
|
||||
if (paths[start] == '"')
|
||||
{
|
||||
if (start + 1 >= paths.size())
|
||||
{
|
||||
newValue.push_back(v);
|
||||
return newValue;
|
||||
}
|
||||
if (paths[start + 1] == '"')
|
||||
{
|
||||
v += paths[start++];
|
||||
start++;
|
||||
}
|
||||
else if (paths[start + 1] == ';')
|
||||
{
|
||||
newValue.push_back(v);
|
||||
start += 2;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
v += paths[start++];
|
||||
}
|
||||
}
|
||||
else
|
||||
v += paths[start++];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string::size_type end = paths.find(';', start);
|
||||
if (end == std::string::npos)
|
||||
end = paths.size();
|
||||
if (start != end)
|
||||
newValue.push_back(paths.substr(start, end - start));
|
||||
if (end == paths.size())
|
||||
break;
|
||||
start = end + 1;
|
||||
}
|
||||
}
|
||||
return newValue;
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
enable_if_t<std::is_same<U, bool>::value>
|
||||
std::enable_if_t<std::is_same_v<U, bool>>
|
||||
doSave(const std::string& section, const std::string& name) const
|
||||
{
|
||||
cfgSaveBool(section, name, value);
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
enable_if_t<(std::is_integral<U>::value || std::is_enum<U>::value)
|
||||
&& !std::is_same<U, bool>::value>
|
||||
std::enable_if_t<std::is_same<U, int64_t>::value>
|
||||
doSave(const std::string& section, const std::string& name) const
|
||||
{
|
||||
cfgSaveInt64(section, name, value);
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
std::enable_if_t<(std::is_integral_v<U> || std::is_enum_v<U>)
|
||||
&& !std::is_same_v<U, bool> && !std::is_same_v<U, int64_t>>
|
||||
doSave(const std::string& section, const std::string& name) const
|
||||
{
|
||||
cfgSaveInt(section, name, (int)value);
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
enable_if_t<std::is_same<U, std::string>::value>
|
||||
std::enable_if_t<std::is_same_v<U, std::string>>
|
||||
doSave(const std::string& section, const std::string& name) const
|
||||
{
|
||||
cfgSaveStr(section, name, value);
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
enable_if_t<std::is_same<float, U>::value>
|
||||
std::enable_if_t<std::is_same_v<float, U>>
|
||||
doSave(const std::string& section, const std::string& name) const
|
||||
{
|
||||
char buf[64];
|
||||
@@ -252,16 +307,36 @@ protected:
|
||||
}
|
||||
|
||||
template <typename U = T>
|
||||
enable_if_t<std::is_same<std::vector<std::string>, U>::value>
|
||||
std::enable_if_t<std::is_same_v<std::vector<std::string>, U>>
|
||||
doSave(const std::string& section, const std::string& name) const
|
||||
{
|
||||
std::string s;
|
||||
for (auto& v : value)
|
||||
for (const auto& v : value)
|
||||
{
|
||||
if (s.empty())
|
||||
s = v;
|
||||
if (!s.empty())
|
||||
s += ';';
|
||||
if (v.find(';') != std::string::npos || (!v.empty() && v[0] == '"'))
|
||||
{
|
||||
s += '"';
|
||||
std::string v2 = v;
|
||||
while (true)
|
||||
{
|
||||
auto pos = v2.find('"');
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
s += v2.substr(0, pos + 1) + '"';
|
||||
v2 = v2.substr(pos + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
s += v2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
s += '"';
|
||||
}
|
||||
else
|
||||
s += ";" + v;
|
||||
s += v;
|
||||
}
|
||||
cfgSaveStr(section, name, s);
|
||||
}
|
||||
@@ -274,20 +349,16 @@ protected:
|
||||
bool overridden = false;
|
||||
Settings& settings;
|
||||
};
|
||||
#endif
|
||||
|
||||
using OptionString = Option<std::string>;
|
||||
|
||||
template<typename T, T value = T()>
|
||||
class ConstOption {
|
||||
public:
|
||||
operator T() const { return value; }
|
||||
};
|
||||
|
||||
// Dynarec
|
||||
|
||||
extern Option<bool> DynarecEnabled;
|
||||
extern Option<bool> DynarecIdleSkip;
|
||||
extern Option<bool> DynarecSafeMode;
|
||||
#ifndef LIBRETRO
|
||||
extern Option<int> Sh4Clock;
|
||||
#endif
|
||||
|
||||
// General
|
||||
|
||||
@@ -295,57 +366,74 @@ extern Option<int> Cable; // 0 -> VGA, 1 -> VGA, 2 -> RGB, 3 -> TV Composite
|
||||
extern Option<int> Region; // 0 -> JP, 1 -> USA, 2 -> EU, 3 -> default
|
||||
extern Option<int> Broadcast; // 0 -> NTSC, 1 -> PAL, 2 -> PAL/M, 3 -> PAL/N, 4 -> default
|
||||
extern Option<int> Language; // 0 -> JP, 1 -> EN, 2 -> DE, 3 -> FR, 4 -> SP, 5 -> IT, 6 -> default
|
||||
extern Option<bool> FullMMU;
|
||||
extern Option<bool> ForceWindowsCE;
|
||||
extern Option<bool> AutoSavestate;
|
||||
extern Option<bool> AutoLoadState;
|
||||
extern Option<bool> AutoSaveState;
|
||||
extern Option<int, false> SavestateSlot;
|
||||
extern Option<bool> ForceFreePlay;
|
||||
extern Option<bool, false> FetchBoxart;
|
||||
extern Option<bool, false> BoxartDisplayMode;
|
||||
extern Option<int, false> UIScaling;
|
||||
|
||||
// Sound
|
||||
|
||||
constexpr ConstOption<bool, true> LimitFPS;
|
||||
constexpr bool LimitFPS = true;
|
||||
extern Option<bool> DSPEnabled;
|
||||
extern Option<bool> DisableSound;
|
||||
extern Option<int> AudioBufferSize; //In samples ,*4 for bytes
|
||||
extern Option<bool> AutoLatency;
|
||||
|
||||
extern OptionString AudioBackend;
|
||||
|
||||
class AudioVolumeOption : public Option<int> {
|
||||
public:
|
||||
AudioVolumeOption() : Option<int>("aica.Volume", 100) {};
|
||||
float logarithmic_volume_scale = 1.0;
|
||||
|
||||
void load() override {
|
||||
Option<int>::load();
|
||||
calcDbPower();
|
||||
}
|
||||
|
||||
float dbPower()
|
||||
{
|
||||
return logarithmic_volume_scale;
|
||||
}
|
||||
void calcDbPower()
|
||||
{
|
||||
// dB scaling calculation: https://www.dr-lex.be/info-stuff/volumecontrols.html
|
||||
logarithmic_volume_scale = std::min(std::exp(4.605f * float(value) / 100.f) / 100.f, 1.f);
|
||||
if (value < 10)
|
||||
logarithmic_volume_scale *= value / 10.f;
|
||||
}
|
||||
};
|
||||
extern AudioVolumeOption AudioVolume;
|
||||
extern Option<bool> VmuSound;
|
||||
|
||||
// Rendering
|
||||
|
||||
class RendererOption : public Option<RenderType> {
|
||||
public:
|
||||
RendererOption()
|
||||
: Option<RenderType>("pvr.rend", RenderType::OpenGL) {}
|
||||
#ifdef LIBRETRO
|
||||
RendererOption() : Option<RenderType>("",
|
||||
#else
|
||||
RendererOption() : Option<RenderType>("pvr.rend",
|
||||
#endif
|
||||
#if defined(USE_DX11)
|
||||
RenderType::DirectX11
|
||||
#elif defined(USE_DX9)
|
||||
RenderType::DirectX9
|
||||
#elif !defined(USE_OPENGL)
|
||||
RenderType::Vulkan
|
||||
#else
|
||||
RenderType::OpenGL
|
||||
#endif
|
||||
) {}
|
||||
|
||||
bool isOpenGL() const {
|
||||
return value == RenderType::OpenGL || value == RenderType::OpenGL_OIT;
|
||||
}
|
||||
void set(RenderType v)
|
||||
{
|
||||
newValue = v;
|
||||
}
|
||||
RenderType& operator=(const RenderType& v) { set(v); return value; }
|
||||
|
||||
void load() override {
|
||||
RenderType current = value;
|
||||
Option<RenderType>::load();
|
||||
newValue = value;
|
||||
value = current;
|
||||
}
|
||||
|
||||
void reset() override {
|
||||
// don't reset the value to avoid vk -> gl -> vk quick switching
|
||||
// don't reset the value to avoid quick switching when starting a game
|
||||
overridden = false;
|
||||
}
|
||||
|
||||
bool pendingChange() {
|
||||
return newValue != value;
|
||||
}
|
||||
void commit() {
|
||||
value = newValue;
|
||||
}
|
||||
|
||||
private:
|
||||
RenderType newValue = RenderType();
|
||||
};
|
||||
extern RendererOption RendererType;
|
||||
extern Option<bool> UseMipmaps;
|
||||
@@ -355,9 +443,12 @@ extern Option<bool> ShowFPS;
|
||||
extern Option<bool> RenderToTextureBuffer;
|
||||
extern Option<bool> TranslucentPolygonDepthMask;
|
||||
extern Option<bool> ModifierVolumes;
|
||||
constexpr ConstOption<bool, true> Clipping;
|
||||
constexpr bool Clipping = true;
|
||||
#ifndef LIBRETRO
|
||||
extern Option<int> TextureUpscale;
|
||||
extern Option<int> MaxFilteredTextureSize;
|
||||
extern Option<int> PerPixelLayers;
|
||||
#endif
|
||||
extern Option<float> ExtraDepthScale;
|
||||
extern Option<bool> CustomTextures;
|
||||
extern Option<bool> DumpTextures;
|
||||
@@ -369,22 +460,48 @@ extern Option<bool> PerStripSorting;
|
||||
extern Option<bool> DelayFrameSwapping; // Delay swapping frame until FB_R_SOF matches FB_W_SOF
|
||||
extern Option<bool> WidescreenGameHacks;
|
||||
extern std::array<Option<int>, 4> CrosshairColor;
|
||||
extern Option<int> CrosshairSize;
|
||||
extern Option<int> SkipFrame;
|
||||
extern Option<int> MaxThreads;
|
||||
extern Option<int> AutoSkipFrame; // 0: none, 1: some, 2: more
|
||||
extern Option<int> RenderResolution;
|
||||
extern Option<bool> VSync;
|
||||
extern Option<int64_t> PixelBufferSize;
|
||||
extern Option<int> AnisotropicFiltering;
|
||||
extern Option<int> TextureFiltering; // 0: default, 1: force nearest, 2: force linear
|
||||
extern Option<bool> ThreadedRendering;
|
||||
extern Option<bool> DupeFrames;
|
||||
extern Option<bool> NativeDepthInterpolation;
|
||||
extern Option<bool> EmulateFramebuffer;
|
||||
extern Option<bool> FixUpscaleBleedingEdge;
|
||||
#ifdef VIDEO_ROUTING
|
||||
extern Option<bool, false> VideoRouting;
|
||||
extern Option<bool, false> VideoRoutingScale;
|
||||
extern Option<int, false> VideoRoutingVRes;
|
||||
#endif
|
||||
|
||||
// Misc
|
||||
|
||||
extern Option<bool> SerialConsole;
|
||||
extern Option<bool> SerialPTY;
|
||||
extern Option<bool> GDB;
|
||||
extern Option<int> GDBPort;
|
||||
extern Option<bool> GDBWaitForConnection;
|
||||
extern Option<bool> UseReios;
|
||||
extern Option<bool> FastGDRomLoad;
|
||||
extern Option<bool> RamMod32MB;
|
||||
|
||||
extern Option<bool> OpenGlChecks;
|
||||
|
||||
extern Option<std::vector<std::string>, false> ContentPath;
|
||||
extern Option<bool, false> HideLegacyNaomiRoms;
|
||||
extern Option<bool, false> UploadCrashLogs;
|
||||
|
||||
// Profiling
|
||||
extern Option<bool> ProfilerEnabled;
|
||||
extern Option<bool> ProfilerDrawToGUI;
|
||||
extern Option<bool> ProfilerOutputTTY;
|
||||
extern Option<float> ProfilerFrameWarningTime;
|
||||
|
||||
// Network
|
||||
|
||||
@@ -392,7 +509,19 @@ extern Option<bool> NetworkEnable;
|
||||
extern Option<bool> ActAsServer;
|
||||
extern OptionString DNS;
|
||||
extern OptionString NetworkServer;
|
||||
extern Option<int> LocalPort;
|
||||
extern Option<bool> EmulateBBA;
|
||||
extern Option<bool> EnableUPnP;
|
||||
extern Option<bool> GGPOEnable;
|
||||
extern Option<int> GGPODelay;
|
||||
extern Option<bool> NetworkStats;
|
||||
extern Option<int> GGPOAnalogAxes;
|
||||
extern Option<bool> GGPOChat;
|
||||
extern Option<bool> GGPOChatTimeoutToggle;
|
||||
extern Option<int> GGPOChatTimeout;
|
||||
extern Option<bool> NetworkOutput;
|
||||
extern Option<int> MultiboardSlaves;
|
||||
extern Option<bool> BattleCableEnable;
|
||||
|
||||
#ifdef SUPPORT_DISPMANX
|
||||
extern Option<bool> DispmanxMaintainAspect;
|
||||
@@ -409,6 +538,15 @@ extern Option<int> MouseSensitivity;
|
||||
extern Option<int> VirtualGamepadVibration;
|
||||
extern std::array<Option<MapleDeviceType>, 4> MapleMainDevices;
|
||||
extern std::array<std::array<Option<MapleDeviceType>, 2>, 4> MapleExpansionDevices;
|
||||
extern Option<bool> PerGameVmu;
|
||||
#ifdef _WIN32
|
||||
extern Option<bool, false> UseRawInput;
|
||||
#else
|
||||
constexpr bool UseRawInput = false;
|
||||
#endif
|
||||
|
||||
#ifdef USE_LUA
|
||||
extern Option<std::string, false> LuaFileName;
|
||||
#endif
|
||||
|
||||
} // namespace config
|
||||
|
||||
+734
-310
File diff suppressed because it is too large.
Load diff
+27
-6
@@ -21,12 +21,15 @@
|
||||
#pragma once
|
||||
#include "types.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
struct WidescreenCheat
|
||||
{
|
||||
const char *game_id;
|
||||
const char *area_or_version;
|
||||
u32 addresses[16];
|
||||
u32 values[16];
|
||||
u32 origValues[16];
|
||||
};
|
||||
|
||||
struct Cheat
|
||||
@@ -39,17 +42,28 @@ struct Cheat
|
||||
runNextIfEq,
|
||||
runNextIfNeq,
|
||||
runNextIfGt,
|
||||
runNextIfLt
|
||||
runNextIfLt,
|
||||
copy
|
||||
};
|
||||
Type type = Type::disabled;
|
||||
Type type;
|
||||
std::string description;
|
||||
bool enabled = false;
|
||||
u32 size = 0;
|
||||
u32 address = 0;
|
||||
u32 value = 0;
|
||||
bool enabled;
|
||||
u32 size;
|
||||
u32 address;
|
||||
u32 value;
|
||||
u8 valueMask = 0;
|
||||
u32 repeatCount = 1;
|
||||
u32 repeatValueIncrement = 0;
|
||||
u32 repeatAddressIncrement = 0;
|
||||
u32 destAddress = 0;
|
||||
bool builtIn;
|
||||
|
||||
Cheat(Type type = Type::disabled, const std::string& description = "", bool enabled = false,
|
||||
u32 size = 0, u32 address = 0, u32 value = 0, bool builtIn = false)
|
||||
: type(type), description(description), enabled(enabled),
|
||||
size(size), address(address), value(value), builtIn(builtIn)
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class CheatManager
|
||||
@@ -62,12 +76,15 @@ public:
|
||||
bool cheatEnabled(size_t index) const { return cheats[index].enabled; }
|
||||
void enableCheat(size_t index, bool enabled) { cheats[index].enabled = enabled; }
|
||||
void loadCheatFile(const std::string& filename);
|
||||
void saveCheatFile(const std::string& filename);
|
||||
// Returns true if using 16:9 anamorphic screen ratio
|
||||
bool isWidescreen() const { return widescreen_cheat != nullptr; }
|
||||
void addGameSharkCheat(const std::string& name, const std::string& s);
|
||||
|
||||
private:
|
||||
u32 readRam(u32 addr, u32 bits);
|
||||
void writeRam(u32 addr, u32 value, u32 bits);
|
||||
void setActive(bool active);
|
||||
|
||||
static const WidescreenCheat widescreen_cheats[];
|
||||
static const WidescreenCheat naomi_widescreen_cheats[];
|
||||
@@ -75,6 +92,10 @@ private:
|
||||
bool active = false;
|
||||
std::vector<Cheat> cheats;
|
||||
std::string gameId;
|
||||
|
||||
friend class CheatManagerTest_TestLoad_Test;
|
||||
friend class CheatManagerTest_TestGameShark_Test;
|
||||
friend class CheatManagerTest_TestSave_Test;
|
||||
};
|
||||
|
||||
extern CheatManager cheatManager;
|
||||
-260
@@ -1,260 +0,0 @@
|
||||
RZDCY_FILES :=
|
||||
|
||||
RZDCY_SRC_DIR ?= $(call my-dir)
|
||||
VERSION_HEADER := $(RZDCY_SRC_DIR)/version.h
|
||||
|
||||
RZDCY_MODULES := cfg/ hw/arm7/ hw/aica/ hw/holly/ hw/ hw/gdrom/ hw/maple/ \
|
||||
hw/mem/ hw/pvr/ hw/sh4/ hw/sh4/interpr/ hw/sh4/modules/ profiler/ oslib/ \
|
||||
hw/naomi/ imgread/ ./ deps/libchdr/src/ deps/libchdr/deps/zlib-1.2.11/ \
|
||||
deps/libelf/ deps/chdpsr/ rend/ reios/ deps/xbrz/ \
|
||||
deps/imgui/ archive/ input/ log/ wsi/ network/ hw/bba/ debug/ \
|
||||
hw/modem/ deps/picotcp/modules/ deps/picotcp/stack/
|
||||
|
||||
ifndef NO_REC
|
||||
ifndef NOT_ARM
|
||||
RZDCY_MODULES += rec-ARM/ deps/vixl/ deps/vixl/aarch32/
|
||||
endif
|
||||
|
||||
ifdef X86_REC
|
||||
RZDCY_MODULES += rec-x86/
|
||||
endif
|
||||
|
||||
ifdef X64_REC
|
||||
RZDCY_MODULES += rec-x64/
|
||||
endif
|
||||
|
||||
ifdef CPP_REC
|
||||
RZDCY_MODULES += rec-cpp/
|
||||
endif
|
||||
|
||||
ifdef ARM64_REC
|
||||
RZDCY_MODULES += rec-ARM64/ deps/vixl/ deps/vixl/aarch64/
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef NO_REND
|
||||
RZDCY_MODULES += rend/gles/
|
||||
ifndef USE_GLES
|
||||
ifndef USE_DISPMANX
|
||||
RZDCY_MODULES += rend/gl4/
|
||||
endif
|
||||
endif
|
||||
ifdef USE_VULKAN
|
||||
RZDCY_MODULES += rend/vulkan/ rend/vulkan/oit/ deps/volk/ \
|
||||
deps/glslang/glslang/MachineIndependent/ \
|
||||
deps/glslang/glslang/MachineIndependent/preprocessor/ \
|
||||
deps/glslang/glslang/GenericCodeGen/ \
|
||||
deps/glslang/OGLCompilersDLL/ \
|
||||
deps/glslang/SPIRV/
|
||||
ifdef FOR_WINDOWS
|
||||
RZDCY_FILES += $(RZDCY_SRC_DIR)/deps/glslang/glslang/OSDependent/Windows/ossource.cpp
|
||||
else
|
||||
RZDCY_FILES += $(RZDCY_SRC_DIR)/deps/glslang/glslang/OSDependent/Unix/ossource.cpp
|
||||
endif
|
||||
endif
|
||||
else
|
||||
RZDCY_MODULES += rend/norend/
|
||||
endif
|
||||
|
||||
ifdef USE_SDL
|
||||
RZDCY_MODULES += sdl/
|
||||
endif
|
||||
|
||||
ifdef FOR_LINUX
|
||||
ifndef UNIT_TESTS
|
||||
RZDCY_MODULES += linux-dist/
|
||||
endif
|
||||
RZDCY_MODULES += linux/
|
||||
endif
|
||||
|
||||
ifdef FOR_WINDOWS
|
||||
ifndef UNIT_TESTS
|
||||
RZDCY_FILES += $(RZDCY_SRC_DIR)/windows/winmain.cpp
|
||||
endif
|
||||
RZDCY_FILES += $(RZDCY_SRC_DIR)/windows/win_vmem.cpp
|
||||
RZDCY_CFLAGS += -I$(RZDCY_SRC_DIR)/deps/dirent
|
||||
endif
|
||||
|
||||
ifdef USE_VULKAN
|
||||
ifdef FOR_WINDOWS
|
||||
RZDCY_CFLAGS += -DVK_USE_PLATFORM_WIN32_KHR
|
||||
else
|
||||
RZDCY_CFLAGS += -DVK_USE_PLATFORM_XLIB_KHR
|
||||
endif
|
||||
RZDCY_CFLAGS += -D USE_VULKAN
|
||||
endif
|
||||
|
||||
RZDCY_CFLAGS += -I$(RZDCY_SRC_DIR) -I$(RZDCY_SRC_DIR)/rend/gles -I$(RZDCY_SRC_DIR)/deps \
|
||||
-I$(RZDCY_SRC_DIR)/deps/vixl -I$(RZDCY_SRC_DIR)/khronos -I$(RZDCY_SRC_DIR)/deps/glslang \
|
||||
-I$(RZDCY_SRC_DIR)/deps/glm -I$(RZDCY_SRC_DIR)/deps/xbyak -I$(RZDCY_SRC_DIR)/deps/nowide/include \
|
||||
-I$(RZDCY_SRC_DIR)/deps/picotcp/include -I$(RZDCY_SRC_DIR)/deps/picotcp/modules \
|
||||
-I$(RZDCY_SRC_DIR)/deps/libchdr/include -I$(RZDCY_SRC_DIR)/deps/libchdr/deps/zlib-1.2.11/ \
|
||||
-I$(RZDCY_SRC_DIR)/deps/libchdr/deps/lzma-19.00 -I$(RZDCY_SRC_DIR)/deps/libchdr/deps/lzma-19.00/include
|
||||
|
||||
ifdef USE_SYSTEM_MINIUPNPC
|
||||
RZDCY_CFLAGS += -I/usr/include/miniupnpc
|
||||
else
|
||||
RZDCY_CFLAGS += -I$(RZDCY_SRC_DIR)/deps/miniupnpc
|
||||
endif
|
||||
|
||||
ifdef NO_REC
|
||||
RZDCY_CFLAGS += -DTARGET_NO_REC
|
||||
else
|
||||
RZDCY_MODULES += hw/sh4/dyna/
|
||||
endif
|
||||
|
||||
ifdef USE_GLES
|
||||
RZDCY_CFLAGS += -DGLES -fPIC
|
||||
endif
|
||||
|
||||
ifdef CHD5_FLAC
|
||||
RZDCY_CFLAGS += -DCHD5_FLAC -I$(RZDCY_SRC_DIR)/deps/flac/src/libFLAC/include/ -I$(RZDCY_SRC_DIR)/deps/flac/include
|
||||
RZDCY_CFLAGS += -DHAVE_CONFIG_H
|
||||
RZDCY_MODULES += deps/flac/src/libFLAC/
|
||||
endif
|
||||
|
||||
# 7-Zip/LZMA settings (CHDv5)
|
||||
ifdef CHD5_LZMA
|
||||
RZDCY_MODULES += deps/lzma/
|
||||
RZDCY_CFLAGS += -D_7ZIP_ST -DCHD5_LZMA
|
||||
endif
|
||||
|
||||
RZDCY_CFLAGS += -DXXH_INLINE_ALL -I$(RZDCY_SRC_DIR)/deps/xxHash -I$(RZDCY_SRC_DIR)/deps/stb
|
||||
|
||||
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.cpp))
|
||||
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.cc))
|
||||
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.c))
|
||||
RZDCY_FILES += $(foreach dir,$(addprefix $(RZDCY_SRC_DIR)/,$(RZDCY_MODULES)),$(wildcard $(dir)*.S))
|
||||
|
||||
ifdef STATIC_LIBZIP
|
||||
RZDCY_CFLAGS += -I$(RZDCY_SRC_DIR)/deps/libzip/lib
|
||||
LIBZIP_DIR = $(RZDCY_SRC_DIR)/deps/libzip/lib
|
||||
RZDCY_FILES += $(LIBZIP_DIR)/zip_add.c \
|
||||
$(LIBZIP_DIR)/zip_add_dir.c \
|
||||
$(LIBZIP_DIR)/zip_add_entry.c \
|
||||
$(LIBZIP_DIR)/zip_algorithm_deflate.c \
|
||||
$(LIBZIP_DIR)/zip_buffer.c \
|
||||
$(LIBZIP_DIR)/zip_close.c \
|
||||
$(LIBZIP_DIR)/zip_delete.c \
|
||||
$(LIBZIP_DIR)/zip_dir_add.c \
|
||||
$(LIBZIP_DIR)/zip_dirent.c \
|
||||
$(LIBZIP_DIR)/zip_discard.c \
|
||||
$(LIBZIP_DIR)/zip_entry.c \
|
||||
$(LIBZIP_DIR)/zip_error.c \
|
||||
$(LIBZIP_DIR)/zip_error_clear.c \
|
||||
$(LIBZIP_DIR)/zip_error_get.c \
|
||||
$(LIBZIP_DIR)/zip_error_get_sys_type.c \
|
||||
$(LIBZIP_DIR)/zip_error_strerror.c \
|
||||
$(LIBZIP_DIR)/zip_error_to_str.c \
|
||||
$(LIBZIP_DIR)/zip_extra_field.c \
|
||||
$(LIBZIP_DIR)/zip_extra_field_api.c \
|
||||
$(LIBZIP_DIR)/zip_fclose.c \
|
||||
$(LIBZIP_DIR)/zip_fdopen.c \
|
||||
$(LIBZIP_DIR)/zip_file_add.c \
|
||||
$(LIBZIP_DIR)/zip_file_error_clear.c \
|
||||
$(LIBZIP_DIR)/zip_file_error_get.c \
|
||||
$(LIBZIP_DIR)/zip_file_get_comment.c \
|
||||
$(LIBZIP_DIR)/zip_file_get_external_attributes.c \
|
||||
$(LIBZIP_DIR)/zip_file_get_offset.c \
|
||||
$(LIBZIP_DIR)/zip_file_rename.c \
|
||||
$(LIBZIP_DIR)/zip_file_replace.c \
|
||||
$(LIBZIP_DIR)/zip_file_set_comment.c \
|
||||
$(LIBZIP_DIR)/zip_file_set_encryption.c \
|
||||
$(LIBZIP_DIR)/zip_file_set_external_attributes.c \
|
||||
$(LIBZIP_DIR)/zip_file_set_mtime.c \
|
||||
$(LIBZIP_DIR)/zip_file_strerror.c \
|
||||
$(LIBZIP_DIR)/zip_fopen.c \
|
||||
$(LIBZIP_DIR)/zip_fopen_encrypted.c \
|
||||
$(LIBZIP_DIR)/zip_fopen_index.c \
|
||||
$(LIBZIP_DIR)/zip_fopen_index_encrypted.c \
|
||||
$(LIBZIP_DIR)/zip_fread.c \
|
||||
$(LIBZIP_DIR)/zip_fseek.c \
|
||||
$(LIBZIP_DIR)/zip_ftell.c \
|
||||
$(LIBZIP_DIR)/zip_get_archive_comment.c \
|
||||
$(LIBZIP_DIR)/zip_get_archive_flag.c \
|
||||
$(LIBZIP_DIR)/zip_get_encryption_implementation.c \
|
||||
$(LIBZIP_DIR)/zip_get_file_comment.c \
|
||||
$(LIBZIP_DIR)/zip_get_name.c \
|
||||
$(LIBZIP_DIR)/zip_get_num_entries.c \
|
||||
$(LIBZIP_DIR)/zip_get_num_files.c \
|
||||
$(LIBZIP_DIR)/zip_hash.c \
|
||||
$(LIBZIP_DIR)/zip_io_util.c \
|
||||
$(LIBZIP_DIR)/zip_libzip_version.c \
|
||||
$(LIBZIP_DIR)/zip_memdup.c \
|
||||
$(LIBZIP_DIR)/zip_name_locate.c \
|
||||
$(LIBZIP_DIR)/zip_new.c \
|
||||
$(LIBZIP_DIR)/zip_open.c \
|
||||
$(LIBZIP_DIR)/zip_pkware.c \
|
||||
$(LIBZIP_DIR)/zip_progress.c \
|
||||
$(LIBZIP_DIR)/zip_rename.c \
|
||||
$(LIBZIP_DIR)/zip_replace.c \
|
||||
$(LIBZIP_DIR)/zip_set_archive_comment.c \
|
||||
$(LIBZIP_DIR)/zip_set_archive_flag.c \
|
||||
$(LIBZIP_DIR)/zip_set_default_password.c \
|
||||
$(LIBZIP_DIR)/zip_set_file_comment.c \
|
||||
$(LIBZIP_DIR)/zip_set_file_compression.c \
|
||||
$(LIBZIP_DIR)/zip_set_name.c \
|
||||
$(LIBZIP_DIR)/zip_source_accept_empty.c \
|
||||
$(LIBZIP_DIR)/zip_source_begin_write.c \
|
||||
$(LIBZIP_DIR)/zip_source_begin_write_cloning.c \
|
||||
$(LIBZIP_DIR)/zip_source_buffer.c \
|
||||
$(LIBZIP_DIR)/zip_source_call.c \
|
||||
$(LIBZIP_DIR)/zip_source_close.c \
|
||||
$(LIBZIP_DIR)/zip_source_commit_write.c \
|
||||
$(LIBZIP_DIR)/zip_source_compress.c \
|
||||
$(LIBZIP_DIR)/zip_source_crc.c \
|
||||
$(LIBZIP_DIR)/zip_source_error.c \
|
||||
$(LIBZIP_DIR)/zip_source_file_common.c \
|
||||
$(LIBZIP_DIR)/zip_source_file_stdio.c \
|
||||
$(LIBZIP_DIR)/zip_source_free.c \
|
||||
$(LIBZIP_DIR)/zip_source_function.c \
|
||||
$(LIBZIP_DIR)/zip_source_get_file_attributes.c \
|
||||
$(LIBZIP_DIR)/zip_source_is_deleted.c \
|
||||
$(LIBZIP_DIR)/zip_source_layered.c \
|
||||
$(LIBZIP_DIR)/zip_source_open.c \
|
||||
$(LIBZIP_DIR)/zip_source_pkware_decode.c \
|
||||
$(LIBZIP_DIR)/zip_source_pkware_encode.c \
|
||||
$(LIBZIP_DIR)/zip_source_read.c \
|
||||
$(LIBZIP_DIR)/zip_source_remove.c \
|
||||
$(LIBZIP_DIR)/zip_source_rollback_write.c \
|
||||
$(LIBZIP_DIR)/zip_source_seek.c \
|
||||
$(LIBZIP_DIR)/zip_source_seek_write.c \
|
||||
$(LIBZIP_DIR)/zip_source_stat.c \
|
||||
$(LIBZIP_DIR)/zip_source_supports.c \
|
||||
$(LIBZIP_DIR)/zip_source_tell.c \
|
||||
$(LIBZIP_DIR)/zip_source_tell_write.c \
|
||||
$(LIBZIP_DIR)/zip_source_window.c \
|
||||
$(LIBZIP_DIR)/zip_source_write.c \
|
||||
$(LIBZIP_DIR)/zip_source_zip.c \
|
||||
$(LIBZIP_DIR)/zip_source_zip_new.c \
|
||||
$(LIBZIP_DIR)/zip_stat.c \
|
||||
$(LIBZIP_DIR)/zip_stat_index.c \
|
||||
$(LIBZIP_DIR)/zip_stat_init.c \
|
||||
$(LIBZIP_DIR)/zip_strerror.c \
|
||||
$(LIBZIP_DIR)/zip_string.c \
|
||||
$(LIBZIP_DIR)/zip_unchange.c \
|
||||
$(LIBZIP_DIR)/zip_unchange_all.c \
|
||||
$(LIBZIP_DIR)/zip_unchange_archive.c \
|
||||
$(LIBZIP_DIR)/zip_unchange_data.c \
|
||||
$(LIBZIP_DIR)/zip_utf-8.c \
|
||||
$(LIBZIP_DIR)/zip_err_str.c
|
||||
|
||||
ifdef FOR_WINDOWS
|
||||
RZDCY_FILES += $(LIBZIP_DIR)/zip_source_file_win32.c \
|
||||
$(LIBZIP_DIR)/zip_source_file_win32_named.c \
|
||||
$(LIBZIP_DIR)/zip_source_file_win32_utf16.c \
|
||||
$(LIBZIP_DIR)/zip_source_file_win32_utf8.c \
|
||||
$(LIBZIP_DIR)/zip_source_file_win32_ansi.c \
|
||||
$(LIBZIP_DIR)/zip_random_win32.c
|
||||
else
|
||||
RZDCY_FILES += $(LIBZIP_DIR)/zip_mkstempm.c \
|
||||
$(LIBZIP_DIR)/zip_source_file_stdio_named.c \
|
||||
$(LIBZIP_DIR)/zip_random_unix.c
|
||||
endif
|
||||
endif
|
||||
|
||||
$(VERSION_HEADER):
|
||||
echo "#define REICAST_VERSION \"`git describe --tags --always`\"" > $(VERSION_HEADER)
|
||||
echo "#define GIT_HASH \"`git rev-parse --short HEAD`\"" >> $(VERSION_HEADER)
|
||||
echo "#define BUILD_DATE \"`date '+%Y-%m-%d %H:%M:%S %Z'`\"" >> $(VERSION_HEADER)
|
||||
|
||||
+52
-29
@@ -73,20 +73,47 @@ const std::array<Sh4RegType, 59> Sh4RegList {
|
||||
class DebugAgent
|
||||
{
|
||||
public:
|
||||
struct Breakpoint {
|
||||
enum Type
|
||||
{
|
||||
BP_TYPE_SOFTWARE_BREAK,
|
||||
BP_TYPE_HARDWARE_BREAK,
|
||||
BP_TYPE_WRITE_WATCHPOINT,
|
||||
BP_TYPE_READ_WATCHPOINT,
|
||||
BP_TYPE_ACCESS_WATCHPOINT,
|
||||
BP_TYPE_COUNT
|
||||
};
|
||||
|
||||
Breakpoint() = default;
|
||||
Breakpoint(u16 type, u32 addr) : addr(addr), type(type) { }
|
||||
u32 addr = 0;
|
||||
u16 type = 0;
|
||||
u16 savedOp = 0;
|
||||
};
|
||||
|
||||
void doContinue(u32 pc = 1)
|
||||
{
|
||||
if (pc != 1)
|
||||
Sh4cntx.pc = pc;
|
||||
dc_resume();
|
||||
emu.start();
|
||||
}
|
||||
|
||||
void step()
|
||||
{
|
||||
bool restoreBreakpoint = removeMatchpoint(0, Sh4cntx.pc, 2);
|
||||
bool restoreBreakpoint = removeMatchpoint(Breakpoint::BP_TYPE_SOFTWARE_BREAK, Sh4cntx.pc, 2);
|
||||
u32 savedPc = Sh4cntx.pc;
|
||||
dc_step();
|
||||
emu.step();
|
||||
if (restoreBreakpoint)
|
||||
insertMatchpoint(0, savedPc, 2);
|
||||
insertMatchpoint(Breakpoint::BP_TYPE_SOFTWARE_BREAK, savedPc, 2);
|
||||
}
|
||||
|
||||
void stepRange(u32 from, u32 to)
|
||||
{
|
||||
bool restoreBreakpoint = removeMatchpoint(Breakpoint::BP_TYPE_SOFTWARE_BREAK, Sh4cntx.pc, 2);
|
||||
u32 savedPc = Sh4cntx.pc;
|
||||
emu.stepRange(from, to);
|
||||
if (restoreBreakpoint)
|
||||
insertMatchpoint(Breakpoint::BP_TYPE_SOFTWARE_BREAK, savedPc, 2);
|
||||
}
|
||||
|
||||
int readAllRegs(u32 **regs)
|
||||
@@ -190,31 +217,31 @@ public:
|
||||
}
|
||||
}
|
||||
}
|
||||
bool insertMatchpoint(char type, u32 addr, u32 len)
|
||||
bool insertMatchpoint(Breakpoint::Type type, u32 addr, u32 len)
|
||||
{
|
||||
if (type == 0 && len != 2) {
|
||||
if (type == Breakpoint::BP_TYPE_SOFTWARE_BREAK && len != 2) {
|
||||
WARN_LOG(COMMON, "insertMatchpoint: length != 2: %d", len);
|
||||
return false;
|
||||
}
|
||||
// TODO other matchpoint types
|
||||
if (breakpoints.find(addr) != breakpoints.end())
|
||||
if (breakpoints[type].find(addr) != breakpoints[type].end())
|
||||
return true;
|
||||
breakpoints[addr] = Breakpoint(type, addr);
|
||||
breakpoints[addr].savedOp = ReadMem16_nommu(addr);
|
||||
breakpoints[type][addr] = Breakpoint(type, addr);
|
||||
breakpoints[type][addr].savedOp = ReadMem16_nommu(addr);
|
||||
WriteMem16_nommu(addr, 0xC308); // trapa #0x20
|
||||
return true;
|
||||
}
|
||||
bool removeMatchpoint(char type, u32 addr, u32 len)
|
||||
bool removeMatchpoint(Breakpoint::Type type, u32 addr, u32 len)
|
||||
{
|
||||
if (type == 0 && len != 2) {
|
||||
if (type == Breakpoint::BP_TYPE_SOFTWARE_BREAK && len != 2) {
|
||||
WARN_LOG(COMMON, "removeMatchpoint: length != 2: %d", len);
|
||||
return false;
|
||||
}
|
||||
auto it = breakpoints.find(addr);
|
||||
if (it == breakpoints.end())
|
||||
auto it = breakpoints[type].find(addr);
|
||||
if (it == breakpoints[type].end())
|
||||
return false;
|
||||
WriteMem16_nommu(addr, it->second.savedOp);
|
||||
breakpoints.erase(it);
|
||||
breakpoints[type].erase(it);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -222,7 +249,7 @@ public:
|
||||
{
|
||||
config::DynarecEnabled = false;
|
||||
exception = SIGINT;
|
||||
dc_stop();
|
||||
emu.stop();
|
||||
return exception;
|
||||
}
|
||||
|
||||
@@ -236,7 +263,7 @@ public:
|
||||
void postDebugTrap()
|
||||
{
|
||||
// needed to join the emu thread since debugTrap() is called by it
|
||||
dc_stop();
|
||||
emu.stop();
|
||||
}
|
||||
|
||||
u32 currentException()
|
||||
@@ -246,14 +273,14 @@ public:
|
||||
|
||||
void restart()
|
||||
{
|
||||
dc_stop();
|
||||
dc_reset(true);
|
||||
dc_resume();
|
||||
emu.unloadGame();
|
||||
emu.loadGame(settings.content.path.c_str());
|
||||
emu.start();
|
||||
}
|
||||
|
||||
void detach()
|
||||
{
|
||||
dc_resume();
|
||||
emu.start();
|
||||
}
|
||||
|
||||
void kill()
|
||||
@@ -295,7 +322,10 @@ public:
|
||||
{
|
||||
verify(!Sh4cntx.CpuRunning);
|
||||
size = stack.size() * 8;
|
||||
return (const u32 *)&stack[0];
|
||||
if (!stack.empty())
|
||||
return (const u32 *)&stack[0];
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void subroutineCall()
|
||||
@@ -312,13 +342,6 @@ public:
|
||||
|
||||
u32 exception = 0;
|
||||
|
||||
struct Breakpoint {
|
||||
Breakpoint() = default;
|
||||
Breakpoint(u16 type, u32 addr) : addr(addr), type(type) { }
|
||||
u32 addr = 0;
|
||||
u16 type = 0;
|
||||
u16 savedOp = 0;
|
||||
};
|
||||
std::map<u32, Breakpoint> breakpoints;
|
||||
std::map<u32, Breakpoint> breakpoints[Breakpoint::Type::BP_TYPE_COUNT];
|
||||
std::vector<std::pair<u32, u32>> stack;
|
||||
};
|
||||
+126
-35
@@ -22,16 +22,18 @@
|
||||
#include "gdb_server.h"
|
||||
#include "debug_agent.h"
|
||||
#include "network/net_platform.h"
|
||||
#include "cfg/option.h"
|
||||
#include <stdexcept>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <mutex>
|
||||
#include <cassert>
|
||||
|
||||
#define SERVER_PORT 3263
|
||||
#define MAX_PACKET_LEN 4096
|
||||
|
||||
namespace debugger {
|
||||
|
||||
static void emuEventCallback(Event event);
|
||||
static void emuEventCallback(Event event, void *);
|
||||
|
||||
class GdbServer
|
||||
{
|
||||
@@ -40,7 +42,7 @@ public:
|
||||
Error(const char *reason) : std::runtime_error(reason) {}
|
||||
};
|
||||
|
||||
void init()
|
||||
void init(int port)
|
||||
{
|
||||
if (VALID(serverSocket))
|
||||
return;
|
||||
@@ -55,7 +57,7 @@ public:
|
||||
struct sockaddr_in serveraddr;
|
||||
memset(&serveraddr, 0, sizeof(serveraddr));
|
||||
serveraddr.sin_family = AF_INET;
|
||||
serveraddr.sin_port = htons(SERVER_PORT);
|
||||
serveraddr.sin_port = htons(port);
|
||||
|
||||
if (::bind(serverSocket, (struct sockaddr *)&serveraddr, sizeof(serveraddr)) < 0)
|
||||
{
|
||||
@@ -69,10 +71,16 @@ public:
|
||||
}
|
||||
EventManager::listen(Event::Resume, emuEventCallback);
|
||||
EventManager::listen(Event::Terminate, emuEventCallback);
|
||||
|
||||
initialised = true;
|
||||
}
|
||||
|
||||
void term()
|
||||
{
|
||||
if (!initialised)
|
||||
return;
|
||||
EventManager::unlisten(Event::Resume, emuEventCallback);
|
||||
EventManager::unlisten(Event::Terminate, emuEventCallback);
|
||||
stop();
|
||||
if (VALID(clientSocket))
|
||||
{
|
||||
@@ -88,12 +96,21 @@ public:
|
||||
|
||||
void run()
|
||||
{
|
||||
if (!initialised || thread.joinable())
|
||||
return;
|
||||
DEBUG_LOG(COMMON, "GdbServer starting");
|
||||
thread = std::thread(&GdbServer::serverThread, this);
|
||||
if (config::GDBWaitForConnection)
|
||||
{
|
||||
DEBUG_LOG(COMMON, "Waiting for GDB connection...");
|
||||
agentInterrupt();
|
||||
}
|
||||
}
|
||||
|
||||
void stop()
|
||||
{
|
||||
if (!initialised)
|
||||
return;
|
||||
if (thread.joinable())
|
||||
{
|
||||
DEBUG_LOG(COMMON, "GdbServer stopping");
|
||||
@@ -104,7 +121,7 @@ public:
|
||||
}
|
||||
|
||||
bool isRunning() const {
|
||||
return thread.joinable();
|
||||
return initialised && thread.joinable();
|
||||
}
|
||||
|
||||
// called on the emu thread
|
||||
@@ -181,18 +198,22 @@ private:
|
||||
{
|
||||
NOTICE_LOG(NETWORK, "gdb: client connection");
|
||||
attached = true;
|
||||
agent.interrupt();
|
||||
agentInterrupt();
|
||||
}
|
||||
}
|
||||
|
||||
void readCommand()
|
||||
{
|
||||
if (postDebugTrapNeeded)
|
||||
{
|
||||
postDebugTrapNeeded = false;
|
||||
agent.postDebugTrap();
|
||||
}
|
||||
try {
|
||||
try {
|
||||
if (postDebugTrapNeeded)
|
||||
{
|
||||
postDebugTrapNeeded = false;
|
||||
try {
|
||||
agent.postDebugTrap();
|
||||
} catch (const FlycastException& e) {
|
||||
throw Error(e.what());
|
||||
}
|
||||
}
|
||||
std::string packet = recvPacket();
|
||||
if (packet.empty())
|
||||
return;
|
||||
@@ -494,7 +515,12 @@ private:
|
||||
const u32 *data = agent.getStack(len);
|
||||
len /= 4;
|
||||
|
||||
#if _MSC_VER // Non-const array size is a GCC extension
|
||||
assert((len * 9 * 2 + 1) < MAX_PACKET_LEN);
|
||||
char reply[MAX_PACKET_LEN];
|
||||
#else
|
||||
char reply[len * 9 * 2 + 1];
|
||||
#endif
|
||||
char *r = reply;
|
||||
for (u32 i = 0; i < len; i++)
|
||||
{
|
||||
@@ -513,9 +539,13 @@ private:
|
||||
sendPacket("");
|
||||
}
|
||||
else if (pkt.rfind("qSupported", 0) == 0)
|
||||
{
|
||||
// Tell the remote stub about features supported by GDB,
|
||||
// and query the stub for features it supports
|
||||
sendPacket("PacketSize=10000");
|
||||
char qsupported[128];
|
||||
snprintf(qsupported, 128, "PacketSize=%i;vContSupported+", MAX_PACKET_LEN);
|
||||
sendPacket(qsupported);
|
||||
}
|
||||
else if (pkt.rfind("qSymbol:", 0) == 0)
|
||||
// Notify the target that GDB is prepared to serve symbol lookup requests
|
||||
sendPacket("OK");
|
||||
@@ -568,11 +598,41 @@ private:
|
||||
if (pkt.rfind("vAttach;", 0) == 0)
|
||||
sendPacket("S05");
|
||||
else if (pkt.rfind("vCont?", 0) == 0)
|
||||
// not supported
|
||||
sendPacket("vCont;s;c");
|
||||
// supported vCont actions - (c)ontinue, (C)ontinue with signal, (s)tep, (S)tep with signal, (r)ange-step
|
||||
sendPacket("vCont;c;C;s;S;t;r");
|
||||
else if (pkt.rfind("vCont", 0) == 0)
|
||||
// not supported
|
||||
WARN_LOG(COMMON, "vCont not supported %s", pkt.c_str());
|
||||
{
|
||||
std::string vContCmd = pkt.substr(strlen("vCont;"));
|
||||
switch (vContCmd[0])
|
||||
{
|
||||
case 'c':
|
||||
case 'C':
|
||||
sendContinue(vContCmd);
|
||||
break;
|
||||
case 's':
|
||||
step(EXCEPT_NONE);
|
||||
break;
|
||||
case 'S':
|
||||
step();
|
||||
case 'r':
|
||||
{
|
||||
u32 from, to;
|
||||
if (sscanf(vContCmd.c_str(), "r%x,%x", &from, &to) == 2)
|
||||
{
|
||||
stepRange(from, to);
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_LOG(COMMON, "Unsupported vCont:r format %s", pkt.c_str());
|
||||
sendContinue("c");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
WARN_LOG(COMMON, "vCont action not supported %s", pkt.c_str());
|
||||
}
|
||||
}
|
||||
else if (pkt.rfind("vFile:", 0) == 0)
|
||||
// not supported
|
||||
sendPacket("");
|
||||
@@ -597,11 +657,11 @@ private:
|
||||
sendPacket("OK");
|
||||
agent.kill();
|
||||
}
|
||||
else if (pkt.rfind("vMustReplyEmpty", 0) == 0)
|
||||
// Reply empty packet
|
||||
sendPacket("");
|
||||
else
|
||||
{
|
||||
WARN_LOG(COMMON, "unknown v packet: %s", pkt.c_str());
|
||||
sendPacket("");
|
||||
}
|
||||
}
|
||||
|
||||
void restart()
|
||||
@@ -611,8 +671,23 @@ private:
|
||||
|
||||
void step(u32 what = 0)
|
||||
{
|
||||
agent.step();
|
||||
sendPacket("S05");
|
||||
try {
|
||||
agent.step();
|
||||
sendPacket("S05");
|
||||
} catch (const FlycastException& e) {
|
||||
throw Error(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void stepRange(u32 from, u32 to)
|
||||
{
|
||||
try {
|
||||
sendPacket("OK");
|
||||
agent.stepRange(from, to);
|
||||
sendPacket("S05");
|
||||
} catch (const FlycastException& e) {
|
||||
throw Error(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void insertMatchpoint(const std::string& pkt)
|
||||
@@ -625,22 +700,23 @@ private:
|
||||
sendPacket("E01");
|
||||
}
|
||||
switch (type) {
|
||||
case 0: // soft bp
|
||||
if (agent.insertMatchpoint(0, addr, len))
|
||||
case DebugAgent::Breakpoint::BP_TYPE_SOFTWARE_BREAK: // soft bp
|
||||
if (agent.insertMatchpoint(DebugAgent::Breakpoint::BP_TYPE_SOFTWARE_BREAK,
|
||||
addr, len))
|
||||
sendPacket("OK");
|
||||
else
|
||||
sendPacket("E01");
|
||||
break;
|
||||
case 1: // hardware bp
|
||||
case DebugAgent::Breakpoint::BP_TYPE_HARDWARE_BREAK: // hardware bp
|
||||
sendPacket("");
|
||||
break;
|
||||
case 2: // write watchpoint
|
||||
case DebugAgent::Breakpoint::BP_TYPE_WRITE_WATCHPOINT: // write watchpoint
|
||||
sendPacket("");
|
||||
break;
|
||||
case 3: // read watchpoint
|
||||
case DebugAgent::Breakpoint::BP_TYPE_READ_WATCHPOINT: // read watchpoint
|
||||
sendPacket("");
|
||||
break;
|
||||
case 4: // access watchpoint
|
||||
case DebugAgent::Breakpoint::BP_TYPE_ACCESS_WATCHPOINT: // access watchpoint
|
||||
sendPacket("");
|
||||
break;
|
||||
default:
|
||||
@@ -660,7 +736,8 @@ private:
|
||||
}
|
||||
switch (type) {
|
||||
case 0: // soft bp
|
||||
if (agent.removeMatchpoint(0, addr, len))
|
||||
if (agent.removeMatchpoint(DebugAgent::Breakpoint::BP_TYPE_SOFTWARE_BREAK,
|
||||
addr, len))
|
||||
sendPacket("OK");
|
||||
else
|
||||
sendPacket("E01");
|
||||
@@ -685,7 +762,7 @@ private:
|
||||
|
||||
void interrupt()
|
||||
{
|
||||
u32 signal = agent.interrupt();
|
||||
u32 signal = agentInterrupt();
|
||||
char s[10];
|
||||
sprintf(s, "S%02x", signal);
|
||||
sendPacket(s);
|
||||
@@ -825,6 +902,16 @@ private:
|
||||
throw Error("I/O error");
|
||||
}
|
||||
|
||||
u32 agentInterrupt()
|
||||
{
|
||||
try {
|
||||
return agent.interrupt();
|
||||
} catch (const FlycastException& e) {
|
||||
throw Error(e.what());
|
||||
}
|
||||
}
|
||||
|
||||
bool initialised = false;
|
||||
bool stopRequested = false;
|
||||
bool attached = false;
|
||||
bool postDebugTrapNeeded = false;
|
||||
@@ -838,9 +925,9 @@ public:
|
||||
|
||||
static GdbServer gdbServer;
|
||||
|
||||
void init()
|
||||
void init(int port)
|
||||
{
|
||||
gdbServer.init();
|
||||
gdbServer.init(port);
|
||||
}
|
||||
|
||||
void term()
|
||||
@@ -863,13 +950,17 @@ void subroutineReturn()
|
||||
gdbServer.agent.subroutineReturn();
|
||||
}
|
||||
|
||||
static void emuEventCallback(Event event)
|
||||
static void emuEventCallback(Event event, void *)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case Event::Resume:
|
||||
if (!gdbServer.isRunning())
|
||||
gdbServer.run();
|
||||
try {
|
||||
if (!gdbServer.isRunning())
|
||||
gdbServer.run();
|
||||
} catch (const GdbServer::Error& e) {
|
||||
ERROR_LOG(COMMON, "%s", e.what());
|
||||
}
|
||||
break;
|
||||
case Event::Terminate:
|
||||
gdbServer.stop();
|
||||
|
||||
@@ -23,9 +23,11 @@ namespace debugger {
|
||||
// exception thrown in response to trap
|
||||
struct Stop { };
|
||||
|
||||
static const int DEFAULT_PORT = 3263;
|
||||
|
||||
#ifdef GDB_SERVER
|
||||
|
||||
void init();
|
||||
void init(int port);
|
||||
void term();
|
||||
void run();
|
||||
void debugTrap(u32 event);
|
||||
@@ -33,7 +35,7 @@ struct Stop { };
|
||||
void subroutineReturn();
|
||||
|
||||
#else
|
||||
static inline void init() {}
|
||||
static inline void init(int port) {}
|
||||
static inline void term() {}
|
||||
static inline void run() {}
|
||||
static inline void debugTrap(u32 event) {}
|
||||
|
||||
+1
-1
Submodule core/deps/SDL updated: 178ae70a29...5adbf3765a.
Submodule
+1
Submodule core/deps/Spout added at 2110a918e7.
Submodule
+1
Submodule core/deps/Syphon added at 486dd8e4ef.
Submodule
+1
Submodule core/deps/Vulkan-Headers added at 85c2334e92.
Submodule
+1
Submodule core/deps/VulkanMemoryAllocator added at 6eb62e1515.
Submodule
+1
Submodule core/deps/breakpad added at 1ab24bcc81.
@@ -1,239 +0,0 @@
|
||||
/*
|
||||
* This code implements the MD5 message-digest algorithm.
|
||||
* The algorithm is due to Ron Rivest. This code was
|
||||
* written by Colin Plumb in 1993, no copyright is claimed.
|
||||
* This code is in the public domain; do with it what you wish.
|
||||
*
|
||||
* Equivalent code is available from RSA Data Security, Inc.
|
||||
* This code has been tested against that, and is equivalent,
|
||||
* except that you don't need to include two pages of legalese
|
||||
* with every copy.
|
||||
*
|
||||
* To compute the message digest of a chunk of bytes, declare an
|
||||
* MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||
* needed on buffers full of bytes, and then call MD5Final, which
|
||||
* will fill a supplied 16-byte array with the digest.
|
||||
*
|
||||
* Changed so as no longer to depend on Colin Plumb's `usual.h' header
|
||||
* definitions; now uses stuff from dpkg's config.h.
|
||||
* - Ian Jackson <[email protected]>.
|
||||
* Still in the public domain.
|
||||
*/
|
||||
|
||||
#include <string.h> /* for memcpy() */
|
||||
|
||||
#include "md5.h"
|
||||
|
||||
#ifndef LSB_FIRST
|
||||
void
|
||||
byteSwap(UWORD32 *buf, unsigned words)
|
||||
{
|
||||
md5byte *p = (md5byte *)buf;
|
||||
|
||||
do {
|
||||
*buf++ = (UWORD32)((unsigned)p[3] << 8 | p[2]) << 16 |
|
||||
((unsigned)p[1] << 8 | p[0]);
|
||||
p += 4;
|
||||
} while (--words);
|
||||
}
|
||||
#else
|
||||
#define byteSwap(buf,words)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Start MD5 accumulation. Set bit count to 0 and buffer to mysterious
|
||||
* initialization constants.
|
||||
*/
|
||||
void
|
||||
MD5Init(struct MD5Context *ctx)
|
||||
{
|
||||
ctx->buf[0] = 0x67452301;
|
||||
ctx->buf[1] = 0xefcdab89;
|
||||
ctx->buf[2] = 0x98badcfe;
|
||||
ctx->buf[3] = 0x10325476;
|
||||
|
||||
ctx->bytes[0] = 0;
|
||||
ctx->bytes[1] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update context to reflect the concatenation of another buffer full
|
||||
* of bytes.
|
||||
*/
|
||||
void
|
||||
MD5Update(struct MD5Context *ctx, md5byte const *buf, unsigned len)
|
||||
{
|
||||
UWORD32 t;
|
||||
|
||||
/* Update byte count */
|
||||
|
||||
t = ctx->bytes[0];
|
||||
if ((ctx->bytes[0] = t + len) < t)
|
||||
ctx->bytes[1]++; /* Carry from low to high */
|
||||
|
||||
t = 64 - (t & 0x3f); /* Space available in ctx->in (at least 1) */
|
||||
if (t > len) {
|
||||
memcpy((md5byte *)ctx->in + 64 - t, buf, len);
|
||||
return;
|
||||
}
|
||||
/* First chunk is an odd size */
|
||||
memcpy((md5byte *)ctx->in + 64 - t, buf, t);
|
||||
byteSwap(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
buf += t;
|
||||
len -= t;
|
||||
|
||||
/* Process data in 64-byte chunks */
|
||||
while (len >= 64) {
|
||||
memcpy(ctx->in, buf, 64);
|
||||
byteSwap(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
buf += 64;
|
||||
len -= 64;
|
||||
}
|
||||
|
||||
/* Handle any remaining bytes of data. */
|
||||
memcpy(ctx->in, buf, len);
|
||||
}
|
||||
|
||||
/*
|
||||
* Final wrapup - pad to 64-byte boundary with the bit pattern
|
||||
* 1 0* (64-bit count of bits processed, MSB-first)
|
||||
*/
|
||||
void
|
||||
MD5Final(md5byte digest[16], struct MD5Context *ctx)
|
||||
{
|
||||
int count = ctx->bytes[0] & 0x3f; /* Number of bytes in ctx->in */
|
||||
md5byte *p = (md5byte *)ctx->in + count;
|
||||
|
||||
/* Set the first char of padding to 0x80. There is always room. */
|
||||
*p++ = 0x80;
|
||||
|
||||
/* Bytes of padding needed to make 56 bytes (-8..55) */
|
||||
count = 56 - 1 - count;
|
||||
|
||||
if (count < 0) { /* Padding forces an extra block */
|
||||
memset(p, 0, count + 8);
|
||||
byteSwap(ctx->in, 16);
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
p = (md5byte *)ctx->in;
|
||||
count = 56;
|
||||
}
|
||||
memset(p, 0, count);
|
||||
byteSwap(ctx->in, 14);
|
||||
|
||||
/* Append length in bits and transform */
|
||||
ctx->in[14] = ctx->bytes[0] << 3;
|
||||
ctx->in[15] = ctx->bytes[1] << 3 | ctx->bytes[0] >> 29;
|
||||
MD5Transform(ctx->buf, ctx->in);
|
||||
|
||||
byteSwap(ctx->buf, 4);
|
||||
memcpy(digest, ctx->buf, 16);
|
||||
memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
|
||||
}
|
||||
|
||||
#ifndef ASM_MD5
|
||||
|
||||
/* The four core functions - F1 is optimized somewhat */
|
||||
|
||||
/* #define F1(x, y, z) (x & y | ~x & z) */
|
||||
#define F1(x, y, z) (z ^ (x & (y ^ z)))
|
||||
#define F2(x, y, z) F1(z, x, y)
|
||||
#define F3(x, y, z) (x ^ y ^ z)
|
||||
#define F4(x, y, z) (y ^ (x | ~z))
|
||||
|
||||
/* This is the central step in the MD5 algorithm. */
|
||||
#define MD5STEP(f,w,x,y,z,in,s) \
|
||||
(w += f(x,y,z) + in, w = (w<<s | w>>(32-s)) + x)
|
||||
|
||||
/*
|
||||
* The core of the MD5 algorithm, this alters an existing MD5 hash to
|
||||
* reflect the addition of 16 longwords of new data. MD5Update blocks
|
||||
* the data and converts bytes into longwords for this routine.
|
||||
*/
|
||||
void
|
||||
MD5Transform(UWORD32 buf[4], UWORD32 const in[16])
|
||||
{
|
||||
register UWORD32 a, b, c, d;
|
||||
|
||||
a = buf[0];
|
||||
b = buf[1];
|
||||
c = buf[2];
|
||||
d = buf[3];
|
||||
|
||||
MD5STEP(F1, a, b, c, d, in[0] + 0xd76aa478, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[1] + 0xe8c7b756, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[2] + 0x242070db, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[3] + 0xc1bdceee, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[4] + 0xf57c0faf, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[5] + 0x4787c62a, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[6] + 0xa8304613, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[7] + 0xfd469501, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[8] + 0x698098d8, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[9] + 0x8b44f7af, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[10] + 0xffff5bb1, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[11] + 0x895cd7be, 22);
|
||||
MD5STEP(F1, a, b, c, d, in[12] + 0x6b901122, 7);
|
||||
MD5STEP(F1, d, a, b, c, in[13] + 0xfd987193, 12);
|
||||
MD5STEP(F1, c, d, a, b, in[14] + 0xa679438e, 17);
|
||||
MD5STEP(F1, b, c, d, a, in[15] + 0x49b40821, 22);
|
||||
|
||||
MD5STEP(F2, a, b, c, d, in[1] + 0xf61e2562, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[6] + 0xc040b340, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[11] + 0x265e5a51, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[0] + 0xe9b6c7aa, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[5] + 0xd62f105d, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[10] + 0x02441453, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[15] + 0xd8a1e681, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[4] + 0xe7d3fbc8, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[9] + 0x21e1cde6, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[14] + 0xc33707d6, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[3] + 0xf4d50d87, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[8] + 0x455a14ed, 20);
|
||||
MD5STEP(F2, a, b, c, d, in[13] + 0xa9e3e905, 5);
|
||||
MD5STEP(F2, d, a, b, c, in[2] + 0xfcefa3f8, 9);
|
||||
MD5STEP(F2, c, d, a, b, in[7] + 0x676f02d9, 14);
|
||||
MD5STEP(F2, b, c, d, a, in[12] + 0x8d2a4c8a, 20);
|
||||
|
||||
MD5STEP(F3, a, b, c, d, in[5] + 0xfffa3942, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[8] + 0x8771f681, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[11] + 0x6d9d6122, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[14] + 0xfde5380c, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[1] + 0xa4beea44, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[4] + 0x4bdecfa9, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[7] + 0xf6bb4b60, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[10] + 0xbebfbc70, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[13] + 0x289b7ec6, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[0] + 0xeaa127fa, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[3] + 0xd4ef3085, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[6] + 0x04881d05, 23);
|
||||
MD5STEP(F3, a, b, c, d, in[9] + 0xd9d4d039, 4);
|
||||
MD5STEP(F3, d, a, b, c, in[12] + 0xe6db99e5, 11);
|
||||
MD5STEP(F3, c, d, a, b, in[15] + 0x1fa27cf8, 16);
|
||||
MD5STEP(F3, b, c, d, a, in[2] + 0xc4ac5665, 23);
|
||||
|
||||
MD5STEP(F4, a, b, c, d, in[0] + 0xf4292244, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[7] + 0x432aff97, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[14] + 0xab9423a7, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[5] + 0xfc93a039, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[12] + 0x655b59c3, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[3] + 0x8f0ccc92, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[10] + 0xffeff47d, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[1] + 0x85845dd1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[8] + 0x6fa87e4f, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[15] + 0xfe2ce6e0, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[6] + 0xa3014314, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[13] + 0x4e0811a1, 21);
|
||||
MD5STEP(F4, a, b, c, d, in[4] + 0xf7537e82, 6);
|
||||
MD5STEP(F4, d, a, b, c, in[11] + 0xbd3af235, 10);
|
||||
MD5STEP(F4, c, d, a, b, in[2] + 0x2ad7d2bb, 15);
|
||||
MD5STEP(F4, b, c, d, a, in[9] + 0xeb86d391, 21);
|
||||
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* This is the header file for the MD5 message-digest algorithm.
|
||||
* The algorithm is due to Ron Rivest. This code was
|
||||
* written by Colin Plumb in 1993, no copyright is claimed.
|
||||
* This code is in the public domain; do with it what you wish.
|
||||
*
|
||||
* Equivalent code is available from RSA Data Security, Inc.
|
||||
* This code has been tested against that, and is equivalent,
|
||||
* except that you don't need to include two pages of legalese
|
||||
* with every copy.
|
||||
*
|
||||
* To compute the message digest of a chunk of bytes, declare an
|
||||
* MD5Context structure, pass it to MD5Init, call MD5Update as
|
||||
* needed on buffers full of bytes, and then call MD5Final, which
|
||||
* will fill a supplied 16-byte array with the digest.
|
||||
*
|
||||
* Changed so as no longer to depend on Colin Plumb's `usual.h'
|
||||
* header definitions; now uses stuff from dpkg's config.h
|
||||
* - Ian Jackson <[email protected]>.
|
||||
* Still in the public domain.
|
||||
*/
|
||||
|
||||
#ifndef MD5_H
|
||||
#define MD5_H
|
||||
|
||||
typedef unsigned int UWORD32;
|
||||
|
||||
#define md5byte unsigned char
|
||||
|
||||
struct MD5Context {
|
||||
UWORD32 buf[4];
|
||||
UWORD32 bytes[2];
|
||||
UWORD32 in[16];
|
||||
};
|
||||
|
||||
void MD5Init(struct MD5Context *context);
|
||||
void MD5Update(struct MD5Context *context, md5byte const *buf, unsigned len);
|
||||
void MD5Final(unsigned char digest[16], struct MD5Context *context);
|
||||
void MD5Transform(UWORD32 buf[4], UWORD32 const in[16]);
|
||||
|
||||
#endif /* !MD5_H */
|
||||
|
||||
@@ -1,387 +0,0 @@
|
||||
/* sha1.h
|
||||
*
|
||||
* The sha1 hash function.
|
||||
*/
|
||||
|
||||
/* nettle, low-level cryptographics library
|
||||
*
|
||||
* Copyright 2001 Peter Gutmann, Andrew Kuchling, Niels Moeller
|
||||
*
|
||||
* The nettle library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* The nettle library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with the nettle library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sha1.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
static unsigned int READ_UINT32(const UINT8* data)
|
||||
{
|
||||
return ((UINT32)data[0] << 24) |
|
||||
((UINT32)data[1] << 16) |
|
||||
((UINT32)data[2] << 8) |
|
||||
((UINT32)data[3]);
|
||||
}
|
||||
|
||||
static void WRITE_UINT32(unsigned char* data, UINT32 val)
|
||||
{
|
||||
data[0] = (val >> 24) & 0xFF;
|
||||
data[1] = (val >> 16) & 0xFF;
|
||||
data[2] = (val >> 8) & 0xFF;
|
||||
data[3] = (val >> 0) & 0xFF;
|
||||
}
|
||||
|
||||
|
||||
/* A block, treated as a sequence of 32-bit words. */
|
||||
#define SHA1_DATA_LENGTH 16
|
||||
|
||||
/* The SHA f()-functions. The f1 and f3 functions can be optimized to
|
||||
save one boolean operation each - thanks to Rich Schroeppel,
|
||||
[email protected] for discovering this */
|
||||
|
||||
/* #define f1(x,y,z) ( ( x & y ) | ( ~x & z ) ) Rounds 0-19 */
|
||||
#define f1(x,y,z) ( z ^ ( x & ( y ^ z ) ) ) /* Rounds 0-19 */
|
||||
#define f2(x,y,z) ( x ^ y ^ z ) /* Rounds 20-39 */
|
||||
/* #define f3(x,y,z) ( ( x & y ) | ( x & z ) | ( y & z ) ) Rounds 40-59 */
|
||||
#define f3(x,y,z) ( ( x & y ) | ( z & ( x | y ) ) ) /* Rounds 40-59 */
|
||||
#define f4(x,y,z) ( x ^ y ^ z ) /* Rounds 60-79 */
|
||||
|
||||
/* The SHA Mysterious Constants */
|
||||
|
||||
#define K1 0x5A827999L /* Rounds 0-19 */
|
||||
#define K2 0x6ED9EBA1L /* Rounds 20-39 */
|
||||
#define K3 0x8F1BBCDCL /* Rounds 40-59 */
|
||||
#define K4 0xCA62C1D6L /* Rounds 60-79 */
|
||||
|
||||
/* SHA initial values */
|
||||
|
||||
#define h0init 0x67452301L
|
||||
#define h1init 0xEFCDAB89L
|
||||
#define h2init 0x98BADCFEL
|
||||
#define h3init 0x10325476L
|
||||
#define h4init 0xC3D2E1F0L
|
||||
|
||||
/* 32-bit rotate left - kludged with shifts */
|
||||
#ifdef _MSC_VER
|
||||
#define ROTL(n,X) _lrotl(X, n)
|
||||
#else
|
||||
#define ROTL(n,X) ( ( (X) << (n) ) | ( (X) >> ( 32 - (n) ) ) )
|
||||
#endif
|
||||
|
||||
/* The initial expanding function. The hash function is defined over an
|
||||
80-word expanded input array W, where the first 16 are copies of the input
|
||||
data, and the remaining 64 are defined by
|
||||
|
||||
W[ i ] = W[ i - 16 ] ^ W[ i - 14 ] ^ W[ i - 8 ] ^ W[ i - 3 ]
|
||||
|
||||
This implementation generates these values on the fly in a circular
|
||||
buffer - thanks to Colin Plumb, [email protected] for this
|
||||
optimization.
|
||||
|
||||
The updated SHA changes the expanding function by adding a rotate of 1
|
||||
bit. Thanks to Jim Gillogly, [email protected], and an anonymous contributor
|
||||
for this information */
|
||||
|
||||
#define expand(W,i) ( W[ i & 15 ] = \
|
||||
ROTL( 1, ( W[ i & 15 ] ^ W[ (i - 14) & 15 ] ^ \
|
||||
W[ (i - 8) & 15 ] ^ W[ (i - 3) & 15 ] ) ) )
|
||||
|
||||
|
||||
/* The prototype SHA sub-round. The fundamental sub-round is:
|
||||
|
||||
a' = e + ROTL( 5, a ) + f( b, c, d ) + k + data;
|
||||
b' = a;
|
||||
c' = ROTL( 30, b );
|
||||
d' = c;
|
||||
e' = d;
|
||||
|
||||
but this is implemented by unrolling the loop 5 times and renaming the
|
||||
variables ( e, a, b, c, d ) = ( a', b', c', d', e' ) each iteration.
|
||||
This code is then replicated 20 times for each of the 4 functions, using
|
||||
the next 20 values from the W[] array each time */
|
||||
|
||||
#define subRound(a, b, c, d, e, f, k, data) \
|
||||
( e += ROTL( 5, a ) + f( b, c, d ) + k + data, b = ROTL( 30, b ) )
|
||||
|
||||
/* Initialize the SHA values */
|
||||
|
||||
void
|
||||
sha1_init(struct sha1_ctx *ctx)
|
||||
{
|
||||
/* Set the h-vars to their initial values */
|
||||
ctx->digest[ 0 ] = h0init;
|
||||
ctx->digest[ 1 ] = h1init;
|
||||
ctx->digest[ 2 ] = h2init;
|
||||
ctx->digest[ 3 ] = h3init;
|
||||
ctx->digest[ 4 ] = h4init;
|
||||
|
||||
/* Initialize bit count */
|
||||
ctx->count_low = ctx->count_high = 0;
|
||||
|
||||
/* Initialize buffer */
|
||||
ctx->index = 0;
|
||||
}
|
||||
|
||||
/* Perform the SHA transformation. Note that this code, like MD5, seems to
|
||||
break some optimizing compilers due to the complexity of the expressions
|
||||
and the size of the basic block. It may be necessary to split it into
|
||||
sections, e.g. based on the four subrounds
|
||||
|
||||
Note that this function destroys the data area */
|
||||
|
||||
static void
|
||||
sha1_transform(UINT32 *state, UINT32 *data)
|
||||
{
|
||||
UINT32 A, B, C, D, E; /* Local vars */
|
||||
|
||||
/* Set up first buffer and local data buffer */
|
||||
A = state[0];
|
||||
B = state[1];
|
||||
C = state[2];
|
||||
D = state[3];
|
||||
E = state[4];
|
||||
|
||||
/* Heavy mangling, in 4 sub-rounds of 20 interations each. */
|
||||
subRound( A, B, C, D, E, f1, K1, data[ 0] );
|
||||
subRound( E, A, B, C, D, f1, K1, data[ 1] );
|
||||
subRound( D, E, A, B, C, f1, K1, data[ 2] );
|
||||
subRound( C, D, E, A, B, f1, K1, data[ 3] );
|
||||
subRound( B, C, D, E, A, f1, K1, data[ 4] );
|
||||
subRound( A, B, C, D, E, f1, K1, data[ 5] );
|
||||
subRound( E, A, B, C, D, f1, K1, data[ 6] );
|
||||
subRound( D, E, A, B, C, f1, K1, data[ 7] );
|
||||
subRound( C, D, E, A, B, f1, K1, data[ 8] );
|
||||
subRound( B, C, D, E, A, f1, K1, data[ 9] );
|
||||
subRound( A, B, C, D, E, f1, K1, data[10] );
|
||||
subRound( E, A, B, C, D, f1, K1, data[11] );
|
||||
subRound( D, E, A, B, C, f1, K1, data[12] );
|
||||
subRound( C, D, E, A, B, f1, K1, data[13] );
|
||||
subRound( B, C, D, E, A, f1, K1, data[14] );
|
||||
subRound( A, B, C, D, E, f1, K1, data[15] );
|
||||
subRound( E, A, B, C, D, f1, K1, expand( data, 16 ) );
|
||||
subRound( D, E, A, B, C, f1, K1, expand( data, 17 ) );
|
||||
subRound( C, D, E, A, B, f1, K1, expand( data, 18 ) );
|
||||
subRound( B, C, D, E, A, f1, K1, expand( data, 19 ) );
|
||||
|
||||
subRound( A, B, C, D, E, f2, K2, expand( data, 20 ) );
|
||||
subRound( E, A, B, C, D, f2, K2, expand( data, 21 ) );
|
||||
subRound( D, E, A, B, C, f2, K2, expand( data, 22 ) );
|
||||
subRound( C, D, E, A, B, f2, K2, expand( data, 23 ) );
|
||||
subRound( B, C, D, E, A, f2, K2, expand( data, 24 ) );
|
||||
subRound( A, B, C, D, E, f2, K2, expand( data, 25 ) );
|
||||
subRound( E, A, B, C, D, f2, K2, expand( data, 26 ) );
|
||||
subRound( D, E, A, B, C, f2, K2, expand( data, 27 ) );
|
||||
subRound( C, D, E, A, B, f2, K2, expand( data, 28 ) );
|
||||
subRound( B, C, D, E, A, f2, K2, expand( data, 29 ) );
|
||||
subRound( A, B, C, D, E, f2, K2, expand( data, 30 ) );
|
||||
subRound( E, A, B, C, D, f2, K2, expand( data, 31 ) );
|
||||
subRound( D, E, A, B, C, f2, K2, expand( data, 32 ) );
|
||||
subRound( C, D, E, A, B, f2, K2, expand( data, 33 ) );
|
||||
subRound( B, C, D, E, A, f2, K2, expand( data, 34 ) );
|
||||
subRound( A, B, C, D, E, f2, K2, expand( data, 35 ) );
|
||||
subRound( E, A, B, C, D, f2, K2, expand( data, 36 ) );
|
||||
subRound( D, E, A, B, C, f2, K2, expand( data, 37 ) );
|
||||
subRound( C, D, E, A, B, f2, K2, expand( data, 38 ) );
|
||||
subRound( B, C, D, E, A, f2, K2, expand( data, 39 ) );
|
||||
|
||||
subRound( A, B, C, D, E, f3, K3, expand( data, 40 ) );
|
||||
subRound( E, A, B, C, D, f3, K3, expand( data, 41 ) );
|
||||
subRound( D, E, A, B, C, f3, K3, expand( data, 42 ) );
|
||||
subRound( C, D, E, A, B, f3, K3, expand( data, 43 ) );
|
||||
subRound( B, C, D, E, A, f3, K3, expand( data, 44 ) );
|
||||
subRound( A, B, C, D, E, f3, K3, expand( data, 45 ) );
|
||||
subRound( E, A, B, C, D, f3, K3, expand( data, 46 ) );
|
||||
subRound( D, E, A, B, C, f3, K3, expand( data, 47 ) );
|
||||
subRound( C, D, E, A, B, f3, K3, expand( data, 48 ) );
|
||||
subRound( B, C, D, E, A, f3, K3, expand( data, 49 ) );
|
||||
subRound( A, B, C, D, E, f3, K3, expand( data, 50 ) );
|
||||
subRound( E, A, B, C, D, f3, K3, expand( data, 51 ) );
|
||||
subRound( D, E, A, B, C, f3, K3, expand( data, 52 ) );
|
||||
subRound( C, D, E, A, B, f3, K3, expand( data, 53 ) );
|
||||
subRound( B, C, D, E, A, f3, K3, expand( data, 54 ) );
|
||||
subRound( A, B, C, D, E, f3, K3, expand( data, 55 ) );
|
||||
subRound( E, A, B, C, D, f3, K3, expand( data, 56 ) );
|
||||
subRound( D, E, A, B, C, f3, K3, expand( data, 57 ) );
|
||||
subRound( C, D, E, A, B, f3, K3, expand( data, 58 ) );
|
||||
subRound( B, C, D, E, A, f3, K3, expand( data, 59 ) );
|
||||
|
||||
subRound( A, B, C, D, E, f4, K4, expand( data, 60 ) );
|
||||
subRound( E, A, B, C, D, f4, K4, expand( data, 61 ) );
|
||||
subRound( D, E, A, B, C, f4, K4, expand( data, 62 ) );
|
||||
subRound( C, D, E, A, B, f4, K4, expand( data, 63 ) );
|
||||
subRound( B, C, D, E, A, f4, K4, expand( data, 64 ) );
|
||||
subRound( A, B, C, D, E, f4, K4, expand( data, 65 ) );
|
||||
subRound( E, A, B, C, D, f4, K4, expand( data, 66 ) );
|
||||
subRound( D, E, A, B, C, f4, K4, expand( data, 67 ) );
|
||||
subRound( C, D, E, A, B, f4, K4, expand( data, 68 ) );
|
||||
subRound( B, C, D, E, A, f4, K4, expand( data, 69 ) );
|
||||
subRound( A, B, C, D, E, f4, K4, expand( data, 70 ) );
|
||||
subRound( E, A, B, C, D, f4, K4, expand( data, 71 ) );
|
||||
subRound( D, E, A, B, C, f4, K4, expand( data, 72 ) );
|
||||
subRound( C, D, E, A, B, f4, K4, expand( data, 73 ) );
|
||||
subRound( B, C, D, E, A, f4, K4, expand( data, 74 ) );
|
||||
subRound( A, B, C, D, E, f4, K4, expand( data, 75 ) );
|
||||
subRound( E, A, B, C, D, f4, K4, expand( data, 76 ) );
|
||||
subRound( D, E, A, B, C, f4, K4, expand( data, 77 ) );
|
||||
subRound( C, D, E, A, B, f4, K4, expand( data, 78 ) );
|
||||
subRound( B, C, D, E, A, f4, K4, expand( data, 79 ) );
|
||||
|
||||
/* Build message digest */
|
||||
state[0] += A;
|
||||
state[1] += B;
|
||||
state[2] += C;
|
||||
state[3] += D;
|
||||
state[4] += E;
|
||||
}
|
||||
|
||||
static void
|
||||
sha1_block(struct sha1_ctx *ctx, const UINT8 *block)
|
||||
{
|
||||
UINT32 data[SHA1_DATA_LENGTH];
|
||||
int i;
|
||||
|
||||
/* Update block count */
|
||||
if (!++ctx->count_low)
|
||||
++ctx->count_high;
|
||||
|
||||
/* Endian independent conversion */
|
||||
for (i = 0; i<SHA1_DATA_LENGTH; i++, block += 4)
|
||||
data[i] = READ_UINT32(block);
|
||||
|
||||
sha1_transform(ctx->digest, data);
|
||||
}
|
||||
|
||||
void
|
||||
sha1_update(struct sha1_ctx *ctx,
|
||||
unsigned length, const UINT8 *buffer)
|
||||
{
|
||||
if (ctx->index)
|
||||
{ /* Try to fill partial block */
|
||||
unsigned left = SHA1_DATA_SIZE - ctx->index;
|
||||
if (length < left)
|
||||
{
|
||||
memcpy(ctx->block + ctx->index, buffer, length);
|
||||
ctx->index += length;
|
||||
return; /* Finished */
|
||||
}
|
||||
else
|
||||
{
|
||||
memcpy(ctx->block + ctx->index, buffer, left);
|
||||
sha1_block(ctx, ctx->block);
|
||||
buffer += left;
|
||||
length -= left;
|
||||
}
|
||||
}
|
||||
while (length >= SHA1_DATA_SIZE)
|
||||
{
|
||||
sha1_block(ctx, buffer);
|
||||
buffer += SHA1_DATA_SIZE;
|
||||
length -= SHA1_DATA_SIZE;
|
||||
}
|
||||
ctx->index = length;
|
||||
if (length)
|
||||
/* Buffer leftovers */
|
||||
memcpy(ctx->block, buffer, length);
|
||||
}
|
||||
|
||||
/* Final wrapup - pad to SHA1_DATA_SIZE-byte boundary with the bit pattern
|
||||
1 0* (64-bit count of bits processed, MSB-first) */
|
||||
|
||||
void
|
||||
sha1_final(struct sha1_ctx *ctx)
|
||||
{
|
||||
UINT32 data[SHA1_DATA_LENGTH];
|
||||
int i;
|
||||
int words;
|
||||
|
||||
i = ctx->index;
|
||||
|
||||
/* Set the first char of padding to 0x80. This is safe since there is
|
||||
always at least one byte free */
|
||||
|
||||
assert(i < SHA1_DATA_SIZE);
|
||||
ctx->block[i++] = 0x80;
|
||||
|
||||
/* Fill rest of word */
|
||||
for( ; i & 3; i++)
|
||||
ctx->block[i] = 0;
|
||||
|
||||
/* i is now a multiple of the word size 4 */
|
||||
words = i >> 2;
|
||||
for (i = 0; i < words; i++)
|
||||
data[i] = READ_UINT32(ctx->block + 4*i);
|
||||
|
||||
if (words > (SHA1_DATA_LENGTH-2))
|
||||
{ /* No room for length in this block. Process it and
|
||||
* pad with another one */
|
||||
for (i = words ; i < SHA1_DATA_LENGTH; i++)
|
||||
data[i] = 0;
|
||||
sha1_transform(ctx->digest, data);
|
||||
for (i = 0; i < (SHA1_DATA_LENGTH-2); i++)
|
||||
data[i] = 0;
|
||||
}
|
||||
else
|
||||
for (i = words ; i < SHA1_DATA_LENGTH - 2; i++)
|
||||
data[i] = 0;
|
||||
|
||||
/* There are 512 = 2^9 bits in one block */
|
||||
data[SHA1_DATA_LENGTH-2] = (ctx->count_high << 9) | (ctx->count_low >> 23);
|
||||
data[SHA1_DATA_LENGTH-1] = (ctx->count_low << 9) | (ctx->index << 3);
|
||||
sha1_transform(ctx->digest, data);
|
||||
}
|
||||
|
||||
void
|
||||
sha1_digest(const struct sha1_ctx *ctx,
|
||||
unsigned length,
|
||||
UINT8 *digest)
|
||||
{
|
||||
unsigned i;
|
||||
unsigned words;
|
||||
unsigned leftover;
|
||||
|
||||
assert(length <= SHA1_DIGEST_SIZE);
|
||||
|
||||
words = length / 4;
|
||||
leftover = length % 4;
|
||||
|
||||
for (i = 0; i < words; i++, digest += 4)
|
||||
WRITE_UINT32(digest, ctx->digest[i]);
|
||||
|
||||
if (leftover)
|
||||
{
|
||||
UINT32 word;
|
||||
unsigned j = leftover;
|
||||
|
||||
assert(i < _SHA1_DIGEST_LENGTH);
|
||||
|
||||
word = ctx->digest[i];
|
||||
|
||||
switch (leftover)
|
||||
{
|
||||
default:
|
||||
/* this is just here to keep the compiler happy; it can never happen */
|
||||
case 3:
|
||||
digest[--j] = (word >> 8) & 0xff;
|
||||
/* Fall through */
|
||||
case 2:
|
||||
digest[--j] = (word >> 16) & 0xff;
|
||||
/* Fall through */
|
||||
case 1:
|
||||
digest[--j] = (word >> 24) & 0xff;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/* sha1.h
|
||||
*
|
||||
* The sha1 hash function.
|
||||
*/
|
||||
|
||||
/* nettle, low-level cryptographics library
|
||||
*
|
||||
* Copyright 2001 Niels Moeller
|
||||
*
|
||||
* The nettle library is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation; either version 2.1 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
* The nettle library is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
|
||||
* License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with the nettle library; see the file COPYING.LIB. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef NETTLE_SHA1_H_INCLUDED
|
||||
#define NETTLE_SHA1_H_INCLUDED
|
||||
|
||||
#include "../chdr/coretypes.h"
|
||||
|
||||
|
||||
|
||||
#define SHA1_DIGEST_SIZE 20
|
||||
#define SHA1_DATA_SIZE 64
|
||||
|
||||
/* Digest is kept internally as 4 32-bit words. */
|
||||
#define _SHA1_DIGEST_LENGTH 5
|
||||
|
||||
struct sha1_ctx
|
||||
{
|
||||
UINT32 digest[_SHA1_DIGEST_LENGTH]; /* Message digest */
|
||||
UINT32 count_low, count_high; /* 64-bit block count */
|
||||
UINT8 block[SHA1_DATA_SIZE]; /* SHA1 data buffer */
|
||||
unsigned int index; /* index into buffer */
|
||||
};
|
||||
|
||||
void
|
||||
sha1_init(struct sha1_ctx *ctx);
|
||||
|
||||
void
|
||||
sha1_update(struct sha1_ctx *ctx,
|
||||
unsigned length,
|
||||
const UINT8 *data);
|
||||
|
||||
void
|
||||
sha1_final(struct sha1_ctx *ctx);
|
||||
|
||||
void
|
||||
sha1_digest(const struct sha1_ctx *ctx,
|
||||
unsigned length,
|
||||
UINT8 *digest);
|
||||
|
||||
#endif /* NETTLE_SHA1_H_INCLUDED */
|
||||
@@ -1,161 +0,0 @@
|
||||
/*********************************************************************
|
||||
* Filename: sha256.c
|
||||
* Author: Brad Conte (brad AT bradconte.com)
|
||||
* Copyright:
|
||||
* Disclaimer: This code is presented "as is" without any guarantees.
|
||||
* Details: Implementation of the SHA-256 hashing algorithm.
|
||||
SHA-256 is one of the three algorithms in the SHA2
|
||||
specification. The others, SHA-384 and SHA-512, are not
|
||||
offered in this implementation.
|
||||
Algorithm specification can be found here:
|
||||
* http://csrc.nist.gov/publications/fips/fips180-2/fips180-2withchangenotice.pdf
|
||||
This implementation uses little endian byte order.
|
||||
*********************************************************************/
|
||||
|
||||
/*************************** HEADER FILES ***************************/
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "sha256.h"
|
||||
|
||||
#define WORD uint32_t
|
||||
#define BYTE uint8_t
|
||||
|
||||
/****************************** MACROS ******************************/
|
||||
#define ROTLEFT(a,b) (((a) << (b)) | ((a) >> (32-(b))))
|
||||
#define ROTRIGHT(a,b) (((a) >> (b)) | ((a) << (32-(b))))
|
||||
|
||||
#define CH(x,y,z) (((x) & (y)) ^ (~(x) & (z)))
|
||||
#define MAJ(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
|
||||
#define EP0(x) (ROTRIGHT(x,2) ^ ROTRIGHT(x,13) ^ ROTRIGHT(x,22))
|
||||
#define EP1(x) (ROTRIGHT(x,6) ^ ROTRIGHT(x,11) ^ ROTRIGHT(x,25))
|
||||
#define SIG0(x) (ROTRIGHT(x,7) ^ ROTRIGHT(x,18) ^ ((x) >> 3))
|
||||
#define SIG1(x) (ROTRIGHT(x,17) ^ ROTRIGHT(x,19) ^ ((x) >> 10))
|
||||
|
||||
/**************************** VARIABLES *****************************/
|
||||
static const WORD k[64] = {
|
||||
0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
|
||||
0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
|
||||
0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
|
||||
0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,
|
||||
0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,
|
||||
0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,
|
||||
0x19a4c116,0x1e376c08,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
|
||||
0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2
|
||||
};
|
||||
|
||||
/*********************** FUNCTION DEFINITIONS ***********************/
|
||||
void sha256_transform(SHA256_CTX *ctx, const BYTE data[])
|
||||
{
|
||||
WORD a, b, c, d, e, f, g, h, i, j, t1, t2, m[64];
|
||||
|
||||
for (i = 0, j = 0; i < 16; ++i, j += 4)
|
||||
m[i] = (data[j] << 24) | (data[j + 1] << 16) | (data[j + 2] << 8) | (data[j + 3]);
|
||||
for ( ; i < 64; ++i)
|
||||
m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
|
||||
|
||||
a = ctx->state[0];
|
||||
b = ctx->state[1];
|
||||
c = ctx->state[2];
|
||||
d = ctx->state[3];
|
||||
e = ctx->state[4];
|
||||
f = ctx->state[5];
|
||||
g = ctx->state[6];
|
||||
h = ctx->state[7];
|
||||
|
||||
for (i = 0; i < 64; ++i) {
|
||||
t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i];
|
||||
t2 = EP0(a) + MAJ(a,b,c);
|
||||
h = g;
|
||||
g = f;
|
||||
f = e;
|
||||
e = d + t1;
|
||||
d = c;
|
||||
c = b;
|
||||
b = a;
|
||||
a = t1 + t2;
|
||||
}
|
||||
|
||||
ctx->state[0] += a;
|
||||
ctx->state[1] += b;
|
||||
ctx->state[2] += c;
|
||||
ctx->state[3] += d;
|
||||
ctx->state[4] += e;
|
||||
ctx->state[5] += f;
|
||||
ctx->state[6] += g;
|
||||
ctx->state[7] += h;
|
||||
}
|
||||
|
||||
void sha256_init(SHA256_CTX *ctx)
|
||||
{
|
||||
ctx->datalen = 0;
|
||||
ctx->bitlen = 0;
|
||||
ctx->state[0] = 0x6a09e667;
|
||||
ctx->state[1] = 0xbb67ae85;
|
||||
ctx->state[2] = 0x3c6ef372;
|
||||
ctx->state[3] = 0xa54ff53a;
|
||||
ctx->state[4] = 0x510e527f;
|
||||
ctx->state[5] = 0x9b05688c;
|
||||
ctx->state[6] = 0x1f83d9ab;
|
||||
ctx->state[7] = 0x5be0cd19;
|
||||
}
|
||||
|
||||
void sha256_update(SHA256_CTX *ctx, const BYTE data[], size_t len)
|
||||
{
|
||||
WORD i;
|
||||
|
||||
for (i = 0; i < len; ++i) {
|
||||
ctx->data[ctx->datalen] = data[i];
|
||||
ctx->datalen++;
|
||||
if (ctx->datalen == 64) {
|
||||
sha256_transform(ctx, ctx->data);
|
||||
ctx->bitlen += 512;
|
||||
ctx->datalen = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void sha256_final(SHA256_CTX *ctx, BYTE hash[])
|
||||
{
|
||||
WORD i;
|
||||
|
||||
i = ctx->datalen;
|
||||
|
||||
// Pad whatever data is left in the buffer.
|
||||
if (ctx->datalen < 56) {
|
||||
ctx->data[i++] = 0x80;
|
||||
while (i < 56)
|
||||
ctx->data[i++] = 0x00;
|
||||
}
|
||||
else {
|
||||
ctx->data[i++] = 0x80;
|
||||
while (i < 64)
|
||||
ctx->data[i++] = 0x00;
|
||||
sha256_transform(ctx, ctx->data);
|
||||
memset(ctx->data, 0, 56);
|
||||
}
|
||||
|
||||
// Append to the padding the total message's length in bits and transform.
|
||||
ctx->bitlen += ctx->datalen * 8;
|
||||
ctx->data[63] = (BYTE)(ctx->bitlen);
|
||||
ctx->data[62] = (BYTE)(ctx->bitlen >> 8);
|
||||
ctx->data[61] = (BYTE)(ctx->bitlen >> 16);
|
||||
ctx->data[60] = (BYTE)(ctx->bitlen >> 24);
|
||||
ctx->data[59] = (BYTE)(ctx->bitlen >> 32);
|
||||
ctx->data[58] = (BYTE)(ctx->bitlen >> 40);
|
||||
ctx->data[57] = (BYTE)(ctx->bitlen >> 48);
|
||||
ctx->data[56] = (BYTE)(ctx->bitlen >> 56);
|
||||
sha256_transform(ctx, ctx->data);
|
||||
|
||||
// Since this implementation uses little endian byte ordering and SHA uses big endian,
|
||||
// reverse all the bytes when copying the final state to the output hash.
|
||||
for (i = 0; i < 4; ++i) {
|
||||
hash[i] = (ctx->state[0] >> (24 - i * 8)) & 0x000000ff;
|
||||
hash[i + 4] = (ctx->state[1] >> (24 - i * 8)) & 0x000000ff;
|
||||
hash[i + 8] = (ctx->state[2] >> (24 - i * 8)) & 0x000000ff;
|
||||
hash[i + 12] = (ctx->state[3] >> (24 - i * 8)) & 0x000000ff;
|
||||
hash[i + 16] = (ctx->state[4] >> (24 - i * 8)) & 0x000000ff;
|
||||
hash[i + 20] = (ctx->state[5] >> (24 - i * 8)) & 0x000000ff;
|
||||
hash[i + 24] = (ctx->state[6] >> (24 - i * 8)) & 0x000000ff;
|
||||
hash[i + 28] = (ctx->state[7] >> (24 - i * 8)) & 0x000000ff;
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*********************************************************************
|
||||
* Filename: sha256.h
|
||||
* Author: Brad Conte (brad AT bradconte.com)
|
||||
* Copyright:
|
||||
* Disclaimer: This code is presented "as is" without any guarantees.
|
||||
* Details: Defines the API for the corresponding SHA1 implementation.
|
||||
*********************************************************************/
|
||||
|
||||
#ifndef SHA256_H
|
||||
#define SHA256_H
|
||||
|
||||
/*************************** HEADER FILES ***************************/
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/****************************** MACROS ******************************/
|
||||
#define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest
|
||||
|
||||
/**************************** DATA TYPES ****************************/
|
||||
/*
|
||||
typedef uint8_t BYTE; // 8-bit byte
|
||||
typedef uint32_t WORD; // 32-bit word, change to "long" for 16-bit machines
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
uint8_t data[64];
|
||||
uint32_t datalen;
|
||||
uint64_t bitlen;
|
||||
uint32_t state[8];
|
||||
} SHA256_CTX;
|
||||
|
||||
/*********************** FUNCTION DECLARATIONS **********************/
|
||||
void sha256_init(SHA256_CTX *ctx);
|
||||
void sha256_update(SHA256_CTX *ctx, const uint8_t data[], size_t len);
|
||||
void sha256_final(SHA256_CTX *ctx, uint8_t hash[]);
|
||||
|
||||
#endif // SHA256_H
|
||||
@@ -29,6 +29,10 @@
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_PC_APP || WINAPI_FAMILY == WINAPI_FAMILY_PHONE_APP)
|
||||
#define FindFirstFileExW FindFirstFileExFromAppW
|
||||
#endif
|
||||
|
||||
/* Indicates that d_type field is available in dirent structure */
|
||||
#define _DIRENT_HAVE_D_TYPE
|
||||
|
||||
@@ -613,7 +617,7 @@ dirent_first(
|
||||
/* Failed to re-open directory: no directory entry in memory */
|
||||
dirp->cached = 0;
|
||||
datap = NULL;
|
||||
|
||||
dirent_set_errno(GetLastError()); /* Not a valid errno but better than nothing */
|
||||
}
|
||||
return datap;
|
||||
}
|
||||
@@ -647,6 +651,8 @@ dirent_next(
|
||||
FindClose (dirp->handle);
|
||||
dirp->handle = INVALID_HANDLE_VALUE;
|
||||
p = NULL;
|
||||
if (GetLastError() != ERROR_NO_MORE_FILES)
|
||||
dirent_set_errno(GetLastError());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,598 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _GGPONET_H_
|
||||
#define _GGPONET_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
// On windows, export at build time and import at runtime.
|
||||
// ELF systems don't need an explicit export/import.
|
||||
#ifdef _WIN32
|
||||
# if defined(GGPO_SHARED_LIB)
|
||||
# ifdef GGPO_SDK_EXPORT
|
||||
# define GGPO_API __declspec(dllexport)
|
||||
# else
|
||||
# define GGPO_API __declspec(dllimport)
|
||||
# endif
|
||||
# else
|
||||
# define GGPO_API
|
||||
# endif
|
||||
#else
|
||||
# define GGPO_API
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(_WIN32) && !defined(_WIN64)
|
||||
#define __cdecl __attribute__((cdecl))
|
||||
#elif !defined(__cdecl)
|
||||
#define __cdecl
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define GGPO_MAX_PLAYERS 4
|
||||
#define GGPO_MAX_PREDICTION_FRAMES 8
|
||||
#define GGPO_MAX_SPECTATORS 32
|
||||
|
||||
#define GGPO_SPECTATOR_INPUT_INTERVAL 4
|
||||
|
||||
typedef struct GGPOSession GGPOSession;
|
||||
|
||||
typedef int GGPOPlayerHandle;
|
||||
|
||||
typedef enum {
|
||||
GGPO_PLAYERTYPE_LOCAL,
|
||||
GGPO_PLAYERTYPE_REMOTE,
|
||||
GGPO_PLAYERTYPE_SPECTATOR,
|
||||
} GGPOPlayerType;
|
||||
|
||||
/*
|
||||
* The GGPOPlayer structure used to describe players in ggpo_add_player
|
||||
*
|
||||
* size: Should be set to the sizeof(GGPOPlayer)
|
||||
*
|
||||
* type: One of the GGPOPlayerType values describing how inputs should be handled
|
||||
* Local players must have their inputs updated every frame via
|
||||
* ggpo_add_local_inputs. Remote players values will come over the
|
||||
* network.
|
||||
*
|
||||
* player_num: The player number. Should be between 1 and the number of players
|
||||
* In the game (e.g. in a 2 player game, either 1 or 2).
|
||||
*
|
||||
* If type == GGPO_PLAYERTYPE_REMOTE:
|
||||
*
|
||||
* u.remote.ip_address: The ip address of the ggpo session which will host this
|
||||
* player.
|
||||
*
|
||||
* u.remote.port: The port where udp packets should be sent to reach this player.
|
||||
* All the local inputs for this session will be sent to this player at
|
||||
* ip_address:port.
|
||||
*
|
||||
*/
|
||||
|
||||
typedef struct GGPOPlayer {
|
||||
int size;
|
||||
GGPOPlayerType type;
|
||||
int player_num;
|
||||
union {
|
||||
struct {
|
||||
bool _unused;
|
||||
} local;
|
||||
struct {
|
||||
char ip_address[32];
|
||||
unsigned short port;
|
||||
} remote;
|
||||
} u;
|
||||
} GGPOPlayer;
|
||||
|
||||
typedef struct GGPOLocalEndpoint {
|
||||
int player_num;
|
||||
} GGPOLocalEndpoint;
|
||||
|
||||
|
||||
#define GGPO_ERRORLIST \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_OK, 0) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_SUCCESS, 0) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_GENERAL_FAILURE, -1) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_INVALID_SESSION, 1) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_INVALID_PLAYER_HANDLE, 2) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_PLAYER_OUT_OF_RANGE, 3) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_PREDICTION_THRESHOLD, 4) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_UNSUPPORTED, 5) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_NOT_SYNCHRONIZED, 6) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_IN_ROLLBACK, 7) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_INPUT_DROPPED, 8) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_PLAYER_DISCONNECTED, 9) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_TOO_MANY_SPECTATORS, 10) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_INVALID_REQUEST, 11) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_INPUT_SIZE_DIFF, 12) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_NETWORK_ERROR, 13) \
|
||||
GGPO_ERRORLIST_ENTRY(GGPO_ERRORCODE_VERIFICATION_ERROR, 14)
|
||||
|
||||
#define GGPO_ERRORLIST_ENTRY(name, value) name = value,
|
||||
typedef enum {
|
||||
GGPO_ERRORLIST
|
||||
} GGPOErrorCode;
|
||||
#undef GGPO_ERRORLIST_ENTRY
|
||||
|
||||
#define GGPO_SUCCEEDED(result) ((result) == GGPO_ERRORCODE_SUCCESS)
|
||||
|
||||
|
||||
#define GGPO_INVALID_HANDLE (-1)
|
||||
|
||||
|
||||
/*
|
||||
* The GGPOEventCode enumeration describes what type of event just happened.
|
||||
*
|
||||
* GGPO_EVENTCODE_CONNECTED_TO_PEER - Handshake with the game running on the
|
||||
* other side of the network has been completed.
|
||||
*
|
||||
* GGPO_EVENTCODE_SYNCHRONIZING_WITH_PEER - Beginning the synchronization
|
||||
* process with the client on the other end of the networking. The count
|
||||
* and total fields in the u.synchronizing struct of the GGPOEvent
|
||||
* object indicate progress.
|
||||
*
|
||||
* GGPO_EVENTCODE_SYNCHRONIZED_WITH_PEER - The synchronziation with this
|
||||
* peer has finished.
|
||||
*
|
||||
* GGPO_EVENTCODE_RUNNING - All the clients have synchronized. You may begin
|
||||
* sending inputs with ggpo_synchronize_inputs.
|
||||
*
|
||||
* GGPO_EVENTCODE_DISCONNECTED_FROM_PEER - The network connection on
|
||||
* the other end of the network has closed.
|
||||
*
|
||||
* GGPO_EVENTCODE_TIMESYNC - The time synchronziation code has determined
|
||||
* that this client is too far ahead of the other one and should slow
|
||||
* down to ensure fairness. The u.timesync.frames_ahead parameter in
|
||||
* the GGPOEvent object indicates how many frames the client is.
|
||||
*
|
||||
*/
|
||||
typedef enum {
|
||||
GGPO_EVENTCODE_CONNECTED_TO_PEER = 1000,
|
||||
GGPO_EVENTCODE_SYNCHRONIZING_WITH_PEER = 1001,
|
||||
GGPO_EVENTCODE_SYNCHRONIZED_WITH_PEER = 1002,
|
||||
GGPO_EVENTCODE_RUNNING = 1003,
|
||||
GGPO_EVENTCODE_DISCONNECTED_FROM_PEER = 1004,
|
||||
GGPO_EVENTCODE_TIMESYNC = 1005,
|
||||
GGPO_EVENTCODE_CONNECTION_INTERRUPTED = 1006,
|
||||
GGPO_EVENTCODE_CONNECTION_RESUMED = 1007,
|
||||
} GGPOEventCode;
|
||||
|
||||
/*
|
||||
* The GGPOEvent structure contains an asynchronous event notification sent
|
||||
* by the on_event callback. See GGPOEventCode, above, for a detailed
|
||||
* explanation of each event.
|
||||
*/
|
||||
typedef struct {
|
||||
GGPOEventCode code;
|
||||
union {
|
||||
struct {
|
||||
GGPOPlayerHandle player;
|
||||
} connected;
|
||||
struct {
|
||||
GGPOPlayerHandle player;
|
||||
int count;
|
||||
int total;
|
||||
} synchronizing;
|
||||
struct {
|
||||
GGPOPlayerHandle player;
|
||||
} synchronized;
|
||||
struct {
|
||||
GGPOPlayerHandle player;
|
||||
} disconnected;
|
||||
struct {
|
||||
int frames_ahead;
|
||||
} timesync;
|
||||
struct {
|
||||
GGPOPlayerHandle player;
|
||||
int disconnect_timeout;
|
||||
} connection_interrupted;
|
||||
struct {
|
||||
GGPOPlayerHandle player;
|
||||
} connection_resumed;
|
||||
} u;
|
||||
} GGPOEvent;
|
||||
|
||||
/*
|
||||
* The GGPOSessionCallbacks structure contains the callback functions that
|
||||
* your application must implement. GGPO.net will periodically call these
|
||||
* functions during the game. All callback functions must be implemented.
|
||||
*/
|
||||
typedef struct {
|
||||
/*
|
||||
* begin_game callback - This callback has been deprecated. You must
|
||||
* implement it, but should ignore the 'game' parameter.
|
||||
*/
|
||||
bool (__cdecl *begin_game)(const char *game);
|
||||
|
||||
/*
|
||||
* save_game_state - The client should allocate a buffer, copy the
|
||||
* entire contents of the current game state into it, and copy the
|
||||
* length into the *len parameter. Optionally, the client can compute
|
||||
* a checksum of the data and store it in the *checksum argument.
|
||||
*/
|
||||
bool (__cdecl *save_game_state)(unsigned char **buffer, int *len, int *checksum, int frame);
|
||||
|
||||
/*
|
||||
* load_game_state - GGPO.net will call this function at the beginning
|
||||
* of a rollback. The buffer and len parameters contain a previously
|
||||
* saved state returned from the save_game_state function. The client
|
||||
* should make the current game state match the state contained in the
|
||||
* buffer.
|
||||
*/
|
||||
bool (__cdecl *load_game_state)(unsigned char *buffer, int len);
|
||||
|
||||
/*
|
||||
* log_game_state - Used in diagnostic testing. The client should use
|
||||
* the ggpo_log function to write the contents of the specified save
|
||||
* state in a human readible form.
|
||||
*/
|
||||
bool (__cdecl *log_game_state)(char *filename, unsigned char *buffer, int len);
|
||||
|
||||
/*
|
||||
* free_buffer - Frees a game state allocated in save_game_state. You
|
||||
* should deallocate the memory contained in the buffer.
|
||||
*/
|
||||
void (__cdecl *free_buffer)(void *buffer);
|
||||
|
||||
/*
|
||||
* advance_frame - Called during a rollback. You should advance your game
|
||||
* state by exactly one frame. Before each frame, call ggpo_synchronize_input
|
||||
* to retrieve the inputs you should use for that frame. After each frame,
|
||||
* you should call ggpo_advance_frame to notify GGPO.net that you're
|
||||
* finished.
|
||||
*
|
||||
* The flags parameter is reserved. It can safely be ignored at this time.
|
||||
*/
|
||||
bool (__cdecl *advance_frame)(int flags);
|
||||
|
||||
/*
|
||||
* on_event - Notification that something has happened. See the GGPOEventCode
|
||||
* structure above for more information.
|
||||
*/
|
||||
bool (__cdecl *on_event)(GGPOEvent *info);
|
||||
|
||||
/*
|
||||
* on_message - Delivers an application message. Allows arbitrary data to be
|
||||
* exchanged with peers. This callback is optional.
|
||||
*/
|
||||
void (__cdecl *on_message)(unsigned char *msg, int len);
|
||||
} GGPOSessionCallbacks;
|
||||
|
||||
/*
|
||||
* The GGPONetworkStats function contains some statistics about the current
|
||||
* session.
|
||||
*
|
||||
* network.send_queue_len - The length of the queue containing UDP packets
|
||||
* which have not yet been acknowledged by the end client. The length of
|
||||
* the send queue is a rough indication of the quality of the connection.
|
||||
* The longer the send queue, the higher the round-trip time between the
|
||||
* clients. The send queue will also be longer than usual during high
|
||||
* packet loss situations.
|
||||
*
|
||||
* network.recv_queue_len - The number of inputs currently buffered by the
|
||||
* GGPO.net network layer which have yet to be validated. The length of
|
||||
* the prediction queue is roughly equal to the current frame number
|
||||
* minus the frame number of the last packet in the remote queue.
|
||||
*
|
||||
* network.ping - The roundtrip packet transmission time as calcuated
|
||||
* by GGPO.net. This will be roughly equal to the actual round trip
|
||||
* packet transmission time + 2 the interval at which you call ggpo_idle
|
||||
* or ggpo_advance_frame.
|
||||
*
|
||||
* network.kbps_sent - The estimated bandwidth used between the two
|
||||
* clients, in kilobits per second.
|
||||
*
|
||||
* timesync.local_frames_behind - The number of frames GGPO.net calculates
|
||||
* that the local client is behind the remote client at this instant in
|
||||
* time. For example, if at this instant the current game client is running
|
||||
* frame 1002 and the remote game client is running frame 1009, this value
|
||||
* will mostly likely roughly equal 7.
|
||||
*
|
||||
* timesync.remote_frames_behind - The same as local_frames_behind, but
|
||||
* calculated from the perspective of the remote player.
|
||||
*
|
||||
*/
|
||||
typedef struct GGPONetworkStats {
|
||||
struct {
|
||||
int send_queue_len;
|
||||
int recv_queue_len;
|
||||
int ping;
|
||||
int kbps_sent;
|
||||
} network;
|
||||
struct {
|
||||
int local_frames_behind;
|
||||
int remote_frames_behind;
|
||||
} timesync;
|
||||
struct {
|
||||
int predicted_frames;
|
||||
} sync;
|
||||
} GGPONetworkStats;
|
||||
|
||||
/*
|
||||
* ggpo_start_session --
|
||||
*
|
||||
* Used to being a new GGPO.net session. The ggpo object returned by ggpo_start_session
|
||||
* uniquely identifies the state for this session and should be passed to all other
|
||||
* functions.
|
||||
*
|
||||
* session - An out parameter to the new ggpo session object.
|
||||
*
|
||||
* cb - A GGPOSessionCallbacks structure which contains the callbacks you implement
|
||||
* to help GGPO.net synchronize the two games. You must implement all functions in
|
||||
* cb, even if they do nothing but 'return true';
|
||||
*
|
||||
* game - The name of the game. This is used internally for GGPO for logging purposes only.
|
||||
*
|
||||
* num_players - The number of players which will be in this game. The number of players
|
||||
* per session is fixed. If you need to change the number of players or any player
|
||||
* disconnects, you must start a new session.
|
||||
*
|
||||
* input_size - The size of the game inputs which will be passsed to ggpo_add_local_input.
|
||||
*
|
||||
* local_port - The port GGPO should bind to for UDP traffic.
|
||||
*
|
||||
* verification - Some optional data that will be matched with the peers during initial sync.
|
||||
* Can be set to null if verification_size is zero. This can be used to check that all peers are
|
||||
* running the same version of the application and of the game, are using the same settings, etc.
|
||||
*
|
||||
* verification_size - Size of the verification data. Can be set to zero to not exchange verification data.
|
||||
* Maximum size is 256 bytes.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_start_session(GGPOSession **session,
|
||||
GGPOSessionCallbacks *cb,
|
||||
const char *game,
|
||||
int num_players,
|
||||
int input_size,
|
||||
unsigned short localport,
|
||||
const void *verification,
|
||||
int verification_size);
|
||||
|
||||
|
||||
/*
|
||||
* ggpo_add_player --
|
||||
*
|
||||
* Must be called for each player in the session (e.g. in a 3 player session, must
|
||||
* be called 3 times).
|
||||
*
|
||||
* player - A GGPOPlayer struct used to describe the player.
|
||||
*
|
||||
* handle - An out parameter to a handle used to identify this player in the future.
|
||||
* (e.g. in the on_event callbacks).
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_add_player(GGPOSession *session,
|
||||
GGPOPlayer *player,
|
||||
GGPOPlayerHandle *handle);
|
||||
|
||||
|
||||
/*
|
||||
* ggpo_start_synctest --
|
||||
*
|
||||
* Used to being a new GGPO.net sync test session. During a sync test, every
|
||||
* frame of execution is run twice: once in prediction mode and once again to
|
||||
* verify the result of the prediction. If the checksums of your save states
|
||||
* do not match, the test is aborted.
|
||||
*
|
||||
* cb - A GGPOSessionCallbacks structure which contains the callbacks you implement
|
||||
* to help GGPO.net synchronize the two games. You must implement all functions in
|
||||
* cb, even if they do nothing but 'return true';
|
||||
*
|
||||
* game - The name of the game. This is used internally for GGPO for logging purposes only.
|
||||
*
|
||||
* num_players - The number of players which will be in this game. The number of players
|
||||
* per session is fixed. If you need to change the number of players or any player
|
||||
* disconnects, you must start a new session.
|
||||
*
|
||||
* input_size - The size of the game inputs which will be passsed to ggpo_add_local_input.
|
||||
*
|
||||
* frames - The number of frames to run before verifying the prediction. The
|
||||
* recommended value is 1.
|
||||
*
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_start_synctest(GGPOSession **session,
|
||||
GGPOSessionCallbacks *cb,
|
||||
const char *game,
|
||||
int num_players,
|
||||
int input_size,
|
||||
int frames);
|
||||
|
||||
|
||||
/*
|
||||
* ggpo_start_spectating --
|
||||
*
|
||||
* Start a spectator session.
|
||||
*
|
||||
* cb - A GGPOSessionCallbacks structure which contains the callbacks you implement
|
||||
* to help GGPO.net synchronize the two games. You must implement all functions in
|
||||
* cb, even if they do nothing but 'return true';
|
||||
*
|
||||
* game - The name of the game. This is used internally for GGPO for logging purposes only.
|
||||
*
|
||||
* num_players - The number of players which will be in this game. The number of players
|
||||
* per session is fixed. If you need to change the number of players or any player
|
||||
* disconnects, you must start a new session.
|
||||
*
|
||||
* input_size - The size of the game inputs which will be passsed to ggpo_add_local_input.
|
||||
*
|
||||
* local_port - The port GGPO should bind to for UDP traffic.
|
||||
*
|
||||
* host_ip - The IP address of the host who will serve you the inputs for the game. Any
|
||||
* player partcipating in the session can serve as a host.
|
||||
*
|
||||
* host_port - The port of the session on the host
|
||||
*
|
||||
* verification - Some optional data that will be matched with the peers during initial sync.
|
||||
* Can be set to null if verification_size is zero. This can be used to check that all peers are
|
||||
* running the same version of the application and of the game, are using the same settings, etc.
|
||||
*
|
||||
* verification_size - Size of the verification data. Can be set to zero to not exchange verification data.
|
||||
* Maximum size is 256 bytes.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_start_spectating(GGPOSession **session,
|
||||
GGPOSessionCallbacks *cb,
|
||||
const char *game,
|
||||
int num_players,
|
||||
int input_size,
|
||||
unsigned short local_port,
|
||||
char *host_ip,
|
||||
unsigned short host_port,
|
||||
const void *verification,
|
||||
int verification_size);
|
||||
|
||||
/*
|
||||
* ggpo_close_session --
|
||||
* Used to close a session. You must call ggpo_close_session to
|
||||
* free the resources allocated in ggpo_start_session.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_close_session(GGPOSession *);
|
||||
|
||||
|
||||
/*
|
||||
* ggpo_set_frame_delay --
|
||||
*
|
||||
* Change the amount of frames ggpo will delay local input. Must be called
|
||||
* before the first call to ggpo_synchronize_input.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_set_frame_delay(GGPOSession *,
|
||||
GGPOPlayerHandle player,
|
||||
int frame_delay);
|
||||
|
||||
/*
|
||||
* ggpo_idle --
|
||||
* Should be called periodically by your application to give GGPO.net
|
||||
* a chance to do some work. Most packet transmissions and rollbacks occur
|
||||
* in ggpo_idle.
|
||||
*
|
||||
* timeout - The amount of time GGPO.net is allowed to spend in this function,
|
||||
* in milliseconds.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_idle(GGPOSession *,
|
||||
int timeout);
|
||||
|
||||
/*
|
||||
* ggpo_add_local_input --
|
||||
*
|
||||
* Used to notify GGPO.net of inputs that should be trasmitted to remote
|
||||
* players. ggpo_add_local_input must be called once every frame for
|
||||
* all player of type GGPO_PLAYERTYPE_LOCAL.
|
||||
*
|
||||
* player - The player handle returned for this player when you called
|
||||
* ggpo_add_local_player.
|
||||
*
|
||||
* values - The controller inputs for this player.
|
||||
*
|
||||
* size - The size of the controller inputs. This must be exactly equal to the
|
||||
* size passed into ggpo_start_session.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_add_local_input(GGPOSession *,
|
||||
GGPOPlayerHandle player,
|
||||
void *values,
|
||||
int size);
|
||||
|
||||
/*
|
||||
* ggpo_synchronize_input --
|
||||
*
|
||||
* You should call ggpo_synchronize_input before every frame of execution,
|
||||
* including those frames which happen during rollback.
|
||||
*
|
||||
* values - When the function returns, the values parameter will contain
|
||||
* inputs for this frame for all players. The values array must be at
|
||||
* least (size * players) large.
|
||||
*
|
||||
* size - The size of the values array.
|
||||
*
|
||||
* disconnect_flags - Indicated whether the input in slot (1 << flag) is
|
||||
* valid. If a player has disconnected, the input in the values array for
|
||||
* that player will be zeroed and the i-th flag will be set. For example,
|
||||
* if only player 3 has disconnected, disconnect flags will be 8 (i.e. 1 << 3).
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_synchronize_input(GGPOSession *,
|
||||
void *values,
|
||||
int size,
|
||||
int *disconnect_flags);
|
||||
|
||||
/*
|
||||
* ggpo_disconnect_player --
|
||||
*
|
||||
* Disconnects a remote player from a game. Will return GGPO_ERRORCODE_PLAYER_DISCONNECTED
|
||||
* if you try to disconnect a player who has already been disconnected.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_disconnect_player(GGPOSession *,
|
||||
GGPOPlayerHandle player);
|
||||
|
||||
/*
|
||||
* ggpo_advance_frame --
|
||||
*
|
||||
* You should call ggpo_advance_frame to notify GGPO.net that you have
|
||||
* advanced your gamestate by a single frame. You should call this everytime
|
||||
* you advance the gamestate by a frame, even during rollbacks. GGPO.net
|
||||
* may call your save_state callback before this function returns.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_advance_frame(GGPOSession *);
|
||||
|
||||
/*
|
||||
* ggpo_get_network_stats --
|
||||
*
|
||||
* Used to fetch some statistics about the quality of the network connection.
|
||||
*
|
||||
* player - The player handle returned from the ggpo_add_player function you used
|
||||
* to add the remote player.
|
||||
*
|
||||
* stats - Out parameter to the network statistics.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_get_network_stats(GGPOSession *,
|
||||
GGPOPlayerHandle player,
|
||||
GGPONetworkStats *stats);
|
||||
|
||||
/*
|
||||
* ggpo_set_disconnect_timeout --
|
||||
*
|
||||
* Sets the disconnect timeout. The session will automatically disconnect
|
||||
* from a remote peer if it has not received a packet in the timeout window.
|
||||
* You will be notified of the disconnect via a GGPO_EVENTCODE_DISCONNECTED_FROM_PEER
|
||||
* event.
|
||||
*
|
||||
* Setting a timeout value of 0 will disable automatic disconnects.
|
||||
*
|
||||
* timeout - The time in milliseconds to wait before disconnecting a peer.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_set_disconnect_timeout(GGPOSession *,
|
||||
int timeout);
|
||||
|
||||
/*
|
||||
* ggpo_set_disconnect_notify_start --
|
||||
*
|
||||
* The time to wait before the first GGPO_EVENTCODE_NETWORK_INTERRUPTED timeout
|
||||
* will be sent.
|
||||
*
|
||||
* timeout - The amount of time which needs to elapse without receiving a packet
|
||||
* before the GGPO_EVENTCODE_NETWORK_INTERRUPTED event is sent.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_set_disconnect_notify_start(GGPOSession *,
|
||||
int timeout);
|
||||
|
||||
/*
|
||||
* ggpo_send_message --
|
||||
*
|
||||
* Sends application-specific data to other peers. The message is
|
||||
* delivered by the on_user_message callback.
|
||||
* If spectators is true, the message is also sent to spectators.
|
||||
*/
|
||||
GGPO_API GGPOErrorCode __cdecl ggpo_send_message(GGPOSession *,
|
||||
const void *msg,
|
||||
int len,
|
||||
bool spectators);
|
||||
|
||||
#ifdef __cplusplus
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,33 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _BACKEND_H
|
||||
#define _BACKEND_H
|
||||
|
||||
#include "../ggpo_types.h"
|
||||
#include "ggponet.h"
|
||||
|
||||
struct GGPOSession {
|
||||
virtual ~GGPOSession() { }
|
||||
virtual GGPOErrorCode DoPoll(int timeout) { return GGPO_OK; }
|
||||
virtual GGPOErrorCode AddPlayer(GGPOPlayer *player, GGPOPlayerHandle *handle) = 0;
|
||||
virtual GGPOErrorCode AddLocalInput(GGPOPlayerHandle player, void *values, int size) = 0;
|
||||
virtual GGPOErrorCode SyncInput(void *values, int size, int *disconnect_flags) = 0;
|
||||
virtual GGPOErrorCode IncrementFrame(void) { return GGPO_OK; }
|
||||
virtual GGPOErrorCode DisconnectPlayer(GGPOPlayerHandle handle) { return GGPO_OK; }
|
||||
virtual GGPOErrorCode GetNetworkStats(GGPONetworkStats *stats, GGPOPlayerHandle handle) { return GGPO_OK; }
|
||||
|
||||
virtual GGPOErrorCode SetFrameDelay(GGPOPlayerHandle player, int delay) { return GGPO_ERRORCODE_UNSUPPORTED; }
|
||||
virtual GGPOErrorCode SetDisconnectTimeout(int timeout) { return GGPO_ERRORCODE_UNSUPPORTED; }
|
||||
virtual GGPOErrorCode SetDisconnectNotifyStart(int timeout) { return GGPO_ERRORCODE_UNSUPPORTED; }
|
||||
virtual GGPOErrorCode SendMessage(const void *msg, int len, bool spectators) { return GGPO_ERRORCODE_UNSUPPORTED; }
|
||||
};
|
||||
|
||||
typedef struct GGPOSession Quark, IQuarkBackend; /* XXX: nuke this */
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,664 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "p2p.h"
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
static const int RECOMMENDATION_INTERVAL = 240;
|
||||
static const int DEFAULT_DISCONNECT_TIMEOUT = 5000;
|
||||
static const int DEFAULT_DISCONNECT_NOTIFY_START = 750;
|
||||
|
||||
Peer2PeerBackend::Peer2PeerBackend(GGPOSessionCallbacks *cb,
|
||||
const char *gamename,
|
||||
uint16 localport,
|
||||
int num_players,
|
||||
int input_size,
|
||||
const void *verification,
|
||||
int verification_size) :
|
||||
_sync(_local_connect_status),
|
||||
_endpoints(nullptr),
|
||||
_num_spectators(0),
|
||||
_input_size(input_size),
|
||||
_num_players(num_players),
|
||||
_next_spectator_frame(0),
|
||||
_disconnect_timeout(DEFAULT_DISCONNECT_TIMEOUT),
|
||||
_disconnect_notify_start(DEFAULT_DISCONNECT_NOTIFY_START)
|
||||
{
|
||||
_callbacks = *cb;
|
||||
_synchronizing = true;
|
||||
_next_recommended_sleep = 0;
|
||||
|
||||
/*
|
||||
* Initialize the synchronziation layer
|
||||
*/
|
||||
Sync::Config config = { 0 };
|
||||
config.num_players = num_players;
|
||||
config.input_size = input_size;
|
||||
config.callbacks = _callbacks;
|
||||
config.num_prediction_frames = MAX_PREDICTION_FRAMES;
|
||||
_sync.Init(config);
|
||||
|
||||
/*
|
||||
* Initialize the UDP port
|
||||
*/
|
||||
_udp.Init(localport, &_poll, this);
|
||||
|
||||
_endpoints = new UdpProtocol[_num_players];
|
||||
for (int i = 0; i < _num_players; i++)
|
||||
_endpoints[i].SetVerificationData(verification, verification_size);
|
||||
memset(_local_connect_status, 0, sizeof(_local_connect_status));
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(_local_connect_status); i++) {
|
||||
_local_connect_status[i].last_frame = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Preload the ROM
|
||||
*/
|
||||
_callbacks.begin_game(gamename);
|
||||
}
|
||||
|
||||
Peer2PeerBackend::~Peer2PeerBackend()
|
||||
{
|
||||
delete [] _endpoints;
|
||||
}
|
||||
|
||||
void
|
||||
Peer2PeerBackend::AddRemotePlayer(char *ip,
|
||||
uint16 port,
|
||||
int queue)
|
||||
{
|
||||
/*
|
||||
* Start the state machine (xxx: no)
|
||||
*/
|
||||
_synchronizing = true;
|
||||
|
||||
_endpoints[queue].Init(&_udp, _poll, queue, ip, port, _local_connect_status);
|
||||
_endpoints[queue].SetDisconnectTimeout(_disconnect_timeout);
|
||||
_endpoints[queue].SetDisconnectNotifyStart(_disconnect_notify_start);
|
||||
_endpoints[queue].Synchronize();
|
||||
}
|
||||
|
||||
GGPOErrorCode Peer2PeerBackend::AddSpectator(char *ip,
|
||||
uint16 port)
|
||||
{
|
||||
if (_num_spectators == GGPO_MAX_SPECTATORS) {
|
||||
return GGPO_ERRORCODE_TOO_MANY_SPECTATORS;
|
||||
}
|
||||
/*
|
||||
* Currently, we can only add spectators before the game starts.
|
||||
*/
|
||||
if (!_synchronizing) {
|
||||
return GGPO_ERRORCODE_INVALID_REQUEST;
|
||||
}
|
||||
int queue = _num_spectators++;
|
||||
|
||||
_spectators[queue].Init(&_udp, _poll, queue + 1000, ip, port, _local_connect_status);
|
||||
_spectators[queue].SetDisconnectTimeout(_disconnect_timeout);
|
||||
_spectators[queue].SetDisconnectNotifyStart(_disconnect_notify_start);
|
||||
_spectators[queue].Synchronize();
|
||||
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
Peer2PeerBackend::DoPoll(int timeout)
|
||||
{
|
||||
if (!_sync.InRollback()) {
|
||||
_poll.Pump(0);
|
||||
|
||||
PollUdpProtocolEvents();
|
||||
|
||||
if (!_synchronizing) {
|
||||
_sync.CheckSimulation(timeout);
|
||||
|
||||
// notify all of our endpoints of their local frame number for their
|
||||
// next connection quality report
|
||||
int current_frame = _sync.GetFrameCount();
|
||||
for (int i = 0; i < _num_players; i++) {
|
||||
_endpoints[i].SetLocalFrameNumber(current_frame);
|
||||
}
|
||||
|
||||
int total_min_confirmed;
|
||||
if (_num_players <= 2) {
|
||||
total_min_confirmed = Poll2Players(current_frame);
|
||||
} else {
|
||||
total_min_confirmed = PollNPlayers(current_frame);
|
||||
}
|
||||
|
||||
Log("last confirmed frame in p2p backend is %d.", total_min_confirmed);
|
||||
if (total_min_confirmed >= 0) {
|
||||
ASSERT(total_min_confirmed != INT_MAX);
|
||||
if (_num_spectators > 0) {
|
||||
while (_next_spectator_frame <= total_min_confirmed) {
|
||||
Log("pushing frame %d to spectators.", _next_spectator_frame);
|
||||
|
||||
GameInput input;
|
||||
input.frame = _next_spectator_frame;
|
||||
input.size = _input_size * _num_players;
|
||||
_sync.GetConfirmedInputs(input.bits, _input_size * _num_players, _next_spectator_frame);
|
||||
for (int i = 0; i < _num_spectators; i++) {
|
||||
_spectators[i].SendInput(input);
|
||||
}
|
||||
_next_spectator_frame++;
|
||||
}
|
||||
}
|
||||
Log("setting confirmed frame in sync to %d.", total_min_confirmed);
|
||||
_sync.SetLastConfirmedFrame(total_min_confirmed);
|
||||
}
|
||||
|
||||
// send timesync notifications if now is the proper time
|
||||
if (current_frame > _next_recommended_sleep) {
|
||||
int interval = 0;
|
||||
for (int i = 0; i < _num_players; i++) {
|
||||
interval = MAX(interval, _endpoints[i].RecommendFrameDelay());
|
||||
}
|
||||
|
||||
if (interval > 0) {
|
||||
GGPOEvent info;
|
||||
info.code = GGPO_EVENTCODE_TIMESYNC;
|
||||
info.u.timesync.frames_ahead = interval;
|
||||
_callbacks.on_event(&info);
|
||||
_next_recommended_sleep = current_frame + RECOMMENDATION_INTERVAL;
|
||||
}
|
||||
}
|
||||
// XXX: this is obviously a farce...
|
||||
if (timeout)
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(1));
|
||||
}
|
||||
}
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
int Peer2PeerBackend::Poll2Players(int current_frame)
|
||||
{
|
||||
int i;
|
||||
|
||||
// discard confirmed frames as appropriate
|
||||
int total_min_confirmed = MAX_INT;
|
||||
for (i = 0; i < _num_players; i++) {
|
||||
bool queue_connected = true;
|
||||
if (_endpoints[i].IsRunning()) {
|
||||
int ignore;
|
||||
queue_connected = _endpoints[i].GetPeerConnectStatus(i, &ignore);
|
||||
}
|
||||
if (!_local_connect_status[i].disconnected) {
|
||||
total_min_confirmed = MIN(_local_connect_status[i].last_frame, total_min_confirmed);
|
||||
}
|
||||
Log(" local endp: connected = %d, last_received = %d, total_min_confirmed = %d.", !_local_connect_status[i].disconnected, _local_connect_status[i].last_frame, total_min_confirmed);
|
||||
if (!queue_connected && !_local_connect_status[i].disconnected) {
|
||||
Log("disconnecting i %d by remote request.", i);
|
||||
DisconnectPlayerQueue(i, total_min_confirmed);
|
||||
}
|
||||
Log(" total_min_confirmed = %d.", total_min_confirmed);
|
||||
}
|
||||
return total_min_confirmed;
|
||||
}
|
||||
|
||||
int Peer2PeerBackend::PollNPlayers(int current_frame)
|
||||
{
|
||||
int i, queue, last_received;
|
||||
|
||||
// discard confirmed frames as appropriate
|
||||
int total_min_confirmed = MAX_INT;
|
||||
for (queue = 0; queue < _num_players; queue++) {
|
||||
bool queue_connected = true;
|
||||
int queue_min_confirmed = MAX_INT;
|
||||
Log("considering queue %d.", queue);
|
||||
for (i = 0; i < _num_players; i++) {
|
||||
// we're going to do a lot of logic here in consideration of endpoint i.
|
||||
// keep accumulating the minimum confirmed point for all n*n packets and
|
||||
// throw away the rest.
|
||||
if (_endpoints[i].IsRunning()) {
|
||||
bool connected = _endpoints[i].GetPeerConnectStatus(queue, &last_received);
|
||||
|
||||
queue_connected = queue_connected && connected;
|
||||
queue_min_confirmed = MIN(last_received, queue_min_confirmed);
|
||||
Log(" endpoint %d: connected = %d, last_received = %d, queue_min_confirmed = %d.", i, connected, last_received, queue_min_confirmed);
|
||||
} else {
|
||||
Log(" endpoint %d: ignoring... not running.", i);
|
||||
}
|
||||
}
|
||||
// merge in our local status only if we're still connected!
|
||||
if (!_local_connect_status[queue].disconnected) {
|
||||
queue_min_confirmed = MIN(_local_connect_status[queue].last_frame, queue_min_confirmed);
|
||||
}
|
||||
Log(" local endp: connected = %d, last_received = %d, queue_min_confirmed = %d.", !_local_connect_status[queue].disconnected, _local_connect_status[queue].last_frame, queue_min_confirmed);
|
||||
|
||||
if (queue_connected) {
|
||||
total_min_confirmed = MIN(queue_min_confirmed, total_min_confirmed);
|
||||
} else {
|
||||
// check to see if this disconnect notification is further back than we've been before. If
|
||||
// so, we need to re-adjust. This can happen when we detect our own disconnect at frame n
|
||||
// and later receive a disconnect notification for frame n-1.
|
||||
if (!_local_connect_status[queue].disconnected || _local_connect_status[queue].last_frame > queue_min_confirmed) {
|
||||
Log("disconnecting queue %d by remote request.", queue);
|
||||
DisconnectPlayerQueue(queue, queue_min_confirmed);
|
||||
}
|
||||
}
|
||||
Log(" total_min_confirmed = %d.", total_min_confirmed);
|
||||
}
|
||||
return total_min_confirmed;
|
||||
}
|
||||
|
||||
|
||||
GGPOErrorCode
|
||||
Peer2PeerBackend::AddPlayer(GGPOPlayer *player,
|
||||
GGPOPlayerHandle *handle)
|
||||
{
|
||||
if (player->type == GGPO_PLAYERTYPE_SPECTATOR) {
|
||||
return AddSpectator(player->u.remote.ip_address, player->u.remote.port);
|
||||
}
|
||||
|
||||
int queue = player->player_num - 1;
|
||||
if (player->player_num < 1 || player->player_num > _num_players) {
|
||||
return GGPO_ERRORCODE_PLAYER_OUT_OF_RANGE;
|
||||
}
|
||||
*handle = QueueToPlayerHandle(queue);
|
||||
|
||||
if (player->type == GGPO_PLAYERTYPE_REMOTE) {
|
||||
AddRemotePlayer(player->u.remote.ip_address, player->u.remote.port, queue);
|
||||
}
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
Peer2PeerBackend::AddLocalInput(GGPOPlayerHandle player,
|
||||
void *values,
|
||||
int size)
|
||||
{
|
||||
int queue;
|
||||
GameInput input;
|
||||
GGPOErrorCode result;
|
||||
|
||||
if (_sync.InRollback()) {
|
||||
return GGPO_ERRORCODE_IN_ROLLBACK;
|
||||
}
|
||||
if (_synchronizing) {
|
||||
return GGPO_ERRORCODE_NOT_SYNCHRONIZED;
|
||||
}
|
||||
|
||||
result = PlayerHandleToQueue(player, &queue);
|
||||
if (!GGPO_SUCCEEDED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
input.init(-1, (char *)values, size);
|
||||
|
||||
// Feed the input for the current frame into the synchronzation layer.
|
||||
if (!_sync.AddLocalInput(queue, input)) {
|
||||
return GGPO_ERRORCODE_PREDICTION_THRESHOLD;
|
||||
}
|
||||
|
||||
if (input.frame != GameInput::NullFrame) { // xxx: <- comment why this is the case
|
||||
// Update the local connect status state to indicate that we've got a
|
||||
// confirmed local frame for this player. this must come first so it
|
||||
// gets incorporated into the next packet we send.
|
||||
|
||||
Log("setting local connect status for local queue %d to %d", queue, input.frame);
|
||||
_local_connect_status[queue].last_frame = input.frame;
|
||||
|
||||
// Send the input to all the remote players.
|
||||
for (int i = 0; i < _num_players; i++) {
|
||||
if (_endpoints[i].IsInitialized()) {
|
||||
_endpoints[i].SendInput(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
|
||||
GGPOErrorCode
|
||||
Peer2PeerBackend::SyncInput(void *values,
|
||||
int size,
|
||||
int *disconnect_flags)
|
||||
{
|
||||
int flags;
|
||||
|
||||
// Wait until we've started to return inputs.
|
||||
if (_synchronizing) {
|
||||
return GGPO_ERRORCODE_NOT_SYNCHRONIZED;
|
||||
}
|
||||
flags = _sync.SynchronizeInputs(values, size);
|
||||
if (disconnect_flags) {
|
||||
*disconnect_flags = flags;
|
||||
}
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
Peer2PeerBackend::IncrementFrame(void)
|
||||
{
|
||||
Log("End of frame (%d)...", _sync.GetFrameCount());
|
||||
_sync.IncrementFrame();
|
||||
DoPoll(0);
|
||||
PollSyncEvents();
|
||||
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Peer2PeerBackend::PollSyncEvents(void)
|
||||
{
|
||||
Sync::Event e;
|
||||
while (_sync.GetEvent(e)) {
|
||||
OnSyncEvent(e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
Peer2PeerBackend::PollUdpProtocolEvents(void)
|
||||
{
|
||||
UdpProtocol::Event evt;
|
||||
for (int i = 0; i < _num_players; i++) {
|
||||
while (_endpoints[i].GetEvent(evt)) {
|
||||
OnUdpProtocolPeerEvent(evt, i);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _num_spectators; i++) {
|
||||
while (_spectators[i].GetEvent(evt)) {
|
||||
OnUdpProtocolSpectatorEvent(evt, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Peer2PeerBackend::OnUdpProtocolPeerEvent(UdpProtocol::Event &evt, int queue)
|
||||
{
|
||||
OnUdpProtocolEvent(evt, QueueToPlayerHandle(queue));
|
||||
switch (evt.type) {
|
||||
case UdpProtocol::Event::Input:
|
||||
if (!_local_connect_status[queue].disconnected) {
|
||||
int current_remote_frame = _local_connect_status[queue].last_frame;
|
||||
int new_remote_frame = evt.u.input.input.frame;
|
||||
ASSERT(current_remote_frame == -1 || new_remote_frame == (current_remote_frame + 1));
|
||||
|
||||
_sync.AddRemoteInput(queue, evt.u.input.input);
|
||||
// Notify the other endpoints which frame we received from a peer
|
||||
Log("setting remote connect status for queue %d to %d", queue, evt.u.input.input.frame);
|
||||
_local_connect_status[queue].last_frame = evt.u.input.input.frame;
|
||||
}
|
||||
break;
|
||||
|
||||
case UdpProtocol::Event::Disconnected:
|
||||
DisconnectPlayer(QueueToPlayerHandle(queue));
|
||||
break;
|
||||
|
||||
case UdpProtocol::Event::AppData:
|
||||
if (evt.u.app_data.spectators)
|
||||
for (int i = 0; i < _num_spectators; i++)
|
||||
if (_spectators[i].IsInitialized())
|
||||
_spectators[i].SendAppData(evt.u.app_data.data, evt.u.app_data.size, true);
|
||||
Log("calling on_message callback with %d bytes", evt.u.app_data.size);
|
||||
if (_callbacks.on_message != nullptr)
|
||||
_callbacks.on_message(evt.u.app_data.data, evt.u.app_data.size);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Peer2PeerBackend::OnUdpProtocolSpectatorEvent(UdpProtocol::Event &evt, int queue)
|
||||
{
|
||||
GGPOPlayerHandle handle = QueueToSpectatorHandle(queue);
|
||||
OnUdpProtocolEvent(evt, handle);
|
||||
|
||||
if (evt.type == UdpProtocol::Event::Disconnected)
|
||||
{
|
||||
_spectators[queue].Disconnect();
|
||||
|
||||
GGPOEvent info;
|
||||
info.code = GGPO_EVENTCODE_DISCONNECTED_FROM_PEER;
|
||||
info.u.disconnected.player = handle;
|
||||
_callbacks.on_event(&info);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Peer2PeerBackend::OnUdpProtocolEvent(UdpProtocol::Event &evt, GGPOPlayerHandle handle)
|
||||
{
|
||||
GGPOEvent info;
|
||||
|
||||
switch (evt.type) {
|
||||
case UdpProtocol::Event::Connected:
|
||||
info.code = GGPO_EVENTCODE_CONNECTED_TO_PEER;
|
||||
info.u.connected.player = handle;
|
||||
_callbacks.on_event(&info);
|
||||
break;
|
||||
case UdpProtocol::Event::Synchronizing:
|
||||
info.code = GGPO_EVENTCODE_SYNCHRONIZING_WITH_PEER;
|
||||
info.u.synchronizing.player = handle;
|
||||
info.u.synchronizing.count = evt.u.synchronizing.count;
|
||||
info.u.synchronizing.total = evt.u.synchronizing.total;
|
||||
_callbacks.on_event(&info);
|
||||
break;
|
||||
case UdpProtocol::Event::Synchronzied:
|
||||
info.code = GGPO_EVENTCODE_SYNCHRONIZED_WITH_PEER;
|
||||
info.u.synchronized.player = handle;
|
||||
_callbacks.on_event(&info);
|
||||
|
||||
CheckInitialSync();
|
||||
break;
|
||||
|
||||
case UdpProtocol::Event::NetworkInterrupted:
|
||||
info.code = GGPO_EVENTCODE_CONNECTION_INTERRUPTED;
|
||||
info.u.connection_interrupted.player = handle;
|
||||
info.u.connection_interrupted.disconnect_timeout = evt.u.network_interrupted.disconnect_timeout;
|
||||
_callbacks.on_event(&info);
|
||||
break;
|
||||
|
||||
case UdpProtocol::Event::NetworkResumed:
|
||||
info.code = GGPO_EVENTCODE_CONNECTION_RESUMED;
|
||||
info.u.connection_resumed.player = handle;
|
||||
_callbacks.on_event(&info);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Called only as the result of a local decision to disconnect. The remote
|
||||
* decisions to disconnect are a result of us parsing the peer_connect_settings
|
||||
* blob in every endpoint periodically.
|
||||
*/
|
||||
GGPOErrorCode
|
||||
Peer2PeerBackend::DisconnectPlayer(GGPOPlayerHandle player)
|
||||
{
|
||||
int queue;
|
||||
GGPOErrorCode result;
|
||||
|
||||
result = PlayerHandleToQueue(player, &queue);
|
||||
if (!GGPO_SUCCEEDED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
if (_local_connect_status[queue].disconnected) {
|
||||
return GGPO_ERRORCODE_PLAYER_DISCONNECTED;
|
||||
}
|
||||
|
||||
if (!_endpoints[queue].IsInitialized()) {
|
||||
int current_frame = _sync.GetFrameCount();
|
||||
// xxx: we should be tracking who the local player is, but for now assume
|
||||
// that if the endpoint is not initalized, this must be the local player.
|
||||
Log("Disconnecting local player %d at frame %d by user request.", queue, _local_connect_status[queue].last_frame);
|
||||
for (int i = 0; i < _num_players; i++) {
|
||||
if (_endpoints[i].IsInitialized()) {
|
||||
DisconnectPlayerQueue(i, current_frame);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Log("Disconnecting queue %d at frame %d by user request.", queue, _local_connect_status[queue].last_frame);
|
||||
DisconnectPlayerQueue(queue, _local_connect_status[queue].last_frame);
|
||||
}
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
void
|
||||
Peer2PeerBackend::DisconnectPlayerQueue(int queue, int syncto)
|
||||
{
|
||||
GGPOEvent info;
|
||||
int framecount = _sync.GetFrameCount();
|
||||
|
||||
_endpoints[queue].Disconnect();
|
||||
|
||||
Log("Changing queue %d local connect status for last frame from %d to %d on disconnect request (current: %d).",
|
||||
queue, _local_connect_status[queue].last_frame, syncto, framecount);
|
||||
|
||||
_local_connect_status[queue].disconnected = 1;
|
||||
_local_connect_status[queue].last_frame = syncto;
|
||||
|
||||
if (syncto != GameInput::NullFrame && syncto < framecount) {
|
||||
Log("adjusting simulation to account for the fact that %d disconnected @ %d.", queue, syncto);
|
||||
_sync.AdjustSimulation(syncto);
|
||||
Log("finished adjusting simulation.");
|
||||
}
|
||||
|
||||
info.code = GGPO_EVENTCODE_DISCONNECTED_FROM_PEER;
|
||||
info.u.disconnected.player = QueueToPlayerHandle(queue);
|
||||
_callbacks.on_event(&info);
|
||||
|
||||
CheckInitialSync();
|
||||
}
|
||||
|
||||
|
||||
GGPOErrorCode
|
||||
Peer2PeerBackend::GetNetworkStats(GGPONetworkStats *stats, GGPOPlayerHandle player)
|
||||
{
|
||||
int queue;
|
||||
GGPOErrorCode result;
|
||||
|
||||
result = PlayerHandleToQueue(player, &queue);
|
||||
if (!GGPO_SUCCEEDED(result)) {
|
||||
return result;
|
||||
}
|
||||
|
||||
memset(stats, 0, sizeof *stats);
|
||||
_endpoints[queue].GetNetworkStats(stats);
|
||||
stats->sync.predicted_frames = _sync.GetPredictedFrames();
|
||||
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
Peer2PeerBackend::SetFrameDelay(GGPOPlayerHandle player, int delay)
|
||||
{
|
||||
int queue;
|
||||
GGPOErrorCode result;
|
||||
|
||||
result = PlayerHandleToQueue(player, &queue);
|
||||
if (!GGPO_SUCCEEDED(result)) {
|
||||
return result;
|
||||
}
|
||||
_sync.SetFrameDelay(queue, delay);
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
Peer2PeerBackend::SetDisconnectTimeout(int timeout)
|
||||
{
|
||||
_disconnect_timeout = timeout;
|
||||
for (int i = 0; i < _num_players; i++) {
|
||||
if (_endpoints[i].IsInitialized()) {
|
||||
_endpoints[i].SetDisconnectTimeout(_disconnect_timeout);
|
||||
}
|
||||
}
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
Peer2PeerBackend::SetDisconnectNotifyStart(int timeout)
|
||||
{
|
||||
_disconnect_notify_start = timeout;
|
||||
for (int i = 0; i < _num_players; i++) {
|
||||
if (_endpoints[i].IsInitialized()) {
|
||||
_endpoints[i].SetDisconnectNotifyStart(_disconnect_notify_start);
|
||||
}
|
||||
}
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
Peer2PeerBackend::PlayerHandleToQueue(GGPOPlayerHandle player, int *queue)
|
||||
{
|
||||
int offset = ((int)player - 1);
|
||||
if (offset < 0 || offset >= _num_players) {
|
||||
return GGPO_ERRORCODE_INVALID_PLAYER_HANDLE;
|
||||
}
|
||||
*queue = offset;
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Peer2PeerBackend::OnMsg(sockaddr_in &from, UdpMsg *msg, int len)
|
||||
{
|
||||
for (int i = 0; i < _num_players; i++) {
|
||||
if (_endpoints[i].HandlesMsg(from, msg)) {
|
||||
_endpoints[i].OnMsg(msg, len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < _num_spectators; i++) {
|
||||
if (_spectators[i].HandlesMsg(from, msg)) {
|
||||
_spectators[i].OnMsg(msg, len);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Peer2PeerBackend::CheckInitialSync()
|
||||
{
|
||||
int i;
|
||||
|
||||
if (_synchronizing) {
|
||||
// Check to see if everyone is now synchronized. If so,
|
||||
// go ahead and tell the client that we're ok to accept input.
|
||||
for (i = 0; i < _num_players; i++) {
|
||||
// xxx: IsInitialized() must go... we're actually using it as a proxy for "represents the local player"
|
||||
if (_endpoints[i].IsInitialized() && !_endpoints[i].IsSynchronized() && !_local_connect_status[i].disconnected) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
for (i = 0; i < _num_spectators; i++) {
|
||||
if (_spectators[i].IsInitialized() && !_spectators[i].IsSynchronized()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOEvent info;
|
||||
info.code = GGPO_EVENTCODE_RUNNING;
|
||||
_callbacks.on_event(&info);
|
||||
_synchronizing = false;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode Peer2PeerBackend::SendMessage(const void *msg, int len, bool spectators)
|
||||
{
|
||||
if (_synchronizing)
|
||||
return GGPO_ERRORCODE_NOT_SYNCHRONIZED;
|
||||
if (len > MAX_APPDATA_SIZE)
|
||||
return GGPO_ERRORCODE_INVALID_REQUEST;
|
||||
for (int i = 0; i < _num_players; i++)
|
||||
if (_endpoints[i].IsInitialized())
|
||||
_endpoints[i].SendAppData(msg, len, spectators);
|
||||
if (spectators)
|
||||
for (int i = 0; i < _num_spectators; i++)
|
||||
if (_spectators[i].IsInitialized())
|
||||
_spectators[i].SendAppData(msg, len, spectators);
|
||||
|
||||
return GGPO_ERRORCODE_SUCCESS;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _P2P_H
|
||||
#define _P2P_H
|
||||
|
||||
#include "ggpo_types.h"
|
||||
#include "ggpo_poll.h"
|
||||
#include "sync.h"
|
||||
#include "backend.h"
|
||||
#include "timesync.h"
|
||||
#include "network/udp_proto.h"
|
||||
|
||||
class Peer2PeerBackend : public IQuarkBackend, IPollSink, Udp::Callbacks {
|
||||
public:
|
||||
Peer2PeerBackend(GGPOSessionCallbacks *cb, const char *gamename, uint16 localport, int num_players, int input_size,
|
||||
const void *verification, int verification_size);
|
||||
virtual ~Peer2PeerBackend();
|
||||
|
||||
|
||||
public:
|
||||
GGPOErrorCode DoPoll(int timeout) override;
|
||||
GGPOErrorCode AddPlayer(GGPOPlayer *player, GGPOPlayerHandle *handle) override;
|
||||
GGPOErrorCode AddLocalInput(GGPOPlayerHandle player, void *values, int size) override;
|
||||
GGPOErrorCode SyncInput(void *values, int size, int *disconnect_flags) override;
|
||||
GGPOErrorCode IncrementFrame(void) override;
|
||||
GGPOErrorCode DisconnectPlayer(GGPOPlayerHandle handle) override;
|
||||
GGPOErrorCode GetNetworkStats(GGPONetworkStats *stats, GGPOPlayerHandle handle) override;
|
||||
GGPOErrorCode SetFrameDelay(GGPOPlayerHandle player, int delay) override;
|
||||
GGPOErrorCode SetDisconnectTimeout(int timeout) override;
|
||||
GGPOErrorCode SetDisconnectNotifyStart(int timeout) override;
|
||||
GGPOErrorCode SendMessage(const void *msg, int len, bool spectators) override;
|
||||
|
||||
public:
|
||||
void OnMsg(sockaddr_in &from, UdpMsg *msg, int len) override;
|
||||
|
||||
protected:
|
||||
GGPOErrorCode PlayerHandleToQueue(GGPOPlayerHandle player, int *queue);
|
||||
GGPOPlayerHandle QueueToPlayerHandle(int queue) { return (GGPOPlayerHandle)(queue + 1); }
|
||||
GGPOPlayerHandle QueueToSpectatorHandle(int queue) { return (GGPOPlayerHandle)(queue + 1000); } /* out of range of the player array, basically */
|
||||
void DisconnectPlayerQueue(int queue, int syncto);
|
||||
void PollSyncEvents(void);
|
||||
void PollUdpProtocolEvents(void);
|
||||
void CheckInitialSync(void);
|
||||
int Poll2Players(int current_frame);
|
||||
int PollNPlayers(int current_frame);
|
||||
void AddRemotePlayer(char *remoteip, uint16 reportport, int queue);
|
||||
GGPOErrorCode AddSpectator(char *remoteip, uint16 reportport);
|
||||
virtual void OnSyncEvent(Sync::Event &e) { }
|
||||
virtual void OnUdpProtocolEvent(UdpProtocol::Event &e, GGPOPlayerHandle handle);
|
||||
virtual void OnUdpProtocolPeerEvent(UdpProtocol::Event &e, int queue);
|
||||
virtual void OnUdpProtocolSpectatorEvent(UdpProtocol::Event &e, int queue);
|
||||
|
||||
protected:
|
||||
GGPOSessionCallbacks _callbacks;
|
||||
Poll _poll;
|
||||
Sync _sync;
|
||||
Udp _udp;
|
||||
UdpProtocol *_endpoints;
|
||||
UdpProtocol _spectators[GGPO_MAX_SPECTATORS];
|
||||
int _num_spectators;
|
||||
int _input_size;
|
||||
|
||||
bool _synchronizing;
|
||||
int _num_players;
|
||||
int _next_recommended_sleep;
|
||||
|
||||
int _next_spectator_frame;
|
||||
int _disconnect_timeout;
|
||||
int _disconnect_notify_start;
|
||||
|
||||
UdpMsg::connect_status _local_connect_status[UDP_MSG_MAX_PLAYERS];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,189 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "spectator.h"
|
||||
|
||||
SpectatorBackend::SpectatorBackend(GGPOSessionCallbacks *cb,
|
||||
const char* gamename,
|
||||
uint16 localport,
|
||||
int num_players,
|
||||
int input_size,
|
||||
char *hostip,
|
||||
u_short hostport,
|
||||
const void *verification,
|
||||
int verification_size) :
|
||||
_input_size(input_size),
|
||||
_num_players(num_players),
|
||||
_next_input_to_send(0)
|
||||
{
|
||||
_callbacks = *cb;
|
||||
_synchronizing = true;
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(_inputs); i++) {
|
||||
_inputs[i].frame = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize the UDP port
|
||||
*/
|
||||
_udp.Init(localport, &_poll, this);
|
||||
|
||||
/*
|
||||
* Init the host endpoint
|
||||
*/
|
||||
_host.SetVerificationData(verification, verification_size);
|
||||
_host.Init(&_udp, _poll, 0, hostip, hostport, NULL);
|
||||
_host.Synchronize();
|
||||
|
||||
/*
|
||||
* Preload the ROM
|
||||
*/
|
||||
_callbacks.begin_game(gamename);
|
||||
}
|
||||
|
||||
SpectatorBackend::~SpectatorBackend()
|
||||
{
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
SpectatorBackend::DoPoll(int timeout)
|
||||
{
|
||||
_poll.Pump(0);
|
||||
|
||||
PollUdpProtocolEvents();
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
SpectatorBackend::SyncInput(void *values,
|
||||
int size,
|
||||
int *disconnect_flags)
|
||||
{
|
||||
// Wait until we've started to return inputs.
|
||||
if (_synchronizing) {
|
||||
return GGPO_ERRORCODE_NOT_SYNCHRONIZED;
|
||||
}
|
||||
|
||||
GameInput &input = _inputs[_next_input_to_send % SPECTATOR_FRAME_BUFFER_SIZE];
|
||||
if (input.frame < _next_input_to_send) {
|
||||
// Haven't received the input from the host yet. Wait
|
||||
return GGPO_ERRORCODE_PREDICTION_THRESHOLD;
|
||||
}
|
||||
if (input.frame > _next_input_to_send) {
|
||||
// The host is way way way far ahead of the spectator. How'd this
|
||||
// happen? Anyway, the input we need is gone forever.
|
||||
return GGPO_ERRORCODE_GENERAL_FAILURE;
|
||||
}
|
||||
|
||||
ASSERT(size >= _input_size * _num_players);
|
||||
memcpy(values, input.bits, _input_size * _num_players);
|
||||
if (disconnect_flags) {
|
||||
*disconnect_flags = 0; // xxx: should get them from the host!
|
||||
}
|
||||
_next_input_to_send++;
|
||||
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
SpectatorBackend::IncrementFrame(void)
|
||||
{
|
||||
Log("End of frame (%d)...", _next_input_to_send - 1);
|
||||
DoPoll(0);
|
||||
PollUdpProtocolEvents();
|
||||
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
void
|
||||
SpectatorBackend::PollUdpProtocolEvents(void)
|
||||
{
|
||||
UdpProtocol::Event evt;
|
||||
while (_host.GetEvent(evt)) {
|
||||
OnUdpProtocolEvent(evt);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SpectatorBackend::OnUdpProtocolEvent(UdpProtocol::Event &evt)
|
||||
{
|
||||
GGPOEvent info;
|
||||
|
||||
switch (evt.type) {
|
||||
case UdpProtocol::Event::Connected:
|
||||
info.code = GGPO_EVENTCODE_CONNECTED_TO_PEER;
|
||||
info.u.connected.player = 0;
|
||||
_callbacks.on_event(&info);
|
||||
break;
|
||||
case UdpProtocol::Event::Synchronizing:
|
||||
info.code = GGPO_EVENTCODE_SYNCHRONIZING_WITH_PEER;
|
||||
info.u.synchronizing.player = 0;
|
||||
info.u.synchronizing.count = evt.u.synchronizing.count;
|
||||
info.u.synchronizing.total = evt.u.synchronizing.total;
|
||||
_callbacks.on_event(&info);
|
||||
break;
|
||||
case UdpProtocol::Event::Synchronzied:
|
||||
if (_synchronizing) {
|
||||
info.code = GGPO_EVENTCODE_SYNCHRONIZED_WITH_PEER;
|
||||
info.u.synchronized.player = 0;
|
||||
_callbacks.on_event(&info);
|
||||
|
||||
info.code = GGPO_EVENTCODE_RUNNING;
|
||||
_callbacks.on_event(&info);
|
||||
_synchronizing = false;
|
||||
}
|
||||
break;
|
||||
|
||||
case UdpProtocol::Event::NetworkInterrupted:
|
||||
info.code = GGPO_EVENTCODE_CONNECTION_INTERRUPTED;
|
||||
info.u.connection_interrupted.player = 0;
|
||||
info.u.connection_interrupted.disconnect_timeout = evt.u.network_interrupted.disconnect_timeout;
|
||||
_callbacks.on_event(&info);
|
||||
break;
|
||||
|
||||
case UdpProtocol::Event::NetworkResumed:
|
||||
info.code = GGPO_EVENTCODE_CONNECTION_RESUMED;
|
||||
info.u.connection_resumed.player = 0;
|
||||
_callbacks.on_event(&info);
|
||||
break;
|
||||
|
||||
case UdpProtocol::Event::Disconnected:
|
||||
info.code = GGPO_EVENTCODE_DISCONNECTED_FROM_PEER;
|
||||
info.u.disconnected.player = 0;
|
||||
_callbacks.on_event(&info);
|
||||
break;
|
||||
|
||||
case UdpProtocol::Event::Input:
|
||||
{
|
||||
GameInput& input = evt.u.input.input;
|
||||
|
||||
_host.SetLocalFrameNumber(input.frame);
|
||||
_host.SendInputAck();
|
||||
_inputs[input.frame % SPECTATOR_FRAME_BUFFER_SIZE] = input;
|
||||
}
|
||||
break;
|
||||
|
||||
case UdpProtocol::Event::AppData:
|
||||
Log("calling on_message callback with %d bytes", evt.u.app_data.size);
|
||||
if (_callbacks.on_message != nullptr)
|
||||
_callbacks.on_message(evt.u.app_data.data, evt.u.app_data.size);
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
SpectatorBackend::OnMsg(sockaddr_in &from, UdpMsg *msg, int len)
|
||||
{
|
||||
if (_host.HandlesMsg(from, msg)) {
|
||||
_host.OnMsg(msg, len);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _SPECTATOR_H
|
||||
#define _SPECTATOR_H
|
||||
|
||||
#include "../ggpo_poll.h"
|
||||
#include "../ggpo_types.h"
|
||||
#include "sync.h"
|
||||
#include "backend.h"
|
||||
#include "timesync.h"
|
||||
#include "network/udp_proto.h"
|
||||
|
||||
#define SPECTATOR_FRAME_BUFFER_SIZE 64
|
||||
|
||||
class SpectatorBackend : public IQuarkBackend, IPollSink, Udp::Callbacks {
|
||||
public:
|
||||
SpectatorBackend(GGPOSessionCallbacks *cb, const char *gamename, uint16 localport, int num_players, int input_size, char *hostip, u_short hostport,
|
||||
const void *verification, int verification_size);
|
||||
virtual ~SpectatorBackend();
|
||||
|
||||
|
||||
public:
|
||||
GGPOErrorCode DoPoll(int timeout) override;
|
||||
GGPOErrorCode AddPlayer(GGPOPlayer *player, GGPOPlayerHandle *handle) override { return GGPO_ERRORCODE_UNSUPPORTED; }
|
||||
GGPOErrorCode AddLocalInput(GGPOPlayerHandle player, void *values, int size) override { return GGPO_OK; }
|
||||
GGPOErrorCode SyncInput(void *values, int size, int *disconnect_flags) override;
|
||||
GGPOErrorCode IncrementFrame(void) override;
|
||||
GGPOErrorCode DisconnectPlayer(GGPOPlayerHandle handle) override { return GGPO_ERRORCODE_UNSUPPORTED; }
|
||||
GGPOErrorCode GetNetworkStats(GGPONetworkStats *stats, GGPOPlayerHandle handle) override { return GGPO_ERRORCODE_UNSUPPORTED; }
|
||||
GGPOErrorCode SetFrameDelay(GGPOPlayerHandle player, int delay) override { return GGPO_ERRORCODE_UNSUPPORTED; }
|
||||
GGPOErrorCode SetDisconnectTimeout(int timeout) override { return GGPO_ERRORCODE_UNSUPPORTED; }
|
||||
GGPOErrorCode SetDisconnectNotifyStart(int timeout) override { return GGPO_ERRORCODE_UNSUPPORTED; }
|
||||
|
||||
public:
|
||||
void OnMsg(sockaddr_in &from, UdpMsg *msg, int len) override;
|
||||
|
||||
protected:
|
||||
void PollUdpProtocolEvents(void);
|
||||
void CheckInitialSync(void);
|
||||
|
||||
void OnUdpProtocolEvent(UdpProtocol::Event &e);
|
||||
|
||||
protected:
|
||||
GGPOSessionCallbacks _callbacks;
|
||||
Poll _poll;
|
||||
Udp _udp;
|
||||
UdpProtocol _host;
|
||||
bool _synchronizing;
|
||||
int _input_size;
|
||||
int _num_players;
|
||||
int _next_input_to_send;
|
||||
GameInput _inputs[SPECTATOR_FRAME_BUFFER_SIZE];
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,184 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "synctest.h"
|
||||
|
||||
SyncTestBackend::SyncTestBackend(GGPOSessionCallbacks *cb,
|
||||
const char *gamename,
|
||||
int frames,
|
||||
int num_players) :
|
||||
_sync(NULL)
|
||||
{
|
||||
_callbacks = *cb;
|
||||
_num_players = num_players;
|
||||
_check_distance = frames;
|
||||
_last_verified = 0;
|
||||
_rollingback = false;
|
||||
_running = false;
|
||||
_logfp = NULL;
|
||||
_current_input.erase();
|
||||
strcpy(_game, gamename);
|
||||
|
||||
/*
|
||||
* Initialize the synchronziation layer
|
||||
*/
|
||||
Sync::Config config = { 0 };
|
||||
config.callbacks = _callbacks;
|
||||
config.num_prediction_frames = MAX_PREDICTION_FRAMES;
|
||||
_sync.Init(config);
|
||||
|
||||
/*
|
||||
* Preload the ROM
|
||||
*/
|
||||
_callbacks.begin_game(gamename);
|
||||
}
|
||||
|
||||
SyncTestBackend::~SyncTestBackend()
|
||||
{
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
SyncTestBackend::DoPoll(int timeout)
|
||||
{
|
||||
if (!_running) {
|
||||
GGPOEvent info;
|
||||
|
||||
info.code = GGPO_EVENTCODE_RUNNING;
|
||||
_callbacks.on_event(&info);
|
||||
_running = true;
|
||||
}
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
SyncTestBackend::AddPlayer(GGPOPlayer *player, GGPOPlayerHandle *handle)
|
||||
{
|
||||
if (player->player_num < 1 || player->player_num > _num_players) {
|
||||
return GGPO_ERRORCODE_PLAYER_OUT_OF_RANGE;
|
||||
}
|
||||
*handle = (GGPOPlayerHandle)(player->player_num - 1);
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
SyncTestBackend::AddLocalInput(GGPOPlayerHandle player, void *values, int size)
|
||||
{
|
||||
if (!_running) {
|
||||
return GGPO_ERRORCODE_NOT_SYNCHRONIZED;
|
||||
}
|
||||
|
||||
int index = (int)player;
|
||||
for (int i = 0; i < size; i++) {
|
||||
_current_input.bits[(index * size) + i] |= ((char *)values)[i];
|
||||
}
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
SyncTestBackend::SyncInput(void *values,
|
||||
int size,
|
||||
int *disconnect_flags)
|
||||
{
|
||||
if (_rollingback) {
|
||||
_last_input = _saved_frames.front().input;
|
||||
} else {
|
||||
if (_sync.GetFrameCount() == 0 && _sync.GetLastSavedFrame().buf == nullptr) {
|
||||
_sync.SaveCurrentFrame();
|
||||
}
|
||||
_last_input = _current_input;
|
||||
}
|
||||
memcpy(values, _last_input.bits, size);
|
||||
if (disconnect_flags) {
|
||||
*disconnect_flags = 0;
|
||||
}
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
SyncTestBackend::IncrementFrame(void)
|
||||
{
|
||||
_sync.IncrementFrame();
|
||||
_current_input.erase();
|
||||
|
||||
DEBUG_LOG(NETWORK, "End of frame(%d)...", _sync.GetFrameCount());
|
||||
|
||||
if (_rollingback) {
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
int frame = _sync.GetFrameCount();
|
||||
// Hold onto the current frame in our queue of saved states. We'll need
|
||||
// the checksum later to verify that our replay of the same frame got the
|
||||
// same results.
|
||||
SavedInfo info;
|
||||
info.frame = frame;
|
||||
info.input = _last_input;
|
||||
info.cbuf = _sync.GetLastSavedFrame().cbuf;
|
||||
info.buf = (char *)malloc(info.cbuf);
|
||||
memcpy(info.buf, _sync.GetLastSavedFrame().buf, info.cbuf);
|
||||
info.checksum = _sync.GetLastSavedFrame().checksum;
|
||||
_saved_frames.push(info);
|
||||
|
||||
if (frame - _last_verified == _check_distance) {
|
||||
// We've gone far enough ahead and should now start replaying frames.
|
||||
// Load the last verified frame and set the rollback flag to true.
|
||||
_sync.LoadFrame(_last_verified);
|
||||
|
||||
_rollingback = true;
|
||||
while(!_saved_frames.empty()) {
|
||||
_callbacks.advance_frame(0);
|
||||
|
||||
// Verify that the checksumn of this frame is the same as the one in our
|
||||
// list.
|
||||
info = _saved_frames.front();
|
||||
_saved_frames.pop();
|
||||
|
||||
if (info.frame != _sync.GetFrameCount()) {
|
||||
RaiseSyncError("Frame number %d does not match saved frame number %d", info.frame, frame);
|
||||
}
|
||||
int checksum = _sync.GetLastSavedFrame().checksum;
|
||||
if (info.checksum != checksum) {
|
||||
LogSaveStates(info);
|
||||
RaiseSyncError("Checksum for frame %d does not match saved (%d != %d)", frame, checksum, info.checksum);
|
||||
}
|
||||
else
|
||||
printf("Checksum %08d for frame %d matches.\n", checksum, info.frame);
|
||||
free(info.buf);
|
||||
}
|
||||
_last_verified = frame;
|
||||
_rollingback = false;
|
||||
}
|
||||
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
void
|
||||
SyncTestBackend::RaiseSyncError(const char *fmt, ...)
|
||||
{
|
||||
char buf[1024];
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
vsnprintf(buf, ARRAY_SIZE(buf), fmt, args);
|
||||
va_end(args);
|
||||
|
||||
puts(buf);
|
||||
#ifdef _WIN32
|
||||
OutputDebugStringA(buf);
|
||||
#endif
|
||||
// DebugBreak();
|
||||
}
|
||||
|
||||
void
|
||||
SyncTestBackend::LogSaveStates(SavedInfo &info)
|
||||
{
|
||||
char filename[MAX_PATH];
|
||||
snprintf(filename, ARRAY_SIZE(filename), "synclogs/state-%04d-original.log", _sync.GetFrameCount());
|
||||
_callbacks.log_game_state(filename, (unsigned char *)info.buf, info.cbuf);
|
||||
|
||||
snprintf(filename, ARRAY_SIZE(filename), "synclogs/state-%04d-replay.log", _sync.GetFrameCount());
|
||||
_callbacks.log_game_state(filename, _sync.GetLastSavedFrame().buf, _sync.GetLastSavedFrame().cbuf);
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _SYNCTEST_H
|
||||
#define _SYNCTEST_H
|
||||
|
||||
#include "ggpo_types.h"
|
||||
#include "backend.h"
|
||||
#include "sync.h"
|
||||
|
||||
#include "ring_buffer.h"
|
||||
|
||||
class SyncTestBackend : public IQuarkBackend {
|
||||
public:
|
||||
SyncTestBackend(GGPOSessionCallbacks *cb, const char *gamename, int frames, int num_players);
|
||||
virtual ~SyncTestBackend();
|
||||
|
||||
virtual GGPOErrorCode DoPoll(int timeout);
|
||||
virtual GGPOErrorCode AddPlayer(GGPOPlayer *player, GGPOPlayerHandle *handle);
|
||||
virtual GGPOErrorCode AddLocalInput(GGPOPlayerHandle player, void *values, int size);
|
||||
virtual GGPOErrorCode SyncInput(void *values, int size, int *disconnect_flags);
|
||||
virtual GGPOErrorCode IncrementFrame(void);
|
||||
|
||||
protected:
|
||||
struct SavedInfo {
|
||||
int frame;
|
||||
int checksum;
|
||||
char *buf;
|
||||
int cbuf;
|
||||
GameInput input;
|
||||
};
|
||||
|
||||
void RaiseSyncError(const char *fmt, ...);
|
||||
void LogSaveStates(SavedInfo &info);
|
||||
|
||||
protected:
|
||||
GGPOSessionCallbacks _callbacks;
|
||||
Sync _sync;
|
||||
int _num_players;
|
||||
int _check_distance;
|
||||
int _last_verified;
|
||||
bool _rollingback;
|
||||
bool _running;
|
||||
FILE *_logfp;
|
||||
char _game[128];
|
||||
|
||||
GameInput _current_input;
|
||||
GameInput _last_input;
|
||||
RingBuffer<SavedInfo, 32> _saved_frames;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,55 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "ggpo_types.h"
|
||||
#include "bitvector.h"
|
||||
|
||||
void
|
||||
BitVector_SetBit(uint8 *vector, int *offset)
|
||||
{
|
||||
vector[(*offset) / 8] |= (1 << ((*offset) % 8));
|
||||
*offset += 1;
|
||||
}
|
||||
|
||||
void
|
||||
BitVector_ClearBit(uint8 *vector, int *offset)
|
||||
{
|
||||
vector[(*offset) / 8] &= ~(1 << ((*offset) % 8));
|
||||
*offset += 1;
|
||||
}
|
||||
|
||||
void
|
||||
BitVector_WriteNibblet(uint8 *vector, int nibble, int *offset)
|
||||
{
|
||||
ASSERT(nibble < (1 << BITVECTOR_NIBBLE_SIZE));
|
||||
for (int i = 0; i < BITVECTOR_NIBBLE_SIZE; i++) {
|
||||
if (nibble & (1 << i)) {
|
||||
BitVector_SetBit(vector, offset);
|
||||
} else {
|
||||
BitVector_ClearBit(vector, offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
BitVector_ReadBit(uint8 *vector, int *offset)
|
||||
{
|
||||
int retval = !!(vector[(*offset) / 8] & (1 << ((*offset) % 8)));
|
||||
*offset += 1;
|
||||
return retval;
|
||||
}
|
||||
|
||||
int
|
||||
BitVector_ReadNibblet(uint8 *vector, int *offset)
|
||||
{
|
||||
int nibblet = 0;
|
||||
for (int i = 0; i < BITVECTOR_NIBBLE_SIZE; i++) {
|
||||
nibblet |= (BitVector_ReadBit(vector, offset) << i);
|
||||
}
|
||||
return nibblet;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _BITVECTOR_H
|
||||
#define _BITVECTOR_H
|
||||
|
||||
#define BITVECTOR_NIBBLE_SIZE 8
|
||||
|
||||
void BitVector_SetBit(uint8 *vector, int *offset);
|
||||
void BitVector_ClearBit(uint8 *vector, int *offset);
|
||||
void BitVector_WriteNibblet(uint8 *vector, int nibble, int *offset);
|
||||
int BitVector_ReadBit(uint8 *vector, int *offset);
|
||||
int BitVector_ReadNibblet(uint8 *vector, int *offset);
|
||||
|
||||
#endif // _BITVECTOR_H
|
||||
@@ -0,0 +1,86 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "game_input.h"
|
||||
|
||||
#include "ggpo_types.h"
|
||||
|
||||
void
|
||||
GameInput::init(int iframe, char *ibits, int isize, int offset)
|
||||
{
|
||||
ASSERT(isize);
|
||||
ASSERT(isize <= GAMEINPUT_MAX_BYTES);
|
||||
frame = iframe;
|
||||
size = isize;
|
||||
memset(bits, 0, sizeof(bits));
|
||||
if (ibits) {
|
||||
memcpy(bits + (offset * isize), ibits, isize);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GameInput::init(int iframe, char *ibits, int isize)
|
||||
{
|
||||
ASSERT(isize);
|
||||
ASSERT(isize <= GAMEINPUT_MAX_BYTES * GAMEINPUT_MAX_PLAYERS);
|
||||
frame = iframe;
|
||||
size = isize;
|
||||
memset(bits, 0, sizeof(bits));
|
||||
if (ibits) {
|
||||
memcpy(bits, ibits, isize);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GameInput::desc(char *buf, size_t buf_size, bool show_frame) const
|
||||
{
|
||||
ASSERT(size);
|
||||
size_t remaining = buf_size;
|
||||
if (show_frame) {
|
||||
remaining -= snprintf(buf, buf_size, "(frame:%d size:%d ", frame, size);
|
||||
} else {
|
||||
remaining -= snprintf(buf, buf_size, "(size:%d ", size);
|
||||
}
|
||||
|
||||
for (int i = 0; i < size * 8; i++) {
|
||||
char buf2[16];
|
||||
if (value(i)) {
|
||||
int c = snprintf(buf2, ARRAY_SIZE(buf2), "%2d ", i);
|
||||
strncat(buf, buf2, ARRAY_SIZE(buf2));
|
||||
remaining -= c;
|
||||
}
|
||||
}
|
||||
strcat(buf, ")");
|
||||
}
|
||||
|
||||
void
|
||||
GameInput::log(char *prefix, bool show_frame) const
|
||||
{
|
||||
char buf[1024];
|
||||
size_t c = strlen(prefix);
|
||||
strcpy(buf, prefix);
|
||||
desc(buf + c, ARRAY_SIZE(buf) - c, show_frame);
|
||||
Log("%s", buf);
|
||||
}
|
||||
|
||||
bool
|
||||
GameInput::equal(GameInput &other, bool bitsonly)
|
||||
{
|
||||
if (!bitsonly && frame != other.frame) {
|
||||
Log("frames don't match: %d, %d", frame, other.frame);
|
||||
}
|
||||
if (size != other.size) {
|
||||
Log("sizes don't match: %d, %d", size, other.size);
|
||||
}
|
||||
bool match = memcmp(bits, other.bits, size) == 0;
|
||||
if (!match)
|
||||
Log("bits don't match");
|
||||
ASSERT(size && other.size);
|
||||
return (bitsonly || frame == other.frame) &&
|
||||
size == other.size && match;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _GAMEINPUT_H
|
||||
#define _GAMEINPUT_H
|
||||
|
||||
#include <stdio.h>
|
||||
#include <memory.h>
|
||||
|
||||
// GAMEINPUT_MAX_BYTES * GAMEINPUT_MAX_PLAYERS * 8 must be less than
|
||||
// 2^BITVECTOR_NIBBLE_SIZE (see bitvector.h)
|
||||
|
||||
#define GAMEINPUT_MAX_BYTES 9
|
||||
#define GAMEINPUT_MAX_PLAYERS 2
|
||||
|
||||
struct GameInput {
|
||||
enum Constants {
|
||||
NullFrame = -1
|
||||
};
|
||||
int frame;
|
||||
int size; /* size in bytes of the entire input for all players */
|
||||
char bits[GAMEINPUT_MAX_BYTES * GAMEINPUT_MAX_PLAYERS];
|
||||
|
||||
bool is_null() { return frame == NullFrame; }
|
||||
void init(int frame, char *bits, int size, int offset);
|
||||
void init(int frame, char *bits, int size);
|
||||
bool value(int i) const { return (bits[i/8] & (1 << (i%8))) != 0; }
|
||||
void set(int i) { bits[i/8] |= (1 << (i%8)); }
|
||||
void clear(int i) { bits[i/8] &= ~(1 << (i%8)); }
|
||||
void erase() { memset(bits, 0, sizeof(bits)); }
|
||||
void desc(char *buf, size_t buf_size, bool show_frame = true) const;
|
||||
void log(char *prefix, bool show_frame = true) const;
|
||||
bool equal(GameInput &input, bool bitsonly = false);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,66 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _POLL_H
|
||||
#define _POLL_H
|
||||
|
||||
#include "static_buffer.h"
|
||||
|
||||
#define MAX_POLLABLE_HANDLES 64
|
||||
|
||||
|
||||
class IPollSink {
|
||||
public:
|
||||
virtual ~IPollSink() { }
|
||||
virtual bool OnHandlePoll(void *) { return true; }
|
||||
virtual bool OnMsgPoll(void *) { return true; }
|
||||
virtual bool OnPeriodicPoll(void *, int ) { return true; }
|
||||
virtual bool OnLoopPoll(void *) { return true; }
|
||||
};
|
||||
|
||||
class Poll {
|
||||
public:
|
||||
Poll(void);
|
||||
// void RegisterHandle(IPollSink *sink, HANDLE h, void *cookie = NULL);
|
||||
void RegisterMsgLoop(IPollSink *sink, void *cookie = NULL);
|
||||
void RegisterPeriodic(IPollSink *sink, int interval, void *cookie = NULL);
|
||||
void RegisterLoop(IPollSink *sink, void *cookie = NULL);
|
||||
|
||||
void Run();
|
||||
bool Pump(int timeout);
|
||||
|
||||
protected:
|
||||
int ComputeWaitTime(int elapsed);
|
||||
|
||||
struct PollSinkCb {
|
||||
IPollSink *sink;
|
||||
void *cookie;
|
||||
PollSinkCb() : sink(NULL), cookie(NULL) { }
|
||||
PollSinkCb(IPollSink *s, void *c) : sink(s), cookie(c) { }
|
||||
};
|
||||
|
||||
struct PollPeriodicSinkCb : public PollSinkCb {
|
||||
int interval;
|
||||
int last_fired;
|
||||
PollPeriodicSinkCb() : PollSinkCb(NULL, NULL), interval(0), last_fired(0) { }
|
||||
PollPeriodicSinkCb(IPollSink *s, void *c, int i) :
|
||||
PollSinkCb(s, c), interval(i), last_fired(0) { }
|
||||
};
|
||||
|
||||
int _start_time;
|
||||
int _handle_count;
|
||||
#ifdef _WIN32
|
||||
HANDLE _handles[MAX_POLLABLE_HANDLES];
|
||||
#endif
|
||||
PollSinkCb _handle_sinks[MAX_POLLABLE_HANDLES];
|
||||
|
||||
StaticBuffer<PollSinkCb, 16> _msg_sinks;
|
||||
StaticBuffer<PollSinkCb, 16> _loop_sinks;
|
||||
StaticBuffer<PollPeriodicSinkCb, 16> _periodic_sinks;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _TYPES_H
|
||||
#define _TYPES_H
|
||||
/*
|
||||
* Keep the compiler happy
|
||||
*/
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/*
|
||||
* Disable specific compiler warnings
|
||||
* 4018 - '<' : signed/unsigned mismatch
|
||||
* 4100 - 'xxx' : unreferenced formal parameter
|
||||
* 4127 - conditional expression is constant
|
||||
* 4201 - nonstandard extension used : nameless struct/union
|
||||
* 4389 - '!=' : signed/unsigned mismatch
|
||||
* 4800 - 'int' : forcing value to bool 'true' or 'false' (performance warning)
|
||||
*/
|
||||
#pragma warning(disable: 4018 4100 4127 4201 4389 4800)
|
||||
#endif
|
||||
|
||||
#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)
|
||||
#define TARGET_UWP
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Simple types
|
||||
*/
|
||||
typedef unsigned char uint8;
|
||||
typedef unsigned short uint16;
|
||||
typedef unsigned int uint32;
|
||||
typedef unsigned char byte;
|
||||
typedef char int8;
|
||||
typedef short int16;
|
||||
typedef int int32;
|
||||
|
||||
#include "ggponet.h"
|
||||
#include "log/Log.h"
|
||||
#include <stdexcept>
|
||||
|
||||
class GGPOException : public std::runtime_error {
|
||||
public:
|
||||
GGPOException(const char *what, GGPOErrorCode ggpoError)
|
||||
: std::runtime_error(what), ggpoError(ggpoError) {}
|
||||
|
||||
GGPOErrorCode ggpoError;
|
||||
};
|
||||
|
||||
/*
|
||||
* Additional headers
|
||||
*/
|
||||
#if defined(_WIN32)
|
||||
# include "platform_windows.h"
|
||||
#elif defined(__unix__) || defined(__APPLE__) || defined(__SWITCH__)
|
||||
# include "platform_linux.h"
|
||||
#else
|
||||
# error Unsupported platform
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros
|
||||
*/
|
||||
#define ASSERT(x) \
|
||||
do { \
|
||||
if (!(x)) { \
|
||||
char assert_buf[1024]; \
|
||||
snprintf(assert_buf, sizeof(assert_buf) - 1, "Assertion: %s @ %s:%d", #x, __FILE__, __LINE__); \
|
||||
GGPOPlatform::AssertFailed(assert_buf); \
|
||||
throw GGPOException(assert_buf, GGPO_ERRORCODE_GENERAL_FAILURE); \
|
||||
} \
|
||||
} while (false)
|
||||
|
||||
#define Log(...) DEBUG_LOG(NETWORK, __VA_ARGS__)
|
||||
|
||||
#ifndef ARRAY_SIZE
|
||||
# define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#endif
|
||||
|
||||
#ifndef MAX_INT
|
||||
# define MAX_INT 0xEFFFFFF
|
||||
#endif
|
||||
|
||||
#ifndef MAX
|
||||
# define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#endif // _TYPES_H
|
||||
@@ -0,0 +1,305 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "input_queue.h"
|
||||
#include "ggpo_types.h"
|
||||
|
||||
#define PREVIOUS_FRAME(offset) (((offset) == 0) ? (INPUT_QUEUE_LENGTH - 1) : ((offset) - 1))
|
||||
|
||||
InputQueue::InputQueue(int input_size)
|
||||
{
|
||||
Init(-1, input_size);
|
||||
}
|
||||
|
||||
InputQueue::~InputQueue()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
InputQueue::Init(int id, int input_size)
|
||||
{
|
||||
_id = id;
|
||||
_head = 0;
|
||||
_tail = 0;
|
||||
_length = 0;
|
||||
_frame_delay = 0;
|
||||
_first_frame = true;
|
||||
_last_user_added_frame = GameInput::NullFrame;
|
||||
_first_incorrect_frame = GameInput::NullFrame;
|
||||
_last_frame_requested = GameInput::NullFrame;
|
||||
_last_added_frame = GameInput::NullFrame;
|
||||
|
||||
_prediction.init(GameInput::NullFrame, NULL, input_size);
|
||||
|
||||
/*
|
||||
* This is safe because we know the GameInput is a proper structure (as in,
|
||||
* no virtual methods, no contained classes, etc.).
|
||||
*/
|
||||
memset(_inputs, 0, sizeof _inputs);
|
||||
for (size_t i = 0; i < ARRAY_SIZE(_inputs); i++) {
|
||||
_inputs[i].size = input_size;
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
InputQueue::GetLastConfirmedFrame()
|
||||
{
|
||||
Log("input q%d | returning last confirmed frame %d.", _id, _last_added_frame);
|
||||
return _last_added_frame;
|
||||
}
|
||||
|
||||
int
|
||||
InputQueue::GetFirstIncorrectFrame()
|
||||
{
|
||||
return _first_incorrect_frame;
|
||||
}
|
||||
|
||||
void
|
||||
InputQueue::DiscardConfirmedFrames(int frame)
|
||||
{
|
||||
ASSERT(frame >= 0);
|
||||
|
||||
if (_last_frame_requested != GameInput::NullFrame) {
|
||||
frame = MIN(frame, _last_frame_requested);
|
||||
}
|
||||
|
||||
Log("input q%d | discarding confirmed frames up to %d (last_added:%d length:%d [head:%d tail:%d]).", _id,
|
||||
frame, _last_added_frame, _length, _head, _tail);
|
||||
if (frame >= _last_added_frame) {
|
||||
_tail = _head;
|
||||
} else {
|
||||
int offset = frame - _inputs[_tail].frame + 1;
|
||||
|
||||
Log("input q%d | difference of %d frames.", _id, offset);
|
||||
ASSERT(offset >= 0);
|
||||
|
||||
_tail = (_tail + offset) % INPUT_QUEUE_LENGTH;
|
||||
_length -= offset;
|
||||
}
|
||||
|
||||
Log("input q%d | after discarding, new tail is %d (frame:%d).", _id, _tail, _inputs[_tail].frame);
|
||||
ASSERT(_length >= 0);
|
||||
}
|
||||
|
||||
void
|
||||
InputQueue::ResetPrediction(int frame)
|
||||
{
|
||||
ASSERT(_first_incorrect_frame == GameInput::NullFrame || frame <= _first_incorrect_frame);
|
||||
|
||||
Log("input q%d | resetting all prediction errors back to frame %d.", _id, frame);
|
||||
|
||||
/*
|
||||
* There's nothing really to do other than reset our prediction
|
||||
* state and the incorrect frame counter...
|
||||
*/
|
||||
_prediction.frame = GameInput::NullFrame;
|
||||
_first_incorrect_frame = GameInput::NullFrame;
|
||||
_last_frame_requested = GameInput::NullFrame;
|
||||
}
|
||||
|
||||
bool
|
||||
InputQueue::GetConfirmedInput(int requested_frame, GameInput *input)
|
||||
{
|
||||
ASSERT(_first_incorrect_frame == GameInput::NullFrame || requested_frame < _first_incorrect_frame);
|
||||
int offset = requested_frame % INPUT_QUEUE_LENGTH;
|
||||
if (_inputs[offset].frame != requested_frame) {
|
||||
return false;
|
||||
}
|
||||
*input = _inputs[offset];
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
InputQueue::GetInput(int requested_frame, GameInput *input)
|
||||
{
|
||||
Log("input q%d | requesting input frame %d.", _id, requested_frame);
|
||||
|
||||
/*
|
||||
* No one should ever try to grab any input when we have a prediction
|
||||
* error. Doing so means that we're just going further down the wrong
|
||||
* path. ASSERT this to verify that it's true.
|
||||
*/
|
||||
ASSERT(_first_incorrect_frame == GameInput::NullFrame);
|
||||
|
||||
/*
|
||||
* Remember the last requested frame number for later. We'll need
|
||||
* this in AddInput() to drop out of prediction mode.
|
||||
*/
|
||||
_last_frame_requested = requested_frame;
|
||||
|
||||
ASSERT(requested_frame >= _inputs[_tail].frame);
|
||||
|
||||
if (_prediction.frame == GameInput::NullFrame) {
|
||||
/*
|
||||
* If the frame requested is in our range, fetch it out of the queue and
|
||||
* return it.
|
||||
*/
|
||||
int offset = requested_frame - _inputs[_tail].frame;
|
||||
|
||||
if (offset < _length) {
|
||||
offset = (offset + _tail) % INPUT_QUEUE_LENGTH;
|
||||
ASSERT(_inputs[offset].frame == requested_frame);
|
||||
*input = _inputs[offset];
|
||||
Log("input q%d | returning confirmed frame number %d.", _id, input->frame);
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* The requested frame isn't in the queue. Bummer. This means we need
|
||||
* to return a prediction frame. Predict that the user will do the
|
||||
* same thing they did last time.
|
||||
*/
|
||||
if (requested_frame == 0) {
|
||||
Log("input q%d | basing new prediction frame from nothing, you're client wants frame 0.", _id);
|
||||
_prediction.erase();
|
||||
} else if (_last_added_frame == GameInput::NullFrame) {
|
||||
Log("input q%d | basing new prediction frame from nothing, since we have no frames yet.", _id);
|
||||
_prediction.erase();
|
||||
} else {
|
||||
Log("input q%d | basing new prediction frame from previously added frame (queue entry:%d, frame:%d).", _id,
|
||||
PREVIOUS_FRAME(_head), _inputs[PREVIOUS_FRAME(_head)].frame);
|
||||
_prediction = _inputs[PREVIOUS_FRAME(_head)];
|
||||
}
|
||||
_prediction.frame++;
|
||||
}
|
||||
|
||||
ASSERT(_prediction.frame >= 0);
|
||||
|
||||
/*
|
||||
* If we've made it this far, we must be predicting. Go ahead and
|
||||
* forward the prediction frame contents. Be sure to return the
|
||||
* frame number requested by the client, though.
|
||||
*/
|
||||
*input = _prediction;
|
||||
input->frame = requested_frame;
|
||||
Log("input q%d | returning prediction frame number %d (%d).", _id, input->frame, _prediction.frame);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
InputQueue::AddInput(GameInput &input)
|
||||
{
|
||||
int new_frame;
|
||||
|
||||
Log("input q%d | adding input frame number %d to queue.", _id, input.frame);
|
||||
|
||||
/*
|
||||
* These next two lines simply verify that inputs are passed in
|
||||
* sequentially by the user, regardless of frame delay.
|
||||
*/
|
||||
ASSERT(_last_user_added_frame == GameInput::NullFrame ||
|
||||
input.frame == _last_user_added_frame + 1);
|
||||
_last_user_added_frame = input.frame;
|
||||
|
||||
/*
|
||||
* Move the queue head to the correct point in preparation to
|
||||
* input the frame into the queue.
|
||||
*/
|
||||
new_frame = AdvanceQueueHead(input.frame);
|
||||
if (new_frame != GameInput::NullFrame) {
|
||||
AddDelayedInputToQueue(input, new_frame);
|
||||
}
|
||||
|
||||
/*
|
||||
* Update the frame number for the input. This will also set the
|
||||
* frame to GameInput::NullFrame for frames that get dropped (by
|
||||
* design).
|
||||
*/
|
||||
input.frame = new_frame;
|
||||
}
|
||||
|
||||
void
|
||||
InputQueue::AddDelayedInputToQueue(GameInput &input, int frame_number)
|
||||
{
|
||||
Log("input q%d | adding delayed input frame number %d to queue.", _id, frame_number);
|
||||
|
||||
if (input.size != _prediction.size)
|
||||
throw GGPOException("Input size differs from peer", GGPO_ERRORCODE_INPUT_SIZE_DIFF);
|
||||
|
||||
ASSERT(_last_added_frame == GameInput::NullFrame || frame_number == _last_added_frame + 1);
|
||||
|
||||
ASSERT(frame_number == 0 || _inputs[PREVIOUS_FRAME(_head)].frame == frame_number - 1);
|
||||
|
||||
/*
|
||||
* Add the frame to the back of the queue
|
||||
*/
|
||||
_inputs[_head] = input;
|
||||
_inputs[_head].frame = frame_number;
|
||||
_head = (_head + 1) % INPUT_QUEUE_LENGTH;
|
||||
_length++;
|
||||
_first_frame = false;
|
||||
|
||||
_last_added_frame = frame_number;
|
||||
|
||||
if (_prediction.frame != GameInput::NullFrame) {
|
||||
ASSERT(frame_number == _prediction.frame);
|
||||
|
||||
/*
|
||||
* We've been predicting... See if the inputs we've gotten match
|
||||
* what we've been predicting. If so, don't worry about it. If not,
|
||||
* remember the first input which was incorrect so we can report it
|
||||
* in GetFirstIncorrectFrame()
|
||||
*/
|
||||
if (_first_incorrect_frame == GameInput::NullFrame && !_prediction.equal(input, true)) {
|
||||
Log("input q%d | frame %d does not match prediction. marking error.", _id, frame_number);
|
||||
_first_incorrect_frame = frame_number;
|
||||
}
|
||||
|
||||
/*
|
||||
* If this input is the same frame as the last one requested and we
|
||||
* still haven't found any mis-predicted inputs, we can dump out
|
||||
* of predition mode entirely! Otherwise, advance the prediction frame
|
||||
* count up.
|
||||
*/
|
||||
if (_prediction.frame == _last_frame_requested && _first_incorrect_frame == GameInput::NullFrame) {
|
||||
Log("input q%d | prediction is correct! dumping out of prediction mode.", _id);
|
||||
_prediction.frame = GameInput::NullFrame;
|
||||
} else {
|
||||
_prediction.frame++;
|
||||
}
|
||||
}
|
||||
ASSERT(_length <= INPUT_QUEUE_LENGTH);
|
||||
}
|
||||
|
||||
int
|
||||
InputQueue::AdvanceQueueHead(int frame)
|
||||
{
|
||||
Log("input q%d | advancing queue head to frame %d.", _id, frame);
|
||||
|
||||
int expected_frame = _first_frame ? 0 : _inputs[PREVIOUS_FRAME(_head)].frame + 1;
|
||||
|
||||
frame += _frame_delay;
|
||||
|
||||
if (expected_frame > frame) {
|
||||
/*
|
||||
* This can occur when the frame delay has dropped since the last
|
||||
* time we shoved a frame into the system. In this case, there's
|
||||
* no room on the queue. Toss it.
|
||||
*/
|
||||
Log("input q%d | Dropping input frame %d (expected next frame to be %d).", _id,
|
||||
frame, expected_frame);
|
||||
return GameInput::NullFrame;
|
||||
}
|
||||
|
||||
while (expected_frame < frame) {
|
||||
/*
|
||||
* This can occur when the frame delay has been increased since the last
|
||||
* time we shoved a frame into the system. We need to replicate the
|
||||
* last frame in the queue several times in order to fill the space
|
||||
* left.
|
||||
*/
|
||||
Log("input q%d | Adding padding frame %d to account for change in frame delay.", _id,
|
||||
expected_frame);
|
||||
GameInput &last_frame = _inputs[PREVIOUS_FRAME(_head)];
|
||||
AddDelayedInputToQueue(last_frame, expected_frame);
|
||||
expected_frame++;
|
||||
}
|
||||
|
||||
ASSERT(frame == 0 || frame == _inputs[PREVIOUS_FRAME(_head)].frame + 1);
|
||||
return frame;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _INPUT_QUEUE_H
|
||||
#define _INPUT_QUEUE_H
|
||||
|
||||
#include "game_input.h"
|
||||
|
||||
#define INPUT_QUEUE_LENGTH 128
|
||||
#define DEFAULT_INPUT_SIZE 4
|
||||
|
||||
class InputQueue {
|
||||
public:
|
||||
InputQueue(int input_size = DEFAULT_INPUT_SIZE);
|
||||
~InputQueue();
|
||||
|
||||
public:
|
||||
void Init(int id, int input_size);
|
||||
int GetLastConfirmedFrame();
|
||||
int GetFirstIncorrectFrame();
|
||||
int GetLength() { return _length; }
|
||||
|
||||
void SetFrameDelay(int delay) { _frame_delay = delay; }
|
||||
void ResetPrediction(int frame);
|
||||
void DiscardConfirmedFrames(int frame);
|
||||
bool GetConfirmedInput(int frame, GameInput *input);
|
||||
bool GetInput(int frame, GameInput *input);
|
||||
void AddInput(GameInput &input);
|
||||
|
||||
protected:
|
||||
int AdvanceQueueHead(int frame);
|
||||
void AddDelayedInputToQueue(GameInput &input, int i);
|
||||
|
||||
protected:
|
||||
int _id;
|
||||
int _head;
|
||||
int _tail;
|
||||
int _length;
|
||||
bool _first_frame;
|
||||
|
||||
int _last_user_added_frame;
|
||||
int _last_added_frame;
|
||||
int _first_incorrect_frame;
|
||||
int _last_frame_requested;
|
||||
|
||||
int _frame_delay;
|
||||
|
||||
GameInput _inputs[INPUT_QUEUE_LENGTH];
|
||||
GameInput _prediction;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,260 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "backends/p2p.h"
|
||||
#include "backends/synctest.h"
|
||||
#include "backends/spectator.h"
|
||||
#include "ggpo_types.h"
|
||||
#include "ggponet.h"
|
||||
|
||||
struct Init
|
||||
{
|
||||
Init() {
|
||||
srand(GGPOPlatform::GetCurrentTimeMS() + GGPOPlatform::GetProcessID());
|
||||
#ifdef _WIN32
|
||||
WSADATA wsaData;
|
||||
WSAStartup(MAKEWORD(2, 0), &wsaData);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
static Init init;
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_start_session(GGPOSession **session,
|
||||
GGPOSessionCallbacks *cb,
|
||||
const char *game,
|
||||
int num_players,
|
||||
int input_size,
|
||||
unsigned short localport,
|
||||
const void *verification,
|
||||
int verification_size)
|
||||
{
|
||||
try {
|
||||
*session= (GGPOSession *)new Peer2PeerBackend(cb,
|
||||
game,
|
||||
localport,
|
||||
num_players,
|
||||
input_size,
|
||||
verification,
|
||||
verification_size);
|
||||
return GGPO_OK;
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_start_session: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_add_player(GGPOSession *ggpo,
|
||||
GGPOPlayer *player,
|
||||
GGPOPlayerHandle *handle)
|
||||
{
|
||||
if (!ggpo)
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
try {
|
||||
return ggpo->AddPlayer(player, handle);
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_add_player: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_start_synctest(GGPOSession **ggpo,
|
||||
GGPOSessionCallbacks *cb,
|
||||
const char *game,
|
||||
int num_players,
|
||||
int input_size,
|
||||
int frames)
|
||||
{
|
||||
try {
|
||||
*ggpo = (GGPOSession *)new SyncTestBackend(cb, game, frames, num_players);
|
||||
return GGPO_OK;
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_start_synctest: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_set_frame_delay(GGPOSession *ggpo,
|
||||
GGPOPlayerHandle player,
|
||||
int frame_delay)
|
||||
{
|
||||
if (!ggpo)
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
try {
|
||||
return ggpo->SetFrameDelay(player, frame_delay);
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_set_frame_delay: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_idle(GGPOSession *ggpo, int timeout)
|
||||
{
|
||||
if (!ggpo)
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
try {
|
||||
return ggpo->DoPoll(timeout);
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_idle: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_add_local_input(GGPOSession *ggpo,
|
||||
GGPOPlayerHandle player,
|
||||
void *values,
|
||||
int size)
|
||||
{
|
||||
if (!ggpo)
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
try {
|
||||
return ggpo->AddLocalInput(player, values, size);
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_add_local_input: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_synchronize_input(GGPOSession *ggpo,
|
||||
void *values,
|
||||
int size,
|
||||
int *disconnect_flags)
|
||||
{
|
||||
if (!ggpo)
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
try {
|
||||
return ggpo->SyncInput(values, size, disconnect_flags);
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_synchronize_input: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode ggpo_disconnect_player(GGPOSession *ggpo,
|
||||
GGPOPlayerHandle player)
|
||||
{
|
||||
if (!ggpo)
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
try {
|
||||
return ggpo->DisconnectPlayer(player);
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_disconnect_player: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_advance_frame(GGPOSession *ggpo)
|
||||
{
|
||||
if (!ggpo)
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
try {
|
||||
return ggpo->IncrementFrame();
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_advance_frame: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_get_network_stats(GGPOSession *ggpo,
|
||||
GGPOPlayerHandle player,
|
||||
GGPONetworkStats *stats)
|
||||
{
|
||||
if (!ggpo)
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
try {
|
||||
return ggpo->GetNetworkStats(stats, player);
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_get_network_stats: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_close_session(GGPOSession *ggpo)
|
||||
{
|
||||
if (!ggpo) {
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
}
|
||||
delete ggpo;
|
||||
return GGPO_OK;
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_set_disconnect_timeout(GGPOSession *ggpo, int timeout)
|
||||
{
|
||||
if (!ggpo)
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
try {
|
||||
return ggpo->SetDisconnectTimeout(timeout);
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_set_disconnect_timeout: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode
|
||||
ggpo_set_disconnect_notify_start(GGPOSession *ggpo, int timeout)
|
||||
{
|
||||
if (!ggpo)
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
try {
|
||||
return ggpo->SetDisconnectNotifyStart(timeout);
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_set_disconnect_notify_start: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode ggpo_start_spectating(GGPOSession **session,
|
||||
GGPOSessionCallbacks *cb,
|
||||
const char *game,
|
||||
int num_players,
|
||||
int input_size,
|
||||
unsigned short local_port,
|
||||
char *host_ip,
|
||||
unsigned short host_port,
|
||||
const void *verification,
|
||||
int verification_size)
|
||||
{
|
||||
try {
|
||||
*session= (GGPOSession *)new SpectatorBackend(cb,
|
||||
game,
|
||||
local_port,
|
||||
num_players,
|
||||
input_size,
|
||||
host_ip,
|
||||
host_port,
|
||||
verification,
|
||||
verification_size);
|
||||
return GGPO_OK;
|
||||
} catch (const GGPOException& e) {
|
||||
ERROR_LOG(NETWORK, "GGPOException in ggpo_start_spectating: %s", e.what());
|
||||
return e.ggpoError;
|
||||
}
|
||||
}
|
||||
|
||||
GGPOErrorCode ggpo_send_message(GGPOSession *ggpo,
|
||||
const void *msg,
|
||||
int len,
|
||||
bool spectators)
|
||||
{
|
||||
if (ggpo == nullptr)
|
||||
return GGPO_ERRORCODE_INVALID_SESSION;
|
||||
return ggpo->SendMessage(msg, len, spectators);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "ggpo_types.h"
|
||||
#include "udp.h"
|
||||
|
||||
SOCKET
|
||||
CreateSocket(uint16 bind_port, int retries)
|
||||
{
|
||||
SOCKET s;
|
||||
sockaddr_in sin;
|
||||
uint16 port;
|
||||
int optval = 1;
|
||||
|
||||
s = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (const char *)&optval, sizeof optval);
|
||||
optval = 0;
|
||||
setsockopt(s, SOL_SOCKET, SO_LINGER, (const char *)&optval, sizeof optval);
|
||||
|
||||
// non-blocking...
|
||||
#ifndef _WIN32
|
||||
fcntl(s, F_SETFL, O_NONBLOCK);
|
||||
#else
|
||||
u_long iMode = 1;
|
||||
ioctlsocket(s, FIONBIO, &iMode);
|
||||
#endif
|
||||
|
||||
sin.sin_family = AF_INET;
|
||||
sin.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
for (port = bind_port; port <= bind_port + retries; port++) {
|
||||
sin.sin_port = htons(port);
|
||||
if (bind(s, (sockaddr *)&sin, sizeof sin) == 0) {
|
||||
Log("Udp bound to port: %d.", port);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
closesocket(s);
|
||||
return INVALID_SOCKET;
|
||||
}
|
||||
|
||||
Udp::Udp() :
|
||||
_socket(INVALID_SOCKET),
|
||||
_callbacks(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
Udp::~Udp(void)
|
||||
{
|
||||
if (_socket != INVALID_SOCKET) {
|
||||
closesocket(_socket);
|
||||
_socket = INVALID_SOCKET;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Udp::Init(uint16 port, Poll *poll, Callbacks *callbacks)
|
||||
{
|
||||
_callbacks = callbacks;
|
||||
poll->RegisterLoop(this);
|
||||
|
||||
Log("binding udp socket to port %d.", port);
|
||||
_socket = CreateSocket(port, 0);
|
||||
if (_socket == INVALID_SOCKET)
|
||||
throw GGPOException("Socket creation or bind failed", GGPO_ERRORCODE_NETWORK_ERROR);
|
||||
}
|
||||
|
||||
void
|
||||
Udp::SendTo(char *buffer, int len, int flags, struct sockaddr *dst, int destlen)
|
||||
{
|
||||
struct sockaddr_in *to = (struct sockaddr_in *)dst;
|
||||
|
||||
int res = sendto(_socket, buffer, len, flags, dst, destlen);
|
||||
if (res == SOCKET_ERROR) {
|
||||
int err = WSAGetLastError();
|
||||
Log("unknown error in sendto (erro: %d wsaerr: %d).", res, err);
|
||||
ASSERT(false && "Unknown error in sendto");
|
||||
}
|
||||
char dst_ip[1024];
|
||||
Log("sent packet length %d to %s:%d (ret:%d).", len, inet_ntop(AF_INET, (void *)&to->sin_addr, dst_ip, ARRAY_SIZE(dst_ip)), ntohs(to->sin_port), res);
|
||||
}
|
||||
|
||||
bool
|
||||
Udp::OnLoopPoll(void *cookie)
|
||||
{
|
||||
uint8 recv_buf[MAX_UDP_PACKET_SIZE];
|
||||
sockaddr_in recv_addr;
|
||||
socklen_t recv_addr_len;
|
||||
|
||||
for (;;) {
|
||||
recv_addr_len = sizeof(recv_addr);
|
||||
int len = recvfrom(_socket, (char *)recv_buf, MAX_UDP_PACKET_SIZE, 0, (struct sockaddr *)&recv_addr, &recv_addr_len);
|
||||
|
||||
// TODO: handle len == 0... indicates a disconnect.
|
||||
|
||||
if (len == -1) {
|
||||
int error = WSAGetLastError();
|
||||
if (error != WSAEWOULDBLOCK) {
|
||||
Log("recvfrom WSAGetLastError returned %d (%x).", error, error);
|
||||
}
|
||||
break;
|
||||
} else if (len > 0) {
|
||||
char src_ip[1024];
|
||||
Log("recvfrom returned (len:%d from:%s:%d).", len, inet_ntop(AF_INET, (void*)&recv_addr.sin_addr, src_ip, ARRAY_SIZE(src_ip)), ntohs(recv_addr.sin_port) );
|
||||
UdpMsg *msg = (UdpMsg *)recv_buf;
|
||||
_callbacks->OnMsg(recv_addr, msg, len);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _UDP_H
|
||||
#define _UDP_H
|
||||
|
||||
#include "ggpo_poll.h"
|
||||
#include "udp_msg.h"
|
||||
#include "ggponet.h"
|
||||
#include "ring_buffer.h"
|
||||
|
||||
#define MAX_UDP_ENDPOINTS 16
|
||||
|
||||
constexpr size_t MAX_UDP_PACKET_SIZE = sizeof(UdpMsg);
|
||||
|
||||
class Udp : public IPollSink
|
||||
{
|
||||
public:
|
||||
struct Stats {
|
||||
int bytes_sent;
|
||||
int packets_sent;
|
||||
float kbps_sent;
|
||||
};
|
||||
|
||||
struct Callbacks {
|
||||
virtual ~Callbacks() { }
|
||||
virtual void OnMsg(sockaddr_in &from, UdpMsg *msg, int len) = 0;
|
||||
};
|
||||
|
||||
Udp();
|
||||
|
||||
void Init(uint16 port, Poll *p, Callbacks *callbacks);
|
||||
|
||||
void SendTo(char *buffer, int len, int flags, struct sockaddr *dst, int destlen);
|
||||
|
||||
virtual bool OnLoopPoll(void *cookie);
|
||||
|
||||
public:
|
||||
~Udp(void);
|
||||
|
||||
protected:
|
||||
// Network transmission information
|
||||
SOCKET _socket;
|
||||
|
||||
// state management
|
||||
Callbacks *_callbacks;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,121 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _UDP_MSG_H
|
||||
#define _UDP_MSG_H
|
||||
|
||||
#define MAX_COMPRESSED_BITS 4096
|
||||
#define UDP_MSG_MAX_PLAYERS 4
|
||||
#define MAX_VERIFICATION_SIZE 256
|
||||
#define MAX_APPDATA_SIZE 512
|
||||
|
||||
#pragma pack(push, 1)
|
||||
|
||||
struct UdpMsg
|
||||
{
|
||||
enum MsgType {
|
||||
Invalid = 0,
|
||||
SyncRequest = 1,
|
||||
SyncReply = 2,
|
||||
Input = 3,
|
||||
QualityReport = 4,
|
||||
QualityReply = 5,
|
||||
KeepAlive = 6,
|
||||
InputAck = 7,
|
||||
AppData = 8
|
||||
};
|
||||
|
||||
struct connect_status {
|
||||
unsigned int disconnected:1;
|
||||
int last_frame:31;
|
||||
};
|
||||
|
||||
struct {
|
||||
uint16 magic;
|
||||
uint16 sequence_number;
|
||||
uint8 type; /* packet type */
|
||||
} hdr;
|
||||
union {
|
||||
struct {
|
||||
uint32 random_request; /* please reply back with this random data */
|
||||
uint16 remote_magic;
|
||||
uint8 remote_endpoint;
|
||||
uint8 verification[MAX_VERIFICATION_SIZE];
|
||||
} sync_request;
|
||||
|
||||
struct {
|
||||
uint32 random_reply; /* OK, here's your random data back */
|
||||
uint8 verification_failure; /* set to one by peer if verification failed */
|
||||
} sync_reply;
|
||||
|
||||
struct {
|
||||
int8 frame_advantage; /* what's the other guy's frame advantage? */
|
||||
uint32 ping;
|
||||
} quality_report;
|
||||
|
||||
struct {
|
||||
uint32 pong;
|
||||
} quality_reply;
|
||||
|
||||
struct {
|
||||
connect_status peer_connect_status[UDP_MSG_MAX_PLAYERS];
|
||||
|
||||
uint32 start_frame;
|
||||
|
||||
int disconnect_requested:1;
|
||||
int ack_frame:31;
|
||||
|
||||
uint16 num_bits;
|
||||
uint8 input_size; // XXX: shouldn't be in every single packet!
|
||||
uint8 bits[MAX_COMPRESSED_BITS / 8]; /* must be last */
|
||||
} input;
|
||||
|
||||
struct {
|
||||
int ack_frame:31;
|
||||
} input_ack;
|
||||
|
||||
struct {
|
||||
uint16 size;
|
||||
uint8 spectators;
|
||||
uint8 data[MAX_APPDATA_SIZE];
|
||||
} app_data;
|
||||
|
||||
} u;
|
||||
|
||||
int verification_size = 0;
|
||||
|
||||
public:
|
||||
int PacketSize() {
|
||||
return sizeof(hdr) + PayloadSize();
|
||||
}
|
||||
|
||||
int PayloadSize() {
|
||||
switch (hdr.type) {
|
||||
case SyncRequest: return (int)(&u.sync_request.verification[0] - (uint8 *)&u) + verification_size;
|
||||
case SyncReply: return sizeof(u.sync_reply);
|
||||
case QualityReport: return sizeof(u.quality_report);
|
||||
case QualityReply: return sizeof(u.quality_reply);
|
||||
case InputAck: return sizeof(u.input_ack);
|
||||
case KeepAlive: return 0;
|
||||
case Input:
|
||||
{
|
||||
int size = (int)((char *)&u.input.bits - (char *)&u.input);
|
||||
size += (u.input.num_bits + 7) / 8;
|
||||
return size;
|
||||
}
|
||||
case AppData: return sizeof(u.app_data) - sizeof(u.app_data.data) + u.app_data.size;
|
||||
}
|
||||
ASSERT(false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
UdpMsg(MsgType t) { hdr.type = (uint8)t; }
|
||||
};
|
||||
|
||||
#pragma pack(pop)
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,815 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "udp_proto.h"
|
||||
|
||||
#include "../ggpo_types.h"
|
||||
#include "bitvector.h"
|
||||
|
||||
static const int UDP_HEADER_SIZE = 28; /* Size of IP + UDP headers */
|
||||
static const int NUM_SYNC_PACKETS = 5;
|
||||
static const int SYNC_RETRY_INTERVAL = 2000;
|
||||
static const int SYNC_FIRST_RETRY_INTERVAL = 500;
|
||||
static const int RUNNING_RETRY_INTERVAL = 200;
|
||||
static const int KEEP_ALIVE_INTERVAL = 200;
|
||||
static const int QUALITY_REPORT_INTERVAL = 1000;
|
||||
static const int NETWORK_STATS_INTERVAL = 1000;
|
||||
static const int UDP_SHUTDOWN_TIMER = 5000;
|
||||
static const int MAX_SEQ_DISTANCE = (1 << 15);
|
||||
|
||||
UdpProtocol::UdpProtocol() :
|
||||
_udp(NULL),
|
||||
_magic_number(0),
|
||||
_queue(-1),
|
||||
_remote_magic_number(0),
|
||||
_connected(false),
|
||||
_packets_sent(0),
|
||||
_bytes_sent(0),
|
||||
_stats_start_time(0),
|
||||
_local_frame_advantage(0),
|
||||
_remote_frame_advantage(0),
|
||||
_last_send_time(0),
|
||||
_shutdown_timeout(0),
|
||||
_disconnect_event_sent(false),
|
||||
_disconnect_timeout(0),
|
||||
_disconnect_notify_start(0),
|
||||
_disconnect_notify_sent(false),
|
||||
_next_send_seq(0),
|
||||
_next_recv_seq(0)
|
||||
{
|
||||
_last_sent_input.init(-1, NULL, 1);
|
||||
_last_received_input.init(-1, NULL, 1);
|
||||
_last_acked_input.init(-1, NULL, 1);
|
||||
|
||||
memset(&_state, 0, sizeof _state);
|
||||
memset(_peer_connect_status, 0, sizeof(_peer_connect_status));
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(_peer_connect_status); i++) {
|
||||
_peer_connect_status[i].last_frame = -1;
|
||||
}
|
||||
memset(&_peer_addr, 0, sizeof _peer_addr);
|
||||
_oo_packet.msg = NULL;
|
||||
|
||||
_send_latency = GGPOPlatform::GetConfigInt("GGPO_NETWORK_DELAY");
|
||||
_oop_percent = GGPOPlatform::GetConfigInt("GGPO_OOP_PERCENT");
|
||||
}
|
||||
|
||||
UdpProtocol::~UdpProtocol()
|
||||
{
|
||||
ClearSendQueue();
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::Init(Udp *udp,
|
||||
Poll &poll,
|
||||
int queue,
|
||||
char *ip,
|
||||
u_short port,
|
||||
UdpMsg::connect_status *status)
|
||||
{
|
||||
_udp = udp;
|
||||
_queue = queue;
|
||||
_local_connect_status = status;
|
||||
|
||||
_peer_addr.sin_family = AF_INET;
|
||||
if (ip != nullptr && ip[0] != '\0')
|
||||
{
|
||||
_peer_addr.sin_port = htons(port);
|
||||
inet_pton(AF_INET, ip, &_peer_addr.sin_addr.s_addr);
|
||||
}
|
||||
|
||||
do {
|
||||
_magic_number = (uint16)rand();
|
||||
} while (_magic_number == 0);
|
||||
poll.RegisterLoop(this);
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::SendInput(GameInput &input)
|
||||
{
|
||||
if (_udp) {
|
||||
if (_current_state == Running) {
|
||||
/*
|
||||
* Check to see if this is a good time to adjust for the rift...
|
||||
*/
|
||||
_timesync.advance_frame(input, _local_frame_advantage, _remote_frame_advantage);
|
||||
|
||||
/*
|
||||
* Save this input packet
|
||||
*
|
||||
* XXX: This queue may fill up for spectators who do not ack input packets in a timely
|
||||
* manner. When this happens, we can either resize the queue (ug) or disconnect them
|
||||
* (better, but still ug). For the meantime, make this queue really big to decrease
|
||||
* the odds of this happening...
|
||||
*/
|
||||
_pending_output.push(input);
|
||||
}
|
||||
SendPendingOutput();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::SendPendingOutput()
|
||||
{
|
||||
UdpMsg *msg = new UdpMsg(UdpMsg::Input);
|
||||
int i, j, offset = 0;
|
||||
uint8 *bits;
|
||||
GameInput last;
|
||||
|
||||
if (_pending_output.size()) {
|
||||
last = _last_acked_input;
|
||||
bits = msg->u.input.bits;
|
||||
|
||||
msg->u.input.start_frame = _pending_output.front().frame;
|
||||
msg->u.input.input_size = (uint8)_pending_output.front().size;
|
||||
|
||||
ASSERT(last.frame == -1 || last.frame + 1 == (int)msg->u.input.start_frame);
|
||||
for (j = 0; j < _pending_output.size(); j++) {
|
||||
GameInput ¤t = _pending_output.item(j);
|
||||
if (memcmp(current.bits, last.bits, current.size) != 0) {
|
||||
ASSERT((GAMEINPUT_MAX_BYTES * GAMEINPUT_MAX_PLAYERS * 8) < (1 << BITVECTOR_NIBBLE_SIZE));
|
||||
for (i = 0; i < current.size * 8; i++) {
|
||||
ASSERT(i < (1 << BITVECTOR_NIBBLE_SIZE));
|
||||
if (current.value(i) != last.value(i)) {
|
||||
BitVector_SetBit(msg->u.input.bits, &offset);
|
||||
(current.value(i) ? BitVector_SetBit : BitVector_ClearBit)(bits, &offset);
|
||||
BitVector_WriteNibblet(bits, i, &offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
BitVector_ClearBit(msg->u.input.bits, &offset);
|
||||
last = _last_sent_input = current;
|
||||
}
|
||||
} else {
|
||||
msg->u.input.start_frame = 0;
|
||||
msg->u.input.input_size = 0;
|
||||
}
|
||||
msg->u.input.ack_frame = _last_received_input.frame;
|
||||
msg->u.input.num_bits = (uint16)offset;
|
||||
|
||||
msg->u.input.disconnect_requested = _current_state == Disconnected;
|
||||
if (_local_connect_status) {
|
||||
memcpy(msg->u.input.peer_connect_status, _local_connect_status, sizeof(UdpMsg::connect_status) * UDP_MSG_MAX_PLAYERS);
|
||||
} else {
|
||||
memset(msg->u.input.peer_connect_status, 0, sizeof(UdpMsg::connect_status) * UDP_MSG_MAX_PLAYERS);
|
||||
}
|
||||
|
||||
ASSERT(offset < MAX_COMPRESSED_BITS);
|
||||
|
||||
SendMsg(msg);
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::SendInputAck()
|
||||
{
|
||||
UdpMsg *msg = new UdpMsg(UdpMsg::InputAck);
|
||||
msg->u.input_ack.ack_frame = _last_received_input.frame;
|
||||
SendMsg(msg);
|
||||
}
|
||||
|
||||
bool
|
||||
UdpProtocol::GetEvent(UdpProtocol::Event &e)
|
||||
{
|
||||
if (_event_queue.size() == 0) {
|
||||
return false;
|
||||
}
|
||||
e = _event_queue.front();
|
||||
_event_queue.pop();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
UdpProtocol::OnLoopPoll(void *cookie)
|
||||
{
|
||||
if (!_udp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int now = GGPOPlatform::GetCurrentTimeMS();
|
||||
unsigned int next_interval;
|
||||
|
||||
PumpSendQueue();
|
||||
switch (_current_state) {
|
||||
case Syncing:
|
||||
next_interval = (_state.sync.roundtrips_remaining == NUM_SYNC_PACKETS) ? SYNC_FIRST_RETRY_INTERVAL : SYNC_RETRY_INTERVAL;
|
||||
if (_last_send_time && _last_send_time + next_interval < now && _peer_addr.sin_addr.s_addr != 0) {
|
||||
Log("udpproto%d | No luck syncing after %d ms... Re-queueing sync packet.", _queue, next_interval);
|
||||
SendSyncRequest();
|
||||
}
|
||||
break;
|
||||
|
||||
case Running:
|
||||
// xxx: rig all this up with a timer wrapper
|
||||
if (!_state.running.last_input_packet_recv_time || _state.running.last_input_packet_recv_time + RUNNING_RETRY_INTERVAL < now) {
|
||||
Log("udpproto%d | Haven't exchanged packets in a while (last received:%d last sent:%d). Resending.", _queue, _last_received_input.frame, _last_sent_input.frame);
|
||||
SendPendingOutput();
|
||||
_state.running.last_input_packet_recv_time = now;
|
||||
}
|
||||
|
||||
if (!_state.running.last_quality_report_time || _state.running.last_quality_report_time + QUALITY_REPORT_INTERVAL < now) {
|
||||
UdpMsg *msg = new UdpMsg(UdpMsg::QualityReport);
|
||||
msg->u.quality_report.ping = GGPOPlatform::GetCurrentTimeMS();
|
||||
msg->u.quality_report.frame_advantage = (uint8)_local_frame_advantage;
|
||||
SendMsg(msg);
|
||||
_state.running.last_quality_report_time = now;
|
||||
}
|
||||
|
||||
if (!_state.running.last_network_stats_interval || _state.running.last_network_stats_interval + NETWORK_STATS_INTERVAL < now) {
|
||||
UpdateNetworkStats();
|
||||
_state.running.last_network_stats_interval = now;
|
||||
}
|
||||
|
||||
if (_last_send_time && _last_send_time + KEEP_ALIVE_INTERVAL < now) {
|
||||
Log("udpproto%d | Sending keep alive packet", _queue);
|
||||
SendMsg(new UdpMsg(UdpMsg::KeepAlive));
|
||||
}
|
||||
|
||||
if (_disconnect_timeout && _disconnect_notify_start &&
|
||||
!_disconnect_notify_sent && (_last_recv_time + _disconnect_notify_start < now)) {
|
||||
Log("udpproto%d | Endpoint has stopped receiving packets for %d ms. Sending notification.", _queue, _disconnect_notify_start);
|
||||
Event e(Event::NetworkInterrupted);
|
||||
e.u.network_interrupted.disconnect_timeout = _disconnect_timeout - _disconnect_notify_start;
|
||||
QueueEvent(e);
|
||||
_disconnect_notify_sent = true;
|
||||
}
|
||||
|
||||
if (_disconnect_timeout && (_last_recv_time + _disconnect_timeout < now)) {
|
||||
if (!_disconnect_event_sent) {
|
||||
Log("udpproto%d | Endpoint has stopped receiving packets for %d ms. Disconnecting.", _queue, _disconnect_timeout);
|
||||
QueueEvent(Event(Event::Disconnected));
|
||||
_disconnect_event_sent = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Disconnected:
|
||||
if (_shutdown_timeout < now) {
|
||||
Log("udpproto%d | Shutting down udp connection.", _queue);
|
||||
_udp = NULL;
|
||||
_shutdown_timeout = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::Disconnect()
|
||||
{
|
||||
_current_state = Disconnected;
|
||||
_shutdown_timeout = GGPOPlatform::GetCurrentTimeMS() + UDP_SHUTDOWN_TIMER;
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::SendSyncRequest()
|
||||
{
|
||||
_state.sync.random = rand() & 0xFFFF;
|
||||
UdpMsg *msg = new UdpMsg(UdpMsg::SyncRequest);
|
||||
msg->u.sync_request.random_request = _state.sync.random;
|
||||
msg->verification_size = verification.size();
|
||||
if (!verification.empty())
|
||||
memcpy(&msg->u.sync_request.verification[0], &verification[0], verification.size());
|
||||
SendMsg(msg);
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::SendMsg(UdpMsg *msg)
|
||||
{
|
||||
LogMsg("send", msg);
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_send_mutex);
|
||||
_packets_sent++;
|
||||
_last_send_time = GGPOPlatform::GetCurrentTimeMS();
|
||||
_bytes_sent += msg->PacketSize();
|
||||
|
||||
msg->hdr.magic = _magic_number;
|
||||
msg->hdr.sequence_number = _next_send_seq++;
|
||||
|
||||
_send_queue.push(QueueEntry(GGPOPlatform::GetCurrentTimeMS(), _peer_addr, msg));
|
||||
}
|
||||
PumpSendQueue();
|
||||
}
|
||||
|
||||
bool
|
||||
UdpProtocol::HandlesMsg(sockaddr_in &from,
|
||||
UdpMsg *msg)
|
||||
{
|
||||
if (!_udp) {
|
||||
return false;
|
||||
}
|
||||
if (_peer_addr.sin_addr.s_addr == 0)
|
||||
{
|
||||
_peer_addr.sin_addr.s_addr = from.sin_addr.s_addr;
|
||||
_peer_addr.sin_port = from.sin_port;
|
||||
return true;
|
||||
}
|
||||
return _peer_addr.sin_addr.s_addr == from.sin_addr.s_addr &&
|
||||
_peer_addr.sin_port == from.sin_port;
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::OnMsg(UdpMsg *msg, int len)
|
||||
{
|
||||
bool handled = false;
|
||||
typedef bool (UdpProtocol::*DispatchFn)(UdpMsg *msg, int len);
|
||||
static const DispatchFn table[] = {
|
||||
&UdpProtocol::OnInvalid, /* Invalid */
|
||||
&UdpProtocol::OnSyncRequest, /* SyncRequest */
|
||||
&UdpProtocol::OnSyncReply, /* SyncReply */
|
||||
&UdpProtocol::OnInput, /* Input */
|
||||
&UdpProtocol::OnQualityReport, /* QualityReport */
|
||||
&UdpProtocol::OnQualityReply, /* QualityReply */
|
||||
&UdpProtocol::OnKeepAlive, /* KeepAlive */
|
||||
&UdpProtocol::OnInputAck, /* InputAck */
|
||||
&UdpProtocol::OnAppData, /* AppData */
|
||||
};
|
||||
|
||||
// filter out messages that don't match what we expect
|
||||
uint16 seq = msg->hdr.sequence_number;
|
||||
if (msg->hdr.type != UdpMsg::SyncRequest &&
|
||||
msg->hdr.type != UdpMsg::SyncReply) {
|
||||
if (msg->hdr.magic != _remote_magic_number) {
|
||||
LogMsg("recv rejecting", msg);
|
||||
return;
|
||||
}
|
||||
|
||||
// filter out out-of-order packets
|
||||
uint16 skipped = (uint16)((int)seq - (int)_next_recv_seq);
|
||||
// Log("udpproto%d | checking sequence number -> next - seq : %d - %d = %d", _queue, seq, _next_recv_seq, skipped);
|
||||
if (skipped > MAX_SEQ_DISTANCE) {
|
||||
Log("udpproto%d | dropping out of order packet (seq: %d, last seq:%d)", _queue, seq, _next_recv_seq);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
_next_recv_seq = seq;
|
||||
LogMsg("recv", msg);
|
||||
if (msg->hdr.type >= ARRAY_SIZE(table)) {
|
||||
OnInvalid(msg, len);
|
||||
} else {
|
||||
handled = (this->*(table[msg->hdr.type]))(msg, len);
|
||||
}
|
||||
if (handled) {
|
||||
_last_recv_time = GGPOPlatform::GetCurrentTimeMS();
|
||||
if (_disconnect_notify_sent && _current_state == Running) {
|
||||
QueueEvent(Event(Event::NetworkResumed));
|
||||
_disconnect_notify_sent = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::UpdateNetworkStats(void)
|
||||
{
|
||||
int now = GGPOPlatform::GetCurrentTimeMS();
|
||||
|
||||
if (_stats_start_time == 0) {
|
||||
_stats_start_time = now;
|
||||
}
|
||||
|
||||
int total_bytes_sent = _bytes_sent + (UDP_HEADER_SIZE * _packets_sent);
|
||||
float seconds = (float)((now - _stats_start_time) / 1000.0);
|
||||
float Bps = total_bytes_sent / seconds;
|
||||
float udp_overhead = (float)(100.0 * (UDP_HEADER_SIZE * _packets_sent) / _bytes_sent);
|
||||
|
||||
_kbps_sent = int(Bps / 1024);
|
||||
|
||||
Log("udpproto%d | Network Stats -- Bandwidth: %.2f KBps Packets Sent: %5d (%.2f pps) "
|
||||
"KB Sent: %.2f UDP Overhead: %.2f %%.", _queue,
|
||||
(float)_kbps_sent,
|
||||
_packets_sent,
|
||||
(float)_packets_sent * 1000 / (now - _stats_start_time),
|
||||
total_bytes_sent / 1024.0,
|
||||
udp_overhead);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
UdpProtocol::QueueEvent(const UdpProtocol::Event &evt)
|
||||
{
|
||||
LogEvent("Queuing event", evt);
|
||||
_event_queue.push(evt);
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::Synchronize()
|
||||
{
|
||||
if (_udp) {
|
||||
_current_state = Syncing;
|
||||
_state.sync.roundtrips_remaining = NUM_SYNC_PACKETS;
|
||||
if (_peer_addr.sin_addr.s_addr != 0)
|
||||
SendSyncRequest();
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
UdpProtocol::GetPeerConnectStatus(int id, int *frame)
|
||||
{
|
||||
*frame = _peer_connect_status[id].last_frame;
|
||||
return !_peer_connect_status[id].disconnected;
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::LogMsg(const char *prefix, UdpMsg *msg)
|
||||
{
|
||||
switch (msg->hdr.type) {
|
||||
case UdpMsg::SyncRequest:
|
||||
Log("udpproto%d | %s sync-request (%d).", _queue, prefix,
|
||||
msg->u.sync_request.random_request);
|
||||
break;
|
||||
case UdpMsg::SyncReply:
|
||||
Log("udpproto%d | %s sync-reply (%d).", _queue, prefix,
|
||||
msg->u.sync_reply.random_reply);
|
||||
break;
|
||||
case UdpMsg::QualityReport:
|
||||
Log("udpproto%d | %s quality report.", _queue, prefix);
|
||||
break;
|
||||
case UdpMsg::QualityReply:
|
||||
Log("udpproto%d | %s quality reply.", _queue, prefix);
|
||||
break;
|
||||
case UdpMsg::KeepAlive:
|
||||
Log("udpproto%d | %s keep alive.", _queue, prefix);
|
||||
break;
|
||||
case UdpMsg::Input:
|
||||
Log("udpproto%d | %s game-compressed-input %d (+ %d bits).", _queue, prefix, msg->u.input.start_frame, msg->u.input.num_bits);
|
||||
break;
|
||||
case UdpMsg::InputAck:
|
||||
Log("udpproto%d | %s input ack.", _queue, prefix);
|
||||
break;
|
||||
case UdpMsg::AppData:
|
||||
Log("udpproto%d | %s app data (%d bytes).", _queue, prefix, msg->u.app_data.size);
|
||||
break;
|
||||
default:
|
||||
ASSERT(false && "Unknown UdpMsg type.");
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::LogEvent(const char *prefix, const UdpProtocol::Event &evt)
|
||||
{
|
||||
if (evt.type == UdpProtocol::Event::Synchronzied)
|
||||
Log("udpproto%d | %s (event: Synchronized).", _queue, prefix);
|
||||
}
|
||||
|
||||
bool
|
||||
UdpProtocol::OnInvalid(UdpMsg *msg, int len)
|
||||
{
|
||||
ASSERT(false && "Invalid msg in UdpProtocol");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
UdpProtocol::OnSyncRequest(UdpMsg *msg, int len)
|
||||
{
|
||||
if (_remote_magic_number != 0 && msg->hdr.magic != _remote_magic_number) {
|
||||
Log("udpproto%d | Ignoring sync request from unknown endpoint (%d != %d).", _queue,
|
||||
msg->hdr.magic, _remote_magic_number);
|
||||
return false;
|
||||
}
|
||||
UdpMsg *reply = new UdpMsg(UdpMsg::SyncReply);
|
||||
reply->u.sync_reply.random_reply = msg->u.sync_request.random_request;
|
||||
// Calculate incoming verif data size
|
||||
msg->verification_size = 0;
|
||||
int msgVerifSize = len - msg->PacketSize();
|
||||
if (msgVerifSize != (int)verification.size()
|
||||
|| (msgVerifSize != 0 && memcmp(&msg->u.sync_request.verification[0], &verification[0], msgVerifSize)))
|
||||
{
|
||||
Log("udpproto%d | Verification mismatch: size received %d expected %d", _queue, msgVerifSize, (int)verification.size());
|
||||
reply->u.sync_reply.verification_failure = 1;
|
||||
SendMsg(reply);
|
||||
throw GGPOException("Verification mismatch", GGPO_ERRORCODE_VERIFICATION_ERROR);
|
||||
}
|
||||
// FIXME
|
||||
if (_state.sync.roundtrips_remaining == NUM_SYNC_PACKETS && msg->hdr.sequence_number == 0) {
|
||||
Log("udpproto%d | Sync request 0 received... Re-queueing sync packet.", _queue);
|
||||
SendSyncRequest();
|
||||
}
|
||||
|
||||
reply->u.sync_reply.verification_failure = 0;
|
||||
SendMsg(reply);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
UdpProtocol::OnSyncReply(UdpMsg *msg, int len)
|
||||
{
|
||||
if (_current_state != Syncing) {
|
||||
Log("udpproto%d | Ignoring SyncReply while not synching.", _queue);
|
||||
return msg->hdr.magic == _remote_magic_number;
|
||||
}
|
||||
|
||||
if (msg->u.sync_reply.random_reply != _state.sync.random) {
|
||||
Log("udpproto%d | sync reply %d != %d. Keep looking...", _queue,
|
||||
msg->u.sync_reply.random_reply, _state.sync.random);
|
||||
return false;
|
||||
}
|
||||
if (msg->u.sync_reply.verification_failure == 1)
|
||||
throw GGPOException("Peer reported verification failure", GGPO_ERRORCODE_VERIFICATION_ERROR);
|
||||
|
||||
if (!_connected) {
|
||||
QueueEvent(Event(Event::Connected));
|
||||
_connected = true;
|
||||
}
|
||||
|
||||
Log("udpproto%d | Checking sync state (%d round trips remaining).", _queue, _state.sync.roundtrips_remaining);
|
||||
if (--_state.sync.roundtrips_remaining == 0) {
|
||||
Log("udpproto%d | Synchronized!", _queue);
|
||||
QueueEvent(UdpProtocol::Event(UdpProtocol::Event::Synchronzied));
|
||||
_current_state = Running;
|
||||
_last_received_input.frame = -1;
|
||||
_remote_magic_number = msg->hdr.magic;
|
||||
} else {
|
||||
UdpProtocol::Event evt(UdpProtocol::Event::Synchronizing);
|
||||
evt.u.synchronizing.total = NUM_SYNC_PACKETS;
|
||||
evt.u.synchronizing.count = NUM_SYNC_PACKETS - _state.sync.roundtrips_remaining;
|
||||
QueueEvent(evt);
|
||||
SendSyncRequest();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
UdpProtocol::OnInput(UdpMsg *msg, int len)
|
||||
{
|
||||
/*
|
||||
* If a disconnect is requested, go ahead and disconnect now.
|
||||
*/
|
||||
bool disconnect_requested = msg->u.input.disconnect_requested;
|
||||
if (disconnect_requested) {
|
||||
if (_current_state != Disconnected && !_disconnect_event_sent) {
|
||||
Log("udpproto%d | Disconnecting endpoint on remote request.", _queue);
|
||||
QueueEvent(Event(Event::Disconnected));
|
||||
_disconnect_event_sent = true;
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* Update the peer connection status if this peer is still considered to be part
|
||||
* of the network.
|
||||
*/
|
||||
UdpMsg::connect_status* remote_status = msg->u.input.peer_connect_status;
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(_peer_connect_status); i++) {
|
||||
ASSERT(remote_status[i].last_frame >= _peer_connect_status[i].last_frame);
|
||||
_peer_connect_status[i].disconnected = _peer_connect_status[i].disconnected || remote_status[i].disconnected;
|
||||
_peer_connect_status[i].last_frame = MAX(_peer_connect_status[i].last_frame, remote_status[i].last_frame);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Decompress the input.
|
||||
*/
|
||||
int last_received_frame_number = _last_received_input.frame;
|
||||
if (msg->u.input.num_bits) {
|
||||
int offset = 0;
|
||||
uint8 *bits = (uint8 *)msg->u.input.bits;
|
||||
int numBits = msg->u.input.num_bits;
|
||||
int currentFrame = msg->u.input.start_frame;
|
||||
|
||||
_last_received_input.size = msg->u.input.input_size;
|
||||
if (_last_received_input.frame < 0) {
|
||||
_last_received_input.frame = msg->u.input.start_frame - 1;
|
||||
}
|
||||
while (offset < numBits) {
|
||||
/*
|
||||
* Keep walking through the frames (parsing bits) until we reach
|
||||
* the inputs for the frame right after the one we're on.
|
||||
*/
|
||||
ASSERT(currentFrame <= (_last_received_input.frame + 1));
|
||||
bool useInputs = currentFrame == _last_received_input.frame + 1;
|
||||
|
||||
while (BitVector_ReadBit(bits, &offset)) {
|
||||
int on = BitVector_ReadBit(bits, &offset);
|
||||
int button = BitVector_ReadNibblet(bits, &offset);
|
||||
if (useInputs) {
|
||||
if (on) {
|
||||
_last_received_input.set(button);
|
||||
} else {
|
||||
_last_received_input.clear(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
ASSERT(offset <= numBits);
|
||||
|
||||
/*
|
||||
* Now if we want to use these inputs, go ahead and send them to
|
||||
* the emulator.
|
||||
*/
|
||||
if (useInputs) {
|
||||
/*
|
||||
* Move forward 1 frame in the stream.
|
||||
*/
|
||||
char desc[1024];
|
||||
ASSERT(currentFrame == _last_received_input.frame + 1);
|
||||
_last_received_input.frame = currentFrame;
|
||||
|
||||
/*
|
||||
* Send the event to the emulator
|
||||
*/
|
||||
UdpProtocol::Event evt(UdpProtocol::Event::Input);
|
||||
evt.u.input.input = _last_received_input;
|
||||
|
||||
if (LogTypes::LDEBUG <= MAX_LOGLEVEL)
|
||||
_last_received_input.desc(desc, ARRAY_SIZE(desc));
|
||||
|
||||
_state.running.last_input_packet_recv_time = GGPOPlatform::GetCurrentTimeMS();
|
||||
|
||||
Log("udpproto%d | Sending frame %d to emu queue %d (%s).", _queue, _last_received_input.frame, _queue, desc);
|
||||
QueueEvent(evt);
|
||||
|
||||
} else {
|
||||
Log("udpproto%d | Skipping past frame:(%d) current is %d.", _queue, currentFrame, _last_received_input.frame);
|
||||
}
|
||||
|
||||
/*
|
||||
* Move forward 1 frame in the input stream.
|
||||
*/
|
||||
currentFrame++;
|
||||
}
|
||||
}
|
||||
ASSERT(_last_received_input.frame >= last_received_frame_number);
|
||||
|
||||
/*
|
||||
* Get rid of our buffered input
|
||||
*/
|
||||
while (_pending_output.size() && _pending_output.front().frame < msg->u.input.ack_frame) {
|
||||
Log("udpproto%d | Throwing away pending output frame %d", _queue, _pending_output.front().frame);
|
||||
_last_acked_input = _pending_output.front();
|
||||
_pending_output.pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
UdpProtocol::OnInputAck(UdpMsg *msg, int len)
|
||||
{
|
||||
/*
|
||||
* Get rid of our buffered input
|
||||
*/
|
||||
while (_pending_output.size() && _pending_output.front().frame < msg->u.input_ack.ack_frame) {
|
||||
Log("udpproto%d | Throwing away pending output frame %d", _queue, _pending_output.front().frame);
|
||||
_last_acked_input = _pending_output.front();
|
||||
_pending_output.pop();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
UdpProtocol::OnQualityReport(UdpMsg *msg, int len)
|
||||
{
|
||||
// send a reply so the other side can compute the round trip transmit time.
|
||||
UdpMsg *reply = new UdpMsg(UdpMsg::QualityReply);
|
||||
reply->u.quality_reply.pong = msg->u.quality_report.ping;
|
||||
SendMsg(reply);
|
||||
|
||||
_remote_frame_advantage = msg->u.quality_report.frame_advantage;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
UdpProtocol::OnQualityReply(UdpMsg *msg, int len)
|
||||
{
|
||||
_round_trip_time = GGPOPlatform::GetCurrentTimeMS() - msg->u.quality_reply.pong;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
UdpProtocol::OnKeepAlive(UdpMsg *msg, int len)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::GetNetworkStats(struct GGPONetworkStats *s)
|
||||
{
|
||||
s->network.ping = _round_trip_time;
|
||||
s->network.send_queue_len = _pending_output.size();
|
||||
s->network.kbps_sent = _kbps_sent;
|
||||
s->timesync.remote_frames_behind = _remote_frame_advantage;
|
||||
s->timesync.local_frames_behind = _local_frame_advantage;
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::SetLocalFrameNumber(int localFrame)
|
||||
{
|
||||
/*
|
||||
* Estimate which frame the other guy is one by looking at the
|
||||
* last frame they gave us plus some delta for the one-way packet
|
||||
* trip time.
|
||||
*/
|
||||
int remoteFrame = _last_received_input.frame + (_round_trip_time * 60 / 1000);
|
||||
|
||||
/*
|
||||
* Our frame advantage is how many frames *behind* the other guy
|
||||
* we are. Counter-intuative, I know. It's an advantage because
|
||||
* it means they'll have to predict more often and our moves will
|
||||
* pop more frequenetly.
|
||||
*/
|
||||
_local_frame_advantage = remoteFrame - localFrame;
|
||||
}
|
||||
|
||||
int
|
||||
UdpProtocol::RecommendFrameDelay()
|
||||
{
|
||||
// XXX: require idle input should be a configuration parameter
|
||||
return _timesync.recommend_frame_wait_duration(false);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
UdpProtocol::SetDisconnectTimeout(int timeout)
|
||||
{
|
||||
_disconnect_timeout = timeout;
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::SetDisconnectNotifyStart(int timeout)
|
||||
{
|
||||
_disconnect_notify_start = timeout;
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::PumpSendQueue()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_send_mutex);
|
||||
while (!_send_queue.empty()) {
|
||||
QueueEntry &entry = _send_queue.front();
|
||||
|
||||
if (_send_latency) {
|
||||
// should really come up with a gaussian distributation based on the configured
|
||||
// value, but this will do for now.
|
||||
int jitter = (_send_latency * 2 / 3) + ((rand() % _send_latency) / 3);
|
||||
if ((int)GGPOPlatform::GetCurrentTimeMS() < _send_queue.front().queue_time + jitter) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (_oop_percent && !_oo_packet.msg && ((rand() % 100) < _oop_percent)) {
|
||||
int delay = rand() % (_send_latency * 10 + 1000);
|
||||
Log("udpproto%d | creating rogue oop (seq: %d delay: %d)", _queue, entry.msg->hdr.sequence_number, delay);
|
||||
_oo_packet.send_time = GGPOPlatform::GetCurrentTimeMS() + delay;
|
||||
_oo_packet.msg = entry.msg;
|
||||
_oo_packet.dest_addr = entry.dest_addr;
|
||||
} else {
|
||||
ASSERT(entry.dest_addr.sin_addr.s_addr);
|
||||
|
||||
_udp->SendTo((char *)entry.msg, entry.msg->PacketSize(), 0,
|
||||
(struct sockaddr *)&entry.dest_addr, sizeof entry.dest_addr);
|
||||
|
||||
delete entry.msg;
|
||||
}
|
||||
_send_queue.pop();
|
||||
}
|
||||
if (_oo_packet.msg && _oo_packet.send_time < (int)GGPOPlatform::GetCurrentTimeMS()) {
|
||||
Log("udpproto%d | sending rogue oop!", _queue);
|
||||
_udp->SendTo((char *)_oo_packet.msg, _oo_packet.msg->PacketSize(), 0,
|
||||
(struct sockaddr *)&_oo_packet.dest_addr, sizeof _oo_packet.dest_addr);
|
||||
|
||||
delete _oo_packet.msg;
|
||||
_oo_packet.msg = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
UdpProtocol::ClearSendQueue()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(_send_mutex);
|
||||
while (!_send_queue.empty()) {
|
||||
delete _send_queue.front().msg;
|
||||
_send_queue.pop();
|
||||
}
|
||||
}
|
||||
|
||||
void UdpProtocol::SendAppData(const void *data, int len, bool spectators)
|
||||
{
|
||||
if (_udp == nullptr)
|
||||
return;
|
||||
if (_current_state != Synchronzied && _current_state != Running)
|
||||
return;
|
||||
|
||||
UdpMsg *msg = new UdpMsg(UdpMsg::AppData);
|
||||
msg->u.app_data.spectators = spectators;
|
||||
msg->u.app_data.size = len;
|
||||
memcpy(msg->u.app_data.data, data, len);
|
||||
|
||||
SendMsg(msg);
|
||||
}
|
||||
|
||||
bool UdpProtocol::OnAppData(UdpMsg *msg, int len)
|
||||
{
|
||||
UdpProtocol::Event evt(UdpProtocol::Event::AppData);
|
||||
evt.u.app_data.spectators = msg->u.app_data.spectators != 0;
|
||||
evt.u.app_data.size = msg->u.app_data.size;
|
||||
memcpy(evt.u.app_data.data, msg->u.app_data.data, msg->u.app_data.size);
|
||||
QueueEvent(evt);
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,223 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _UDP_PROTO_H_
|
||||
#define _UDP_PROTO_H_
|
||||
|
||||
#include "ggpo_poll.h"
|
||||
#include "udp.h"
|
||||
#include "udp_msg.h"
|
||||
#include "game_input.h"
|
||||
#include "timesync.h"
|
||||
#include "ggponet.h"
|
||||
#include "ring_buffer.h"
|
||||
#include <vector>
|
||||
#include <mutex>
|
||||
|
||||
class UdpProtocol : public IPollSink
|
||||
{
|
||||
public:
|
||||
struct Stats {
|
||||
int ping;
|
||||
int remote_frame_advantage;
|
||||
int local_frame_advantage;
|
||||
int send_queue_len;
|
||||
Udp::Stats udp;
|
||||
};
|
||||
|
||||
struct Event {
|
||||
enum Type {
|
||||
Unknown = -1,
|
||||
Connected,
|
||||
Synchronizing,
|
||||
Synchronzied,
|
||||
Input,
|
||||
Disconnected,
|
||||
NetworkInterrupted,
|
||||
NetworkResumed,
|
||||
AppData,
|
||||
};
|
||||
|
||||
Type type;
|
||||
union {
|
||||
struct {
|
||||
GameInput input;
|
||||
} input;
|
||||
struct {
|
||||
int total;
|
||||
int count;
|
||||
} synchronizing;
|
||||
struct {
|
||||
int disconnect_timeout;
|
||||
} network_interrupted;
|
||||
struct {
|
||||
bool spectators;
|
||||
int size;
|
||||
uint8 data[MAX_APPDATA_SIZE];
|
||||
} app_data;
|
||||
} u;
|
||||
|
||||
Event(Type t = Unknown) : type(t) { }
|
||||
};
|
||||
|
||||
public:
|
||||
virtual bool OnLoopPoll(void *cookie);
|
||||
|
||||
public:
|
||||
UdpProtocol();
|
||||
virtual ~UdpProtocol();
|
||||
|
||||
void Init(Udp *udp, Poll &p, int queue, char *ip, u_short port, UdpMsg::connect_status *status);
|
||||
|
||||
void Synchronize();
|
||||
bool GetPeerConnectStatus(int id, int *frame);
|
||||
bool IsInitialized() { return _udp != NULL; }
|
||||
bool IsSynchronized() { return _current_state == Running; }
|
||||
bool IsRunning() { return _current_state == Running; }
|
||||
void SendInput(GameInput &input);
|
||||
void SendInputAck();
|
||||
bool HandlesMsg(sockaddr_in &from, UdpMsg *msg);
|
||||
void OnMsg(UdpMsg *msg, int len);
|
||||
void Disconnect();
|
||||
void SendAppData(const void *data, int len, bool spectators);
|
||||
|
||||
void GetNetworkStats(struct GGPONetworkStats *stats);
|
||||
bool GetEvent(UdpProtocol::Event &e);
|
||||
void GGPONetworkStats(Stats *stats);
|
||||
void SetLocalFrameNumber(int num);
|
||||
int RecommendFrameDelay();
|
||||
void SetVerificationData(const void *verification, int verification_size) {
|
||||
ASSERT(verification_size <= MAX_VERIFICATION_SIZE);
|
||||
this->verification.resize(verification_size);
|
||||
memcpy(&this->verification[0], verification, verification_size);
|
||||
}
|
||||
|
||||
void SetDisconnectTimeout(int timeout);
|
||||
void SetDisconnectNotifyStart(int timeout);
|
||||
|
||||
protected:
|
||||
enum State {
|
||||
Syncing,
|
||||
Synchronzied,
|
||||
Running,
|
||||
Disconnected
|
||||
};
|
||||
struct QueueEntry {
|
||||
int queue_time;
|
||||
sockaddr_in dest_addr;
|
||||
UdpMsg *msg;
|
||||
|
||||
QueueEntry() {}
|
||||
QueueEntry(int time, sockaddr_in &dst, UdpMsg *m) : queue_time(time), dest_addr(dst), msg(m) { }
|
||||
};
|
||||
|
||||
bool CreateSocket(int retries);
|
||||
void UpdateNetworkStats(void);
|
||||
void QueueEvent(const UdpProtocol::Event &evt);
|
||||
void ClearSendQueue(void);
|
||||
void LogMsg(const char *prefix, UdpMsg *msg);
|
||||
void LogEvent(const char *prefix, const UdpProtocol::Event &evt);
|
||||
void SendSyncRequest();
|
||||
void SendMsg(UdpMsg *msg);
|
||||
void PumpSendQueue();
|
||||
void SendPendingOutput();
|
||||
bool OnInvalid(UdpMsg *msg, int len);
|
||||
bool OnSyncRequest(UdpMsg *msg, int len);
|
||||
bool OnSyncReply(UdpMsg *msg, int len);
|
||||
bool OnInput(UdpMsg *msg, int len);
|
||||
bool OnInputAck(UdpMsg *msg, int len);
|
||||
bool OnQualityReport(UdpMsg *msg, int len);
|
||||
bool OnQualityReply(UdpMsg *msg, int len);
|
||||
bool OnKeepAlive(UdpMsg *msg, int len);
|
||||
bool OnAppData(UdpMsg *msg, int len);
|
||||
|
||||
protected:
|
||||
/*
|
||||
* Network transmission information
|
||||
*/
|
||||
Udp *_udp;
|
||||
sockaddr_in _peer_addr;
|
||||
uint16 _magic_number;
|
||||
int _queue;
|
||||
uint16 _remote_magic_number;
|
||||
bool _connected;
|
||||
int _send_latency;
|
||||
int _oop_percent;
|
||||
struct {
|
||||
int send_time;
|
||||
sockaddr_in dest_addr;
|
||||
UdpMsg* msg;
|
||||
} _oo_packet;
|
||||
RingBuffer<QueueEntry, 64> _send_queue;
|
||||
std::mutex _send_mutex;
|
||||
|
||||
std::vector<uint8> verification;
|
||||
|
||||
/*
|
||||
* Stats
|
||||
*/
|
||||
int _round_trip_time;
|
||||
int _packets_sent;
|
||||
int _bytes_sent;
|
||||
int _kbps_sent;
|
||||
int _stats_start_time;
|
||||
|
||||
/*
|
||||
* The state machine
|
||||
*/
|
||||
UdpMsg::connect_status *_local_connect_status;
|
||||
UdpMsg::connect_status _peer_connect_status[UDP_MSG_MAX_PLAYERS];
|
||||
|
||||
State _current_state;
|
||||
union {
|
||||
struct {
|
||||
uint32 roundtrips_remaining;
|
||||
uint32 random;
|
||||
} sync;
|
||||
struct {
|
||||
uint32 last_quality_report_time;
|
||||
uint32 last_network_stats_interval;
|
||||
uint32 last_input_packet_recv_time;
|
||||
} running;
|
||||
} _state;
|
||||
|
||||
/*
|
||||
* Fairness.
|
||||
*/
|
||||
int _local_frame_advantage;
|
||||
int _remote_frame_advantage;
|
||||
|
||||
/*
|
||||
* Packet loss...
|
||||
*/
|
||||
RingBuffer<GameInput, 64> _pending_output;
|
||||
GameInput _last_received_input;
|
||||
GameInput _last_sent_input;
|
||||
GameInput _last_acked_input;
|
||||
unsigned int _last_send_time;
|
||||
unsigned int _last_recv_time;
|
||||
unsigned int _shutdown_timeout;
|
||||
unsigned int _disconnect_event_sent;
|
||||
unsigned int _disconnect_timeout;
|
||||
unsigned int _disconnect_notify_start;
|
||||
bool _disconnect_notify_sent;
|
||||
|
||||
uint16 _next_send_seq;
|
||||
uint16 _next_recv_seq;
|
||||
|
||||
/*
|
||||
* Rift synchronization.
|
||||
*/
|
||||
TimeSync _timesync;
|
||||
|
||||
/*
|
||||
* Event queue
|
||||
*/
|
||||
RingBuffer<UdpProtocol::Event, 64> _event_queue;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,38 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
#if defined(__unix__) || defined(__APPLE__) || defined(__SWITCH__)
|
||||
|
||||
#include "platform_linux.h"
|
||||
#include <time.h>
|
||||
#include <strings.h>
|
||||
#include <chrono>
|
||||
|
||||
uint32_t GGPOPlatform::GetCurrentTimeMS()
|
||||
{
|
||||
using namespace std::chrono;
|
||||
static steady_clock::time_point startTime = steady_clock::now();
|
||||
|
||||
return (uint32_t)duration_cast<milliseconds>(steady_clock::now() - startTime).count();
|
||||
}
|
||||
|
||||
int GGPOPlatform::GetConfigInt(const char* name)
|
||||
{
|
||||
char *buf = getenv(name);
|
||||
if (buf == nullptr)
|
||||
return 0;
|
||||
return atoi(buf);
|
||||
}
|
||||
|
||||
bool GGPOPlatform::GetConfigBool(const char* name)
|
||||
{
|
||||
char *buf = getenv(name);
|
||||
if (buf == nullptr)
|
||||
return false;
|
||||
return atoi(buf) != 0 || strcasecmp(buf, "true") == 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,69 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _GGPO_LINUX_H_
|
||||
#define _GGPO_LINUX_H_
|
||||
|
||||
#include <limits>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <cstdint>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#ifdef __SWITCH__
|
||||
#include "nswitch.h"
|
||||
#else
|
||||
#include <netinet/ip.h>
|
||||
#endif
|
||||
#include <netinet/tcp.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
using SOCKET = int;
|
||||
#define closesocket close
|
||||
#define INVALID_SOCKET (-1)
|
||||
#define SOCKET_ERROR (-1)
|
||||
#define WSAEWOULDBLOCK EWOULDBLOCK
|
||||
|
||||
constexpr size_t MAX_PATH = 4096;
|
||||
#ifdef INT_MAX
|
||||
#undef INT_MAX
|
||||
#endif
|
||||
constexpr int INT_MAX = std::numeric_limits<int>::max();
|
||||
|
||||
class GGPOPlatform {
|
||||
public: // types
|
||||
typedef pid_t ProcessID;
|
||||
|
||||
public: // functions
|
||||
static ProcessID GetProcessID() { return getpid(); }
|
||||
static void AssertFailed(char *msg) { fprintf(stderr, "%s", msg); }
|
||||
static uint32_t GetCurrentTimeMS();
|
||||
static int GetConfigInt(const char* name);
|
||||
static bool GetConfigBool(const char* name);
|
||||
};
|
||||
|
||||
extern "C" {
|
||||
|
||||
inline static void DebugBreak()
|
||||
{
|
||||
__builtin_trap();
|
||||
}
|
||||
|
||||
inline static int WSAGetLastError() {
|
||||
return errno;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,28 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
#include "platform_windows.h"
|
||||
|
||||
int
|
||||
GGPOPlatform::GetConfigInt(const char* name)
|
||||
{
|
||||
char buf[1024];
|
||||
if (GetEnvironmentVariableA(name, buf, ARRAY_SIZE(buf)) == 0) {
|
||||
return 0;
|
||||
}
|
||||
return atoi(buf);
|
||||
}
|
||||
|
||||
bool GGPOPlatform::GetConfigBool(const char* name)
|
||||
{
|
||||
char buf[1024];
|
||||
if (GetEnvironmentVariableA(name, buf, ARRAY_SIZE(buf)) == 0) {
|
||||
return false;
|
||||
}
|
||||
return atoi(buf) != 0 || _stricmp(buf, "true") == 0;
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,44 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _GGPO_WINDOWS_H_
|
||||
#define _GGPO_WINDOWS_H_
|
||||
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <chrono>
|
||||
|
||||
#include "ggpo_types.h"
|
||||
|
||||
class GGPOPlatform {
|
||||
public: // types
|
||||
typedef DWORD ProcessID;
|
||||
|
||||
public: // functions
|
||||
static ProcessID GetProcessID() { return GetCurrentProcessId(); }
|
||||
static void AssertFailed(char *msg) {
|
||||
#ifndef TARGET_UWP
|
||||
MessageBoxA(NULL, msg, "GGPO Assertion Failed", MB_OK | MB_ICONEXCLAMATION);
|
||||
#endif
|
||||
}
|
||||
static uint32 GetCurrentTimeMS() {
|
||||
#ifdef TARGET_UWP
|
||||
using namespace std::chrono;
|
||||
static steady_clock::time_point startTime = steady_clock::now();
|
||||
|
||||
return (uint32_t)duration_cast<milliseconds>(steady_clock::now() - startTime).count();
|
||||
#else
|
||||
return timeGetTime();
|
||||
#endif
|
||||
}
|
||||
static int GetConfigInt(const char* name);
|
||||
static bool GetConfigBool(const char* name);
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,127 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "ggpo_poll.h"
|
||||
#include "ggpo_types.h"
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
constexpr int INFINITE = -1;
|
||||
#endif
|
||||
|
||||
Poll::Poll(void) :
|
||||
_start_time(0),
|
||||
_handle_count(0)
|
||||
{
|
||||
/*
|
||||
* Create a dummy handle to simplify things.
|
||||
*/
|
||||
#ifdef _WIN32
|
||||
_handles[_handle_count++] = CreateEvent(NULL, true, false, NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
void
|
||||
Poll::RegisterHandle(IPollSink *sink, HANDLE h, void *cookie)
|
||||
{
|
||||
ASSERT(_handle_count < MAX_POLLABLE_HANDLES - 1);
|
||||
|
||||
_handles[_handle_count] = h;
|
||||
_handle_sinks[_handle_count] = PollSinkCb(sink, cookie);
|
||||
_handle_count++;
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
Poll::RegisterMsgLoop(IPollSink *sink, void *cookie)
|
||||
{
|
||||
_msg_sinks.push_back(PollSinkCb(sink, cookie));
|
||||
}
|
||||
|
||||
void
|
||||
Poll::RegisterLoop(IPollSink *sink, void *cookie)
|
||||
{
|
||||
_loop_sinks.push_back(PollSinkCb(sink, cookie));
|
||||
}
|
||||
void
|
||||
Poll::RegisterPeriodic(IPollSink *sink, int interval, void *cookie)
|
||||
{
|
||||
_periodic_sinks.push_back(PollPeriodicSinkCb(sink, cookie, interval));
|
||||
}
|
||||
|
||||
void
|
||||
Poll::Run()
|
||||
{
|
||||
while (Pump(100)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Poll::Pump(int timeout)
|
||||
{
|
||||
int i;
|
||||
bool finished = false;
|
||||
|
||||
if (_start_time == 0) {
|
||||
_start_time = GGPOPlatform::GetCurrentTimeMS();
|
||||
}
|
||||
int elapsed = GGPOPlatform::GetCurrentTimeMS() - _start_time;
|
||||
int maxwait = ComputeWaitTime(elapsed);
|
||||
if (maxwait != INFINITE) {
|
||||
timeout = MIN(timeout, maxwait);
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
DWORD res = WaitForMultipleObjects(_handle_count, _handles, false, timeout);
|
||||
if (res >= WAIT_OBJECT_0 && res < WAIT_OBJECT_0 + _handle_count) {
|
||||
i = res - WAIT_OBJECT_0;
|
||||
finished = !_handle_sinks[i].sink->OnHandlePoll(_handle_sinks[i].cookie) || finished;
|
||||
}
|
||||
#else
|
||||
if (timeout > 0)
|
||||
std::this_thread::sleep_for(std::chrono::milliseconds(timeout));
|
||||
#endif
|
||||
for (i = 0; i < _msg_sinks.size(); i++) {
|
||||
PollSinkCb &cb = _msg_sinks[i];
|
||||
finished = !cb.sink->OnMsgPoll(cb.cookie) || finished;
|
||||
}
|
||||
|
||||
for (i = 0; i < _periodic_sinks.size(); i++) {
|
||||
PollPeriodicSinkCb &cb = _periodic_sinks[i];
|
||||
if (cb.interval + cb.last_fired <= elapsed) {
|
||||
cb.last_fired = (elapsed / cb.interval) * cb.interval;
|
||||
finished = !cb.sink->OnPeriodicPoll(cb.cookie, cb.last_fired) || finished;
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < _loop_sinks.size(); i++) {
|
||||
PollSinkCb &cb = _loop_sinks[i];
|
||||
finished = !cb.sink->OnLoopPoll(cb.cookie) || finished;
|
||||
}
|
||||
return finished;
|
||||
}
|
||||
|
||||
int
|
||||
Poll::ComputeWaitTime(int elapsed)
|
||||
{
|
||||
int waitTime = INFINITE;
|
||||
size_t count = _periodic_sinks.size();
|
||||
|
||||
if (count > 0) {
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
PollPeriodicSinkCb &cb = _periodic_sinks[i];
|
||||
int timeout = (cb.interval + cb.last_fired) - elapsed;
|
||||
if (waitTime == INFINITE || (timeout < waitTime)) {
|
||||
waitTime = MAX(timeout, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
return waitTime;
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _RING_BUFFER_H
|
||||
#define _RING_BUFFER_H
|
||||
|
||||
#include "ggpo_types.h"
|
||||
|
||||
template<class T, int N> class RingBuffer
|
||||
{
|
||||
public:
|
||||
RingBuffer<T, N>() :
|
||||
_head(0),
|
||||
_tail(0),
|
||||
_size(0) {
|
||||
}
|
||||
|
||||
T &front() {
|
||||
ASSERT(_size != N);
|
||||
return _elements[_tail];
|
||||
}
|
||||
|
||||
T &item(int i) {
|
||||
ASSERT(i < _size);
|
||||
return _elements[(_tail + i) % N];
|
||||
}
|
||||
|
||||
void pop() {
|
||||
ASSERT(_size != N);
|
||||
_tail = (_tail + 1) % N;
|
||||
_size--;
|
||||
}
|
||||
|
||||
void push(const T &t) {
|
||||
ASSERT(_size != (N-1));
|
||||
_elements[_head] = t;
|
||||
_head = (_head + 1) % N;
|
||||
_size++;
|
||||
}
|
||||
|
||||
int size() {
|
||||
return _size;
|
||||
}
|
||||
|
||||
bool empty() {
|
||||
return _size == 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
T _elements[N];
|
||||
int _head;
|
||||
int _tail;
|
||||
int _size;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _STATIC_BUFFER_H
|
||||
#define _STATIC_BUFFER_H
|
||||
|
||||
#include "ggpo_types.h"
|
||||
|
||||
template<class T, int N> class StaticBuffer
|
||||
{
|
||||
public:
|
||||
StaticBuffer<T, N>() :
|
||||
_size(0) {
|
||||
}
|
||||
|
||||
T& operator[](int i) {
|
||||
ASSERT(i >= 0 && i < _size);
|
||||
return _elements[i];
|
||||
}
|
||||
|
||||
void push_back(const T &t) {
|
||||
ASSERT(_size != (N-1));
|
||||
_elements[_size++] = t;
|
||||
}
|
||||
|
||||
int size() {
|
||||
return _size;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
T _elements[N];
|
||||
int _size;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,304 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "sync.h"
|
||||
|
||||
Sync::Sync(UdpMsg::connect_status *connect_status) :
|
||||
_input_queues(NULL),
|
||||
_local_connect_status(connect_status)
|
||||
{
|
||||
_framecount = 0;
|
||||
_last_confirmed_frame = -1;
|
||||
_max_prediction_frames = 0;
|
||||
memset(&_savedstate, 0, sizeof(_savedstate));
|
||||
}
|
||||
|
||||
Sync::~Sync()
|
||||
{
|
||||
/*
|
||||
* Delete frames manually here rather than in a destructor of the SavedFrame
|
||||
* structure so we can efficently copy frames via weak references.
|
||||
*/
|
||||
for (size_t i = 0; i < ARRAY_SIZE(_savedstate.frames); i++) {
|
||||
_callbacks.free_buffer(_savedstate.frames[i].buf);
|
||||
}
|
||||
delete [] _input_queues;
|
||||
_input_queues = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
Sync::Init(Sync::Config &config)
|
||||
{
|
||||
_config = config;
|
||||
_callbacks = config.callbacks;
|
||||
_framecount = 0;
|
||||
_rollingback = false;
|
||||
|
||||
_max_prediction_frames = config.num_prediction_frames;
|
||||
|
||||
CreateQueues(config);
|
||||
}
|
||||
|
||||
void
|
||||
Sync::SetLastConfirmedFrame(int frame)
|
||||
{
|
||||
_last_confirmed_frame = frame;
|
||||
if (_last_confirmed_frame > 0) {
|
||||
for (int i = 0; i < _config.num_players; i++) {
|
||||
_input_queues[i].DiscardConfirmedFrames(frame - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
Sync::AddLocalInput(int queue, GameInput &input)
|
||||
{
|
||||
int frames_behind = _framecount - _last_confirmed_frame;
|
||||
if (_framecount >= _max_prediction_frames && frames_behind >= _max_prediction_frames) {
|
||||
Log("Rejecting input from emulator: reached prediction barrier.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_framecount == 0) {
|
||||
SaveCurrentFrame();
|
||||
}
|
||||
|
||||
Log("Sending undelayed local frame %d to queue %d.", _framecount, queue);
|
||||
input.frame = _framecount;
|
||||
_input_queues[queue].AddInput(input);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
Sync::AddRemoteInput(int queue, GameInput &input)
|
||||
{
|
||||
_input_queues[queue].AddInput(input);
|
||||
}
|
||||
|
||||
int
|
||||
Sync::GetConfirmedInputs(void *values, int size, int frame)
|
||||
{
|
||||
int disconnect_flags = 0;
|
||||
char *output = (char *)values;
|
||||
|
||||
ASSERT(size >= _config.num_players * _config.input_size);
|
||||
|
||||
memset(output, 0, size);
|
||||
for (int i = 0; i < _config.num_players; i++) {
|
||||
GameInput input;
|
||||
if (_local_connect_status[i].disconnected && frame > _local_connect_status[i].last_frame) {
|
||||
disconnect_flags |= (1 << i);
|
||||
input.erase();
|
||||
} else {
|
||||
_input_queues[i].GetConfirmedInput(frame, &input);
|
||||
}
|
||||
memcpy(output + (i * _config.input_size), input.bits, _config.input_size);
|
||||
}
|
||||
return disconnect_flags;
|
||||
}
|
||||
|
||||
int
|
||||
Sync::SynchronizeInputs(void *values, int size)
|
||||
{
|
||||
int disconnect_flags = 0;
|
||||
char *output = (char *)values;
|
||||
|
||||
ASSERT(size >= _config.num_players * _config.input_size);
|
||||
|
||||
memset(output, 0, size);
|
||||
for (int i = 0; i < _config.num_players; i++) {
|
||||
GameInput input;
|
||||
if (_local_connect_status[i].disconnected && _framecount > _local_connect_status[i].last_frame) {
|
||||
disconnect_flags |= (1 << i);
|
||||
input.erase();
|
||||
} else {
|
||||
_input_queues[i].GetInput(_framecount, &input);
|
||||
}
|
||||
memcpy(output + (i * _config.input_size), input.bits, _config.input_size);
|
||||
}
|
||||
return disconnect_flags;
|
||||
}
|
||||
|
||||
void
|
||||
Sync::CheckSimulation(int timeout)
|
||||
{
|
||||
int seek_to;
|
||||
if (!CheckSimulationConsistency(&seek_to)) {
|
||||
AdjustSimulation(seek_to);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Sync::IncrementFrame(void)
|
||||
{
|
||||
_framecount++;
|
||||
SaveCurrentFrame();
|
||||
}
|
||||
|
||||
void
|
||||
Sync::AdjustSimulation(int seek_to)
|
||||
{
|
||||
int framecount = _framecount;
|
||||
int count = _framecount - seek_to;
|
||||
|
||||
Log("Catching up");
|
||||
_rollingback = true;
|
||||
|
||||
/*
|
||||
* Flush our input queue and load the last frame.
|
||||
*/
|
||||
LoadFrame(seek_to);
|
||||
ASSERT(_framecount == seek_to);
|
||||
|
||||
/*
|
||||
* Advance frame by frame (stuffing notifications back to
|
||||
* the master).
|
||||
*/
|
||||
ResetPrediction(_framecount);
|
||||
for (int i = 0; i < count; i++) {
|
||||
_callbacks.advance_frame(0);
|
||||
}
|
||||
ASSERT(_framecount == framecount);
|
||||
|
||||
_rollingback = false;
|
||||
|
||||
Log("---");
|
||||
}
|
||||
|
||||
void
|
||||
Sync::LoadFrame(int frame)
|
||||
{
|
||||
// find the frame in question
|
||||
if (frame == _framecount) {
|
||||
Log("Skipping NOP.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Move the head pointer back and load it up
|
||||
_savedstate.head = FindSavedFrameIndex(frame);
|
||||
SavedFrame *state = _savedstate.frames + _savedstate.head;
|
||||
|
||||
Log("=== Loading frame info %d (size: %d checksum: %08x).",
|
||||
state->frame, state->cbuf, state->checksum);
|
||||
|
||||
ASSERT(state->buf && state->cbuf);
|
||||
_callbacks.load_game_state(state->buf, state->cbuf);
|
||||
|
||||
// Reset framecount and the head of the state ring-buffer to point in
|
||||
// advance of the current frame (as if we had just finished executing it).
|
||||
_framecount = state->frame;
|
||||
_savedstate.head = (_savedstate.head + 1) % ARRAY_SIZE(_savedstate.frames);
|
||||
}
|
||||
|
||||
void
|
||||
Sync::SaveCurrentFrame()
|
||||
{
|
||||
/*
|
||||
* See StateCompress for the real save feature implemented by FinalBurn.
|
||||
* Write everything into the head, then advance the head pointer.
|
||||
*/
|
||||
SavedFrame *state = _savedstate.frames + _savedstate.head;
|
||||
if (state->buf) {
|
||||
_callbacks.free_buffer(state->buf);
|
||||
state->buf = NULL;
|
||||
}
|
||||
state->frame = _framecount;
|
||||
_callbacks.save_game_state(&state->buf, &state->cbuf, &state->checksum, state->frame);
|
||||
|
||||
Log("=== Saved frame info %d (size: %d checksum: %08x).", state->frame, state->cbuf, state->checksum);
|
||||
_savedstate.head = (_savedstate.head + 1) % ARRAY_SIZE(_savedstate.frames);
|
||||
}
|
||||
|
||||
Sync::SavedFrame&
|
||||
Sync::GetLastSavedFrame()
|
||||
{
|
||||
int i = _savedstate.head - 1;
|
||||
if (i < 0) {
|
||||
i = ARRAY_SIZE(_savedstate.frames) - 1;
|
||||
}
|
||||
return _savedstate.frames[i];
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
Sync::FindSavedFrameIndex(int frame)
|
||||
{
|
||||
int i, count = ARRAY_SIZE(_savedstate.frames);
|
||||
for (i = 0; i < count; i++) {
|
||||
if (_savedstate.frames[i].frame == frame) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == count) {
|
||||
ASSERT(false);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Sync::CreateQueues(Config &config)
|
||||
{
|
||||
delete [] _input_queues;
|
||||
_input_queues = new InputQueue[_config.num_players];
|
||||
|
||||
for (int i = 0; i < _config.num_players; i++) {
|
||||
_input_queues[i].Init(i, _config.input_size);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
Sync::CheckSimulationConsistency(int *seekTo)
|
||||
{
|
||||
int first_incorrect = GameInput::NullFrame;
|
||||
for (int i = 0; i < _config.num_players; i++) {
|
||||
int incorrect = _input_queues[i].GetFirstIncorrectFrame();
|
||||
Log("considering incorrect frame %d reported by queue %d.", incorrect, i);
|
||||
|
||||
if (incorrect != GameInput::NullFrame && (first_incorrect == GameInput::NullFrame || incorrect < first_incorrect)) {
|
||||
first_incorrect = incorrect;
|
||||
}
|
||||
}
|
||||
|
||||
if (first_incorrect == GameInput::NullFrame) {
|
||||
Log("prediction ok. proceeding.");
|
||||
return true;
|
||||
}
|
||||
*seekTo = first_incorrect;
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
Sync::SetFrameDelay(int queue, int delay)
|
||||
{
|
||||
_input_queues[queue].SetFrameDelay(delay);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
Sync::ResetPrediction(int frameNumber)
|
||||
{
|
||||
for (int i = 0; i < _config.num_players; i++) {
|
||||
_input_queues[i].ResetPrediction(frameNumber);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
Sync::GetEvent(Event &e)
|
||||
{
|
||||
if (_event_queue.size()) {
|
||||
e = _event_queue.front();
|
||||
_event_queue.pop();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _SYNC_H
|
||||
#define _SYNC_H
|
||||
|
||||
#include "ggponet.h"
|
||||
#include "game_input.h"
|
||||
#include "ggpo_types.h"
|
||||
#include "input_queue.h"
|
||||
#include "ring_buffer.h"
|
||||
#include "network/udp_msg.h"
|
||||
|
||||
#define MAX_PREDICTION_FRAMES 8
|
||||
|
||||
class SyncTestBackend;
|
||||
|
||||
class Sync {
|
||||
public:
|
||||
struct Config {
|
||||
GGPOSessionCallbacks callbacks;
|
||||
int num_prediction_frames;
|
||||
int num_players;
|
||||
int input_size;
|
||||
};
|
||||
struct Event {
|
||||
enum {
|
||||
ConfirmedInput,
|
||||
} type;
|
||||
union {
|
||||
struct {
|
||||
GameInput input;
|
||||
} confirmedInput;
|
||||
} u;
|
||||
};
|
||||
|
||||
public:
|
||||
Sync(UdpMsg::connect_status *connect_status);
|
||||
virtual ~Sync();
|
||||
|
||||
void Init(Config &config);
|
||||
|
||||
void SetLastConfirmedFrame(int frame);
|
||||
void SetFrameDelay(int queue, int delay);
|
||||
bool AddLocalInput(int queue, GameInput &input);
|
||||
void AddRemoteInput(int queue, GameInput &input);
|
||||
int GetConfirmedInputs(void *values, int size, int frame);
|
||||
int SynchronizeInputs(void *values, int size);
|
||||
|
||||
void CheckSimulation(int timeout);
|
||||
void AdjustSimulation(int seek_to);
|
||||
void IncrementFrame(void);
|
||||
|
||||
int GetFrameCount() { return _framecount; }
|
||||
bool InRollback() { return _rollingback; }
|
||||
int GetPredictedFrames() { return _framecount - _last_confirmed_frame; }
|
||||
|
||||
bool GetEvent(Event &e);
|
||||
|
||||
protected:
|
||||
friend SyncTestBackend;
|
||||
|
||||
struct SavedFrame {
|
||||
byte *buf;
|
||||
int cbuf;
|
||||
int frame;
|
||||
int checksum;
|
||||
SavedFrame() : buf(NULL), cbuf(0), frame(-1), checksum(0) { }
|
||||
};
|
||||
struct SavedState {
|
||||
SavedFrame frames[MAX_PREDICTION_FRAMES + 2];
|
||||
int head;
|
||||
};
|
||||
|
||||
void LoadFrame(int frame);
|
||||
void SaveCurrentFrame();
|
||||
int FindSavedFrameIndex(int frame);
|
||||
SavedFrame &GetLastSavedFrame();
|
||||
|
||||
bool CreateQueues(Config &config);
|
||||
bool CheckSimulationConsistency(int *seekTo);
|
||||
void ResetPrediction(int frameNumber);
|
||||
|
||||
protected:
|
||||
GGPOSessionCallbacks _callbacks;
|
||||
SavedState _savedstate;
|
||||
Config _config;
|
||||
|
||||
bool _rollingback;
|
||||
int _last_confirmed_frame;
|
||||
int _framecount;
|
||||
int _max_prediction_frames;
|
||||
|
||||
InputQueue *_input_queues;
|
||||
|
||||
RingBuffer<Event, 32> _event_queue;
|
||||
UdpMsg::connect_status *_local_connect_status;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "timesync.h"
|
||||
|
||||
TimeSync::TimeSync()
|
||||
{
|
||||
memset(_local, 0, sizeof(_local));
|
||||
memset(_remote, 0, sizeof(_remote));
|
||||
_next_prediction = FRAME_WINDOW_SIZE * 3;
|
||||
}
|
||||
|
||||
TimeSync::~TimeSync()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
TimeSync::advance_frame(GameInput &input, int advantage, int radvantage)
|
||||
{
|
||||
// Remember the last frame and frame advantage
|
||||
_last_inputs[input.frame % ARRAY_SIZE(_last_inputs)] = input;
|
||||
_local[input.frame % ARRAY_SIZE(_local)] = advantage;
|
||||
_remote[input.frame % ARRAY_SIZE(_remote)] = radvantage;
|
||||
}
|
||||
|
||||
int
|
||||
TimeSync::recommend_frame_wait_duration(bool require_idle_input)
|
||||
{
|
||||
// Average our local and remote frame advantages
|
||||
int sum = 0;
|
||||
float advantage, radvantage;
|
||||
for (size_t i = 0; i < ARRAY_SIZE(_local); i++) {
|
||||
sum += _local[i];
|
||||
}
|
||||
advantage = sum / (float)ARRAY_SIZE(_local);
|
||||
|
||||
sum = 0;
|
||||
for (size_t i = 0; i < ARRAY_SIZE(_remote); i++) {
|
||||
sum += _remote[i];
|
||||
}
|
||||
radvantage = sum / (float)ARRAY_SIZE(_remote);
|
||||
|
||||
static int count = 0;
|
||||
count++;
|
||||
|
||||
// See if someone should take action. The person furthest ahead
|
||||
// needs to slow down so the other user can catch up.
|
||||
// Only do this if both clients agree on who's ahead!!
|
||||
if (advantage >= radvantage) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Both clients agree that we're the one ahead. Split
|
||||
// the difference between the two to figure out how long to
|
||||
// sleep for.
|
||||
int sleep_frames = (int)(((radvantage - advantage) / 2) + 0.5);
|
||||
|
||||
Log("iteration %d: sleep frames is %d", count, sleep_frames);
|
||||
|
||||
// Some things just aren't worth correcting for. Make sure
|
||||
// the difference is relevant before proceeding.
|
||||
if (sleep_frames < MIN_FRAME_ADVANTAGE) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Make sure our input had been "idle enough" before recommending
|
||||
// a sleep. This tries to make the emulator sleep while the
|
||||
// user's input isn't sweeping in arcs (e.g. fireball motions in
|
||||
// Street Fighter), which could cause the player to miss moves.
|
||||
if (require_idle_input) {
|
||||
for (size_t i = 1; i < ARRAY_SIZE(_last_inputs); i++) {
|
||||
if (!_last_inputs[i].equal(_last_inputs[0], true)) {
|
||||
Log("iteration %d: rejecting due to input stuff at position %d...!!!", count, (int)i);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Success!!! Recommend the number of frames to sleep and adjust
|
||||
return MIN(sleep_frames, MAX_FRAME_ADVANTAGE);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
/* -----------------------------------------------------------------------
|
||||
* GGPO.net (http://ggpo.net) - Copyright 2009 GroundStorm Studios, LLC.
|
||||
*
|
||||
* Use of this software is governed by the MIT license that can be found
|
||||
* in the LICENSE file.
|
||||
*/
|
||||
|
||||
#ifndef _TIMESYNC_H
|
||||
#define _TIMESYNC_H
|
||||
|
||||
#include "game_input.h"
|
||||
#include "ggpo_types.h"
|
||||
|
||||
#define FRAME_WINDOW_SIZE 40
|
||||
#define MIN_UNIQUE_FRAMES 10
|
||||
#define MIN_FRAME_ADVANTAGE 3
|
||||
#define MAX_FRAME_ADVANTAGE 9
|
||||
|
||||
class TimeSync {
|
||||
public:
|
||||
TimeSync();
|
||||
virtual ~TimeSync ();
|
||||
|
||||
void advance_frame(GameInput &input, int advantage, int radvantage);
|
||||
int recommend_frame_wait_duration(bool require_idle_input);
|
||||
|
||||
protected:
|
||||
int _local[FRAME_WINDOW_SIZE];
|
||||
int _remote[FRAME_WINDOW_SIZE];
|
||||
GameInput _last_inputs[MIN_UNIQUE_FRAMES];
|
||||
int _next_prediction;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,175 @@
|
||||
#ifndef __eglplatform_h_
|
||||
#define __eglplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright 2007-2020 The Khronos Group Inc.
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/* Platform-specific types and definitions for egl.h
|
||||
*
|
||||
* Adopters may modify khrplatform.h and this file to suit their platform.
|
||||
* You are encouraged to submit all modifications to the Khronos group so that
|
||||
* they can be included in future versions of this file. Please submit changes
|
||||
* by filing an issue or pull request on the public Khronos EGL Registry, at
|
||||
* https://www.github.com/KhronosGroup/EGL-Registry/
|
||||
*/
|
||||
|
||||
#include <KHR/khrplatform.h>
|
||||
|
||||
/* Macros used in EGL function prototype declarations.
|
||||
*
|
||||
* EGL functions should be prototyped as:
|
||||
*
|
||||
* EGLAPI return-type EGLAPIENTRY eglFunction(arguments);
|
||||
* typedef return-type (EXPAPIENTRYP PFNEGLFUNCTIONPROC) (arguments);
|
||||
*
|
||||
* KHRONOS_APICALL and KHRONOS_APIENTRY are defined in KHR/khrplatform.h
|
||||
*/
|
||||
|
||||
#ifndef EGLAPI
|
||||
#define EGLAPI KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
#ifndef EGLAPIENTRY
|
||||
#define EGLAPIENTRY KHRONOS_APIENTRY
|
||||
#endif
|
||||
#define EGLAPIENTRYP EGLAPIENTRY*
|
||||
|
||||
/* The types NativeDisplayType, NativeWindowType, and NativePixmapType
|
||||
* are aliases of window-system-dependent types, such as X Display * or
|
||||
* Windows Device Context. They must be defined in platform-specific
|
||||
* code below. The EGL-prefixed versions of Native*Type are the same
|
||||
* types, renamed in EGL 1.3 so all types in the API start with "EGL".
|
||||
*
|
||||
* Khronos STRONGLY RECOMMENDS that you use the default definitions
|
||||
* provided below, since these changes affect both binary and source
|
||||
* portability of applications using EGL running on different EGL
|
||||
* implementations.
|
||||
*/
|
||||
|
||||
#if defined(EGL_NO_PLATFORM_SPECIFIC_TYPES)
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef void *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(_WIN32) || defined(__VC32__) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__) /* Win32 and WinCE */
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN 1
|
||||
#endif
|
||||
#include <windows.h>
|
||||
|
||||
typedef HDC EGLNativeDisplayType;
|
||||
typedef HBITMAP EGLNativePixmapType;
|
||||
typedef HWND EGLNativeWindowType;
|
||||
|
||||
#elif defined(__QNX__)
|
||||
|
||||
typedef khronos_uintptr_t EGLNativeDisplayType;
|
||||
typedef struct _screen_pixmap* EGLNativePixmapType; /* screen_pixmap_t */
|
||||
typedef struct _screen_window* EGLNativeWindowType; /* screen_window_t */
|
||||
|
||||
#elif defined(__EMSCRIPTEN__)
|
||||
|
||||
typedef int EGLNativeDisplayType;
|
||||
typedef int EGLNativePixmapType;
|
||||
typedef int EGLNativeWindowType;
|
||||
|
||||
#elif defined(__WINSCW__) || defined(__SYMBIAN32__) /* Symbian */
|
||||
|
||||
typedef int EGLNativeDisplayType;
|
||||
typedef void *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(WL_EGL_PLATFORM)
|
||||
|
||||
typedef struct wl_display *EGLNativeDisplayType;
|
||||
typedef struct wl_egl_pixmap *EGLNativePixmapType;
|
||||
typedef struct wl_egl_window *EGLNativeWindowType;
|
||||
|
||||
#elif defined(__GBM__)
|
||||
|
||||
typedef struct gbm_device *EGLNativeDisplayType;
|
||||
typedef struct gbm_bo *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(__ANDROID__) || defined(ANDROID)
|
||||
|
||||
struct ANativeWindow;
|
||||
struct egl_native_pixmap_t;
|
||||
|
||||
typedef void* EGLNativeDisplayType;
|
||||
typedef struct egl_native_pixmap_t* EGLNativePixmapType;
|
||||
typedef struct ANativeWindow* EGLNativeWindowType;
|
||||
|
||||
#elif defined(USE_OZONE)
|
||||
|
||||
typedef intptr_t EGLNativeDisplayType;
|
||||
typedef intptr_t EGLNativePixmapType;
|
||||
typedef intptr_t EGLNativeWindowType;
|
||||
|
||||
#elif defined(USE_X11)
|
||||
|
||||
/* X11 (tentative) */
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/Xutil.h>
|
||||
|
||||
typedef Display *EGLNativeDisplayType;
|
||||
typedef Pixmap EGLNativePixmapType;
|
||||
typedef Window EGLNativeWindowType;
|
||||
|
||||
#elif defined(__unix__)
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef khronos_uintptr_t EGLNativePixmapType;
|
||||
typedef khronos_uintptr_t EGLNativeWindowType;
|
||||
|
||||
#elif defined(__APPLE__)
|
||||
|
||||
typedef int EGLNativeDisplayType;
|
||||
typedef void *EGLNativePixmapType;
|
||||
typedef void *EGLNativeWindowType;
|
||||
|
||||
#elif defined(__HAIKU__)
|
||||
|
||||
#include <kernel/image.h>
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef khronos_uintptr_t EGLNativePixmapType;
|
||||
typedef khronos_uintptr_t EGLNativeWindowType;
|
||||
|
||||
#elif defined(__Fuchsia__)
|
||||
|
||||
typedef void *EGLNativeDisplayType;
|
||||
typedef khronos_uintptr_t EGLNativePixmapType;
|
||||
typedef khronos_uintptr_t EGLNativeWindowType;
|
||||
|
||||
#else
|
||||
#error "Platform not recognized"
|
||||
#endif
|
||||
|
||||
/* EGL 1.2 types, renamed for consistency in EGL 1.3 */
|
||||
typedef EGLNativeDisplayType NativeDisplayType;
|
||||
typedef EGLNativePixmapType NativePixmapType;
|
||||
typedef EGLNativeWindowType NativeWindowType;
|
||||
|
||||
|
||||
/* Define EGLint. This must be a signed integral type large enough to contain
|
||||
* all legal attribute names and values passed into and out of EGL, whether
|
||||
* their type is boolean, bitmask, enumerant (symbolic constant), integer,
|
||||
* handle, or other. While in general a 32-bit integer will suffice, if
|
||||
* handles are 64 bit types, then EGLint should be defined as a signed 64-bit
|
||||
* integer type.
|
||||
*/
|
||||
typedef khronos_int32_t EGLint;
|
||||
|
||||
|
||||
/* C++ / C typecast macros for special EGL handle values */
|
||||
#if defined(__cplusplus)
|
||||
#define EGL_CAST(type, value) (static_cast<type>(value))
|
||||
#else
|
||||
#define EGL_CAST(type, value) ((type) (value))
|
||||
#endif
|
||||
|
||||
#endif /* __eglplatform_h */
|
||||
@@ -0,0 +1,311 @@
|
||||
#ifndef __khrplatform_h_
|
||||
#define __khrplatform_h_
|
||||
|
||||
/*
|
||||
** Copyright (c) 2008-2018 The Khronos Group Inc.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a
|
||||
** copy of this software and/or associated documentation files (the
|
||||
** "Materials"), to deal in the Materials without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Materials, and to
|
||||
** permit persons to whom the Materials are furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included
|
||||
** in all copies or substantial portions of the Materials.
|
||||
**
|
||||
** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
|
||||
*/
|
||||
|
||||
/* Khronos platform-specific types and definitions.
|
||||
*
|
||||
* The master copy of khrplatform.h is maintained in the Khronos EGL
|
||||
* Registry repository at https://github.com/KhronosGroup/EGL-Registry
|
||||
* The last semantic modification to khrplatform.h was at commit ID:
|
||||
* 67a3e0864c2d75ea5287b9f3d2eb74a745936692
|
||||
*
|
||||
* Adopters may modify this file to suit their platform. Adopters are
|
||||
* encouraged to submit platform specific modifications to the Khronos
|
||||
* group so that they can be included in future versions of this file.
|
||||
* Please submit changes by filing pull requests or issues on
|
||||
* the EGL Registry repository linked above.
|
||||
*
|
||||
*
|
||||
* See the Implementer's Guidelines for information about where this file
|
||||
* should be located on your system and for more details of its use:
|
||||
* http://www.khronos.org/registry/implementers_guide.pdf
|
||||
*
|
||||
* This file should be included as
|
||||
* #include <KHR/khrplatform.h>
|
||||
* by Khronos client API header files that use its types and defines.
|
||||
*
|
||||
* The types in khrplatform.h should only be used to define API-specific types.
|
||||
*
|
||||
* Types defined in khrplatform.h:
|
||||
* khronos_int8_t signed 8 bit
|
||||
* khronos_uint8_t unsigned 8 bit
|
||||
* khronos_int16_t signed 16 bit
|
||||
* khronos_uint16_t unsigned 16 bit
|
||||
* khronos_int32_t signed 32 bit
|
||||
* khronos_uint32_t unsigned 32 bit
|
||||
* khronos_int64_t signed 64 bit
|
||||
* khronos_uint64_t unsigned 64 bit
|
||||
* khronos_intptr_t signed same number of bits as a pointer
|
||||
* khronos_uintptr_t unsigned same number of bits as a pointer
|
||||
* khronos_ssize_t signed size
|
||||
* khronos_usize_t unsigned size
|
||||
* khronos_float_t signed 32 bit floating point
|
||||
* khronos_time_ns_t unsigned 64 bit time in nanoseconds
|
||||
* khronos_utime_nanoseconds_t unsigned time interval or absolute time in
|
||||
* nanoseconds
|
||||
* khronos_stime_nanoseconds_t signed time interval in nanoseconds
|
||||
* khronos_boolean_enum_t enumerated boolean type. This should
|
||||
* only be used as a base type when a client API's boolean type is
|
||||
* an enum. Client APIs which use an integer or other type for
|
||||
* booleans cannot use this as the base type for their boolean.
|
||||
*
|
||||
* Tokens defined in khrplatform.h:
|
||||
*
|
||||
* KHRONOS_FALSE, KHRONOS_TRUE Enumerated boolean false/true values.
|
||||
*
|
||||
* KHRONOS_SUPPORT_INT64 is 1 if 64 bit integers are supported; otherwise 0.
|
||||
* KHRONOS_SUPPORT_FLOAT is 1 if floats are supported; otherwise 0.
|
||||
*
|
||||
* Calling convention macros defined in this file:
|
||||
* KHRONOS_APICALL
|
||||
* KHRONOS_APIENTRY
|
||||
* KHRONOS_APIATTRIBUTES
|
||||
*
|
||||
* These may be used in function prototypes as:
|
||||
*
|
||||
* KHRONOS_APICALL void KHRONOS_APIENTRY funcname(
|
||||
* int arg1,
|
||||
* int arg2) KHRONOS_APIATTRIBUTES;
|
||||
*/
|
||||
|
||||
#if defined(__SCITECH_SNAP__) && !defined(KHRONOS_STATIC)
|
||||
# define KHRONOS_STATIC 1
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APICALL
|
||||
*-------------------------------------------------------------------------
|
||||
* This precedes the return type of the function in the function prototype.
|
||||
*/
|
||||
#if defined(KHRONOS_STATIC)
|
||||
/* If the preprocessor constant KHRONOS_STATIC is defined, make the
|
||||
* header compatible with static linking. */
|
||||
# define KHRONOS_APICALL
|
||||
#elif defined(_WIN32)
|
||||
# define KHRONOS_APICALL __declspec(dllimport)
|
||||
#elif defined (__SYMBIAN32__)
|
||||
# define KHRONOS_APICALL IMPORT_C
|
||||
#elif defined(__ANDROID__)
|
||||
# define KHRONOS_APICALL __attribute__((visibility("default")))
|
||||
#else
|
||||
# define KHRONOS_APICALL
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIENTRY
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the return type of the function and precedes the function
|
||||
* name in the function prototype.
|
||||
*/
|
||||
#if defined(_WIN32) && !defined(_WIN32_WCE) && !defined(__SCITECH_SNAP__)
|
||||
/* Win32 but not WinCE */
|
||||
# define KHRONOS_APIENTRY __stdcall
|
||||
#else
|
||||
# define KHRONOS_APIENTRY
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Definition of KHRONOS_APIATTRIBUTES
|
||||
*-------------------------------------------------------------------------
|
||||
* This follows the closing parenthesis of the function prototype arguments.
|
||||
*/
|
||||
#if defined (__ARMCC_2__)
|
||||
#define KHRONOS_APIATTRIBUTES __softfp
|
||||
#else
|
||||
#define KHRONOS_APIATTRIBUTES
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* basic type definitions
|
||||
*-----------------------------------------------------------------------*/
|
||||
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || defined(__GNUC__) || defined(__SCO__) || defined(__USLC__)
|
||||
|
||||
|
||||
/*
|
||||
* Using <stdint.h>
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
/*
|
||||
* To support platform where unsigned long cannot be used interchangeably with
|
||||
* inptr_t (e.g. CHERI-extended ISAs), we can use the stdint.h intptr_t.
|
||||
* Ideally, we could just use (u)intptr_t everywhere, but this could result in
|
||||
* ABI breakage if khronos_uintptr_t is changed from unsigned long to
|
||||
* unsigned long long or similar (this results in different C++ name mangling).
|
||||
* To avoid changes for existing platforms, we restrict usage of intptr_t to
|
||||
* platforms where the size of a pointer is larger than the size of long.
|
||||
*/
|
||||
#if defined(__SIZEOF_LONG__) && defined(__SIZEOF_POINTER__)
|
||||
#if __SIZEOF_POINTER__ > __SIZEOF_LONG__
|
||||
#define KHRONOS_USE_INTPTR_T
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif defined(__VMS ) || defined(__sgi)
|
||||
|
||||
/*
|
||||
* Using <inttypes.h>
|
||||
*/
|
||||
#include <inttypes.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(_WIN32) && !defined(__SCITECH_SNAP__)
|
||||
|
||||
/*
|
||||
* Win32
|
||||
*/
|
||||
typedef __int32 khronos_int32_t;
|
||||
typedef unsigned __int32 khronos_uint32_t;
|
||||
typedef __int64 khronos_int64_t;
|
||||
typedef unsigned __int64 khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif defined(__sun__) || defined(__digital__)
|
||||
|
||||
/*
|
||||
* Sun or Digital
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#if defined(__arch64__) || defined(_LP64)
|
||||
typedef long int khronos_int64_t;
|
||||
typedef unsigned long int khronos_uint64_t;
|
||||
#else
|
||||
typedef long long int khronos_int64_t;
|
||||
typedef unsigned long long int khronos_uint64_t;
|
||||
#endif /* __arch64__ */
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#elif 0
|
||||
|
||||
/*
|
||||
* Hypothetical platform with no float or int64 support
|
||||
*/
|
||||
typedef int khronos_int32_t;
|
||||
typedef unsigned int khronos_uint32_t;
|
||||
#define KHRONOS_SUPPORT_INT64 0
|
||||
#define KHRONOS_SUPPORT_FLOAT 0
|
||||
|
||||
#else
|
||||
|
||||
/*
|
||||
* Generic fallback
|
||||
*/
|
||||
#include <stdint.h>
|
||||
typedef int32_t khronos_int32_t;
|
||||
typedef uint32_t khronos_uint32_t;
|
||||
typedef int64_t khronos_int64_t;
|
||||
typedef uint64_t khronos_uint64_t;
|
||||
#define KHRONOS_SUPPORT_INT64 1
|
||||
#define KHRONOS_SUPPORT_FLOAT 1
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* Types that are (so far) the same on all platforms
|
||||
*/
|
||||
typedef signed char khronos_int8_t;
|
||||
typedef unsigned char khronos_uint8_t;
|
||||
typedef signed short int khronos_int16_t;
|
||||
typedef unsigned short int khronos_uint16_t;
|
||||
|
||||
/*
|
||||
* Types that differ between LLP64 and LP64 architectures - in LLP64,
|
||||
* pointers are 64 bits, but 'long' is still 32 bits. Win64 appears
|
||||
* to be the only LLP64 architecture in current use.
|
||||
*/
|
||||
#ifdef KHRONOS_USE_INTPTR_T
|
||||
typedef intptr_t khronos_intptr_t;
|
||||
typedef uintptr_t khronos_uintptr_t;
|
||||
#elif defined(_WIN64)
|
||||
typedef signed long long int khronos_intptr_t;
|
||||
typedef unsigned long long int khronos_uintptr_t;
|
||||
#else
|
||||
typedef signed long int khronos_intptr_t;
|
||||
typedef unsigned long int khronos_uintptr_t;
|
||||
#endif
|
||||
|
||||
#if defined(_WIN64)
|
||||
typedef signed long long int khronos_ssize_t;
|
||||
typedef unsigned long long int khronos_usize_t;
|
||||
#else
|
||||
typedef signed long int khronos_ssize_t;
|
||||
typedef unsigned long int khronos_usize_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_FLOAT
|
||||
/*
|
||||
* Float type
|
||||
*/
|
||||
typedef float khronos_float_t;
|
||||
#endif
|
||||
|
||||
#if KHRONOS_SUPPORT_INT64
|
||||
/* Time types
|
||||
*
|
||||
* These types can be used to represent a time interval in nanoseconds or
|
||||
* an absolute Unadjusted System Time. Unadjusted System Time is the number
|
||||
* of nanoseconds since some arbitrary system event (e.g. since the last
|
||||
* time the system booted). The Unadjusted System Time is an unsigned
|
||||
* 64 bit value that wraps back to 0 every 584 years. Time intervals
|
||||
* may be either signed or unsigned.
|
||||
*/
|
||||
typedef khronos_uint64_t khronos_utime_nanoseconds_t;
|
||||
typedef khronos_int64_t khronos_stime_nanoseconds_t;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Dummy value used to pad enum types to 32 bits.
|
||||
*/
|
||||
#ifndef KHRONOS_MAX_ENUM
|
||||
#define KHRONOS_MAX_ENUM 0x7FFFFFFF
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Enumerated boolean type
|
||||
*
|
||||
* Values other than zero should be considered to be true. Therefore
|
||||
* comparisons should not be made against KHRONOS_TRUE.
|
||||
*/
|
||||
typedef enum {
|
||||
KHRONOS_FALSE = 0,
|
||||
KHRONOS_TRUE = 1,
|
||||
KHRONOS_BOOLEAN_ENUM_FORCE_SIZE = KHRONOS_MAX_ENUM
|
||||
} khronos_boolean_enum_t;
|
||||
|
||||
#endif /* __khrplatform_h_ */
|
||||
@@ -0,0 +1,550 @@
|
||||
/**
|
||||
* Loader generated by glad 2.0.4 on Sat Jan 20 11:00:00 2024
|
||||
*
|
||||
* SPDX-License-Identifier: (WTFPL OR CC0-1.0) AND Apache-2.0
|
||||
*
|
||||
* Generator: C/C++
|
||||
* Specification: egl
|
||||
* Extensions: 0
|
||||
*
|
||||
* APIs:
|
||||
* - egl=1.5
|
||||
*
|
||||
* Options:
|
||||
* - ALIAS = False
|
||||
* - DEBUG = False
|
||||
* - HEADER_ONLY = False
|
||||
* - LOADER = True
|
||||
* - MX = False
|
||||
* - ON_DEMAND = False
|
||||
*
|
||||
* Commandline:
|
||||
* --api='egl=1.5' --extensions='' c --loader
|
||||
*
|
||||
* Online:
|
||||
* http://glad.sh/#api=egl%3D1.5&extensions=&generator=c&options=LOADER
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef GLAD_EGL_H_
|
||||
#define GLAD_EGL_H_
|
||||
|
||||
|
||||
#define GLAD_EGL
|
||||
#define GLAD_OPTION_EGL_LOADER
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_H_
|
||||
#define GLAD_PLATFORM_H_
|
||||
|
||||
#ifndef GLAD_PLATFORM_WIN32
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) || defined(__MINGW32__)
|
||||
#define GLAD_PLATFORM_WIN32 1
|
||||
#else
|
||||
#define GLAD_PLATFORM_WIN32 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_APPLE
|
||||
#ifdef __APPLE__
|
||||
#define GLAD_PLATFORM_APPLE 1
|
||||
#else
|
||||
#define GLAD_PLATFORM_APPLE 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_EMSCRIPTEN
|
||||
#ifdef __EMSCRIPTEN__
|
||||
#define GLAD_PLATFORM_EMSCRIPTEN 1
|
||||
#else
|
||||
#define GLAD_PLATFORM_EMSCRIPTEN 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_UWP
|
||||
#if defined(_MSC_VER) && !defined(GLAD_INTERNAL_HAVE_WINAPIFAMILY)
|
||||
#ifdef __has_include
|
||||
#if __has_include(<winapifamily.h>)
|
||||
#define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
|
||||
#endif
|
||||
#elif _MSC_VER >= 1700 && !_USING_V110_SDK71_
|
||||
#define GLAD_INTERNAL_HAVE_WINAPIFAMILY 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef GLAD_INTERNAL_HAVE_WINAPIFAMILY
|
||||
#include <winapifamily.h>
|
||||
#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
|
||||
#define GLAD_PLATFORM_UWP 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef GLAD_PLATFORM_UWP
|
||||
#define GLAD_PLATFORM_UWP 0
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define GLAD_GNUC_EXTENSION __extension__
|
||||
#else
|
||||
#define GLAD_GNUC_EXTENSION
|
||||
#endif
|
||||
|
||||
#define GLAD_UNUSED(x) (void)(x)
|
||||
|
||||
#ifndef GLAD_API_CALL
|
||||
#if defined(GLAD_API_CALL_EXPORT)
|
||||
#if GLAD_PLATFORM_WIN32 || defined(__CYGWIN__)
|
||||
#if defined(GLAD_API_CALL_EXPORT_BUILD)
|
||||
#if defined(__GNUC__)
|
||||
#define GLAD_API_CALL __attribute__ ((dllexport)) extern
|
||||
#else
|
||||
#define GLAD_API_CALL __declspec(dllexport) extern
|
||||
#endif
|
||||
#else
|
||||
#if defined(__GNUC__)
|
||||
#define GLAD_API_CALL __attribute__ ((dllimport)) extern
|
||||
#else
|
||||
#define GLAD_API_CALL __declspec(dllimport) extern
|
||||
#endif
|
||||
#endif
|
||||
#elif defined(__GNUC__) && defined(GLAD_API_CALL_EXPORT_BUILD)
|
||||
#define GLAD_API_CALL __attribute__ ((visibility ("default"))) extern
|
||||
#else
|
||||
#define GLAD_API_CALL extern
|
||||
#endif
|
||||
#else
|
||||
#define GLAD_API_CALL extern
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef APIENTRY
|
||||
#define GLAD_API_PTR APIENTRY
|
||||
#elif GLAD_PLATFORM_WIN32
|
||||
#define GLAD_API_PTR __stdcall
|
||||
#else
|
||||
#define GLAD_API_PTR
|
||||
#endif
|
||||
|
||||
#ifndef GLAPI
|
||||
#define GLAPI GLAD_API_CALL
|
||||
#endif
|
||||
|
||||
#ifndef GLAPIENTRY
|
||||
#define GLAPIENTRY GLAD_API_PTR
|
||||
#endif
|
||||
|
||||
#define GLAD_MAKE_VERSION(major, minor) (major * 10000 + minor)
|
||||
#define GLAD_VERSION_MAJOR(version) (version / 10000)
|
||||
#define GLAD_VERSION_MINOR(version) (version % 10000)
|
||||
|
||||
#define GLAD_GENERATOR_VERSION "2.0.4"
|
||||
|
||||
typedef void (*GLADapiproc)(void);
|
||||
|
||||
typedef GLADapiproc (*GLADloadfunc)(const char *name);
|
||||
typedef GLADapiproc (*GLADuserptrloadfunc)(void *userptr, const char *name);
|
||||
|
||||
typedef void (*GLADprecallback)(const char *name, GLADapiproc apiproc, int len_args, ...);
|
||||
typedef void (*GLADpostcallback)(void *ret, const char *name, GLADapiproc apiproc, int len_args, ...);
|
||||
|
||||
#endif /* GLAD_PLATFORM_H_ */
|
||||
|
||||
#define EGL_ALPHA_FORMAT 0x3088
|
||||
#define EGL_ALPHA_FORMAT_NONPRE 0x308B
|
||||
#define EGL_ALPHA_FORMAT_PRE 0x308C
|
||||
#define EGL_ALPHA_MASK_SIZE 0x303E
|
||||
#define EGL_ALPHA_SIZE 0x3021
|
||||
#define EGL_BACK_BUFFER 0x3084
|
||||
#define EGL_BAD_ACCESS 0x3002
|
||||
#define EGL_BAD_ALLOC 0x3003
|
||||
#define EGL_BAD_ATTRIBUTE 0x3004
|
||||
#define EGL_BAD_CONFIG 0x3005
|
||||
#define EGL_BAD_CONTEXT 0x3006
|
||||
#define EGL_BAD_CURRENT_SURFACE 0x3007
|
||||
#define EGL_BAD_DISPLAY 0x3008
|
||||
#define EGL_BAD_MATCH 0x3009
|
||||
#define EGL_BAD_NATIVE_PIXMAP 0x300A
|
||||
#define EGL_BAD_NATIVE_WINDOW 0x300B
|
||||
#define EGL_BAD_PARAMETER 0x300C
|
||||
#define EGL_BAD_SURFACE 0x300D
|
||||
#define EGL_BIND_TO_TEXTURE_RGB 0x3039
|
||||
#define EGL_BIND_TO_TEXTURE_RGBA 0x303A
|
||||
#define EGL_BLUE_SIZE 0x3022
|
||||
#define EGL_BUFFER_DESTROYED 0x3095
|
||||
#define EGL_BUFFER_PRESERVED 0x3094
|
||||
#define EGL_BUFFER_SIZE 0x3020
|
||||
#define EGL_CLIENT_APIS 0x308D
|
||||
#define EGL_CL_EVENT_HANDLE 0x309C
|
||||
#define EGL_COLORSPACE 0x3087
|
||||
#define EGL_COLORSPACE_LINEAR 0x308A
|
||||
#define EGL_COLORSPACE_sRGB 0x3089
|
||||
#define EGL_COLOR_BUFFER_TYPE 0x303F
|
||||
#define EGL_CONDITION_SATISFIED 0x30F6
|
||||
#define EGL_CONFIG_CAVEAT 0x3027
|
||||
#define EGL_CONFIG_ID 0x3028
|
||||
#define EGL_CONFORMANT 0x3042
|
||||
#define EGL_CONTEXT_CLIENT_TYPE 0x3097
|
||||
#define EGL_CONTEXT_CLIENT_VERSION 0x3098
|
||||
#define EGL_CONTEXT_LOST 0x300E
|
||||
#define EGL_CONTEXT_MAJOR_VERSION 0x3098
|
||||
#define EGL_CONTEXT_MINOR_VERSION 0x30FB
|
||||
#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT 0x00000002
|
||||
#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT 0x00000001
|
||||
#define EGL_CONTEXT_OPENGL_DEBUG 0x31B0
|
||||
#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE 0x31B1
|
||||
#define EGL_CONTEXT_OPENGL_PROFILE_MASK 0x30FD
|
||||
#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY 0x31BD
|
||||
#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS 0x31B2
|
||||
#define EGL_CORE_NATIVE_ENGINE 0x305B
|
||||
#define EGL_DEFAULT_DISPLAY EGL_CAST(EGLNativeDisplayType,0)
|
||||
#define EGL_DEPTH_SIZE 0x3025
|
||||
#define EGL_DISPLAY_SCALING 10000
|
||||
#define EGL_DONT_CARE EGL_CAST(EGLint,-1)
|
||||
#define EGL_DRAW 0x3059
|
||||
#define EGL_EXTENSIONS 0x3055
|
||||
#define EGL_FALSE 0
|
||||
#define EGL_FOREVER 0xFFFFFFFFFFFFFFFF
|
||||
#define EGL_GL_COLORSPACE 0x309D
|
||||
#define EGL_GL_COLORSPACE_LINEAR 0x308A
|
||||
#define EGL_GL_COLORSPACE_SRGB 0x3089
|
||||
#define EGL_GL_RENDERBUFFER 0x30B9
|
||||
#define EGL_GL_TEXTURE_2D 0x30B1
|
||||
#define EGL_GL_TEXTURE_3D 0x30B2
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x30B4
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x30B6
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x30B8
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x30B3
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x30B5
|
||||
#define EGL_GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x30B7
|
||||
#define EGL_GL_TEXTURE_LEVEL 0x30BC
|
||||
#define EGL_GL_TEXTURE_ZOFFSET 0x30BD
|
||||
#define EGL_GREEN_SIZE 0x3023
|
||||
#define EGL_HEIGHT 0x3056
|
||||
#define EGL_HORIZONTAL_RESOLUTION 0x3090
|
||||
#define EGL_IMAGE_PRESERVED 0x30D2
|
||||
#define EGL_LARGEST_PBUFFER 0x3058
|
||||
#define EGL_LEVEL 0x3029
|
||||
#define EGL_LOSE_CONTEXT_ON_RESET 0x31BF
|
||||
#define EGL_LUMINANCE_BUFFER 0x308F
|
||||
#define EGL_LUMINANCE_SIZE 0x303D
|
||||
#define EGL_MATCH_NATIVE_PIXMAP 0x3041
|
||||
#define EGL_MAX_PBUFFER_HEIGHT 0x302A
|
||||
#define EGL_MAX_PBUFFER_PIXELS 0x302B
|
||||
#define EGL_MAX_PBUFFER_WIDTH 0x302C
|
||||
#define EGL_MAX_SWAP_INTERVAL 0x303C
|
||||
#define EGL_MIN_SWAP_INTERVAL 0x303B
|
||||
#define EGL_MIPMAP_LEVEL 0x3083
|
||||
#define EGL_MIPMAP_TEXTURE 0x3082
|
||||
#define EGL_MULTISAMPLE_RESOLVE 0x3099
|
||||
#define EGL_MULTISAMPLE_RESOLVE_BOX 0x309B
|
||||
#define EGL_MULTISAMPLE_RESOLVE_BOX_BIT 0x0200
|
||||
#define EGL_MULTISAMPLE_RESOLVE_DEFAULT 0x309A
|
||||
#define EGL_NATIVE_RENDERABLE 0x302D
|
||||
#define EGL_NATIVE_VISUAL_ID 0x302E
|
||||
#define EGL_NATIVE_VISUAL_TYPE 0x302F
|
||||
#define EGL_NONE 0x3038
|
||||
#define EGL_NON_CONFORMANT_CONFIG 0x3051
|
||||
#define EGL_NOT_INITIALIZED 0x3001
|
||||
#define EGL_NO_CONTEXT EGL_CAST(EGLContext,0)
|
||||
#define EGL_NO_DISPLAY EGL_CAST(EGLDisplay,0)
|
||||
#define EGL_NO_IMAGE EGL_CAST(EGLImage,0)
|
||||
#define EGL_NO_RESET_NOTIFICATION 0x31BE
|
||||
#define EGL_NO_SURFACE EGL_CAST(EGLSurface,0)
|
||||
#define EGL_NO_SYNC EGL_CAST(EGLSync,0)
|
||||
#define EGL_NO_TEXTURE 0x305C
|
||||
#define EGL_OPENGL_API 0x30A2
|
||||
#define EGL_OPENGL_BIT 0x0008
|
||||
#define EGL_OPENGL_ES2_BIT 0x0004
|
||||
#define EGL_OPENGL_ES3_BIT 0x00000040
|
||||
#define EGL_OPENGL_ES_API 0x30A0
|
||||
#define EGL_OPENGL_ES_BIT 0x0001
|
||||
#define EGL_OPENVG_API 0x30A1
|
||||
#define EGL_OPENVG_BIT 0x0002
|
||||
#define EGL_OPENVG_IMAGE 0x3096
|
||||
#define EGL_PBUFFER_BIT 0x0001
|
||||
#define EGL_PIXEL_ASPECT_RATIO 0x3092
|
||||
#define EGL_PIXMAP_BIT 0x0002
|
||||
#define EGL_READ 0x305A
|
||||
#define EGL_RED_SIZE 0x3024
|
||||
#define EGL_RENDERABLE_TYPE 0x3040
|
||||
#define EGL_RENDER_BUFFER 0x3086
|
||||
#define EGL_RGB_BUFFER 0x308E
|
||||
#define EGL_SAMPLES 0x3031
|
||||
#define EGL_SAMPLE_BUFFERS 0x3032
|
||||
#define EGL_SIGNALED 0x30F2
|
||||
#define EGL_SINGLE_BUFFER 0x3085
|
||||
#define EGL_SLOW_CONFIG 0x3050
|
||||
#define EGL_STENCIL_SIZE 0x3026
|
||||
#define EGL_SUCCESS 0x3000
|
||||
#define EGL_SURFACE_TYPE 0x3033
|
||||
#define EGL_SWAP_BEHAVIOR 0x3093
|
||||
#define EGL_SWAP_BEHAVIOR_PRESERVED_BIT 0x0400
|
||||
#define EGL_SYNC_CL_EVENT 0x30FE
|
||||
#define EGL_SYNC_CL_EVENT_COMPLETE 0x30FF
|
||||
#define EGL_SYNC_CONDITION 0x30F8
|
||||
#define EGL_SYNC_FENCE 0x30F9
|
||||
#define EGL_SYNC_FLUSH_COMMANDS_BIT 0x0001
|
||||
#define EGL_SYNC_PRIOR_COMMANDS_COMPLETE 0x30F0
|
||||
#define EGL_SYNC_STATUS 0x30F1
|
||||
#define EGL_SYNC_TYPE 0x30F7
|
||||
#define EGL_TEXTURE_2D 0x305F
|
||||
#define EGL_TEXTURE_FORMAT 0x3080
|
||||
#define EGL_TEXTURE_RGB 0x305D
|
||||
#define EGL_TEXTURE_RGBA 0x305E
|
||||
#define EGL_TEXTURE_TARGET 0x3081
|
||||
#define EGL_TIMEOUT_EXPIRED 0x30F5
|
||||
#define EGL_TRANSPARENT_BLUE_VALUE 0x3035
|
||||
#define EGL_TRANSPARENT_GREEN_VALUE 0x3036
|
||||
#define EGL_TRANSPARENT_RED_VALUE 0x3037
|
||||
#define EGL_TRANSPARENT_RGB 0x3052
|
||||
#define EGL_TRANSPARENT_TYPE 0x3034
|
||||
#define EGL_TRUE 1
|
||||
#define EGL_UNKNOWN EGL_CAST(EGLint,-1)
|
||||
#define EGL_UNSIGNALED 0x30F3
|
||||
#define EGL_VENDOR 0x3053
|
||||
#define EGL_VERSION 0x3054
|
||||
#define EGL_VERTICAL_RESOLUTION 0x3091
|
||||
#define EGL_VG_ALPHA_FORMAT 0x3088
|
||||
#define EGL_VG_ALPHA_FORMAT_NONPRE 0x308B
|
||||
#define EGL_VG_ALPHA_FORMAT_PRE 0x308C
|
||||
#define EGL_VG_ALPHA_FORMAT_PRE_BIT 0x0040
|
||||
#define EGL_VG_COLORSPACE 0x3087
|
||||
#define EGL_VG_COLORSPACE_LINEAR 0x308A
|
||||
#define EGL_VG_COLORSPACE_LINEAR_BIT 0x0020
|
||||
#define EGL_VG_COLORSPACE_sRGB 0x3089
|
||||
#define EGL_WIDTH 0x3057
|
||||
#define EGL_WINDOW_BIT 0x0004
|
||||
|
||||
|
||||
#include <KHR/khrplatform.h>
|
||||
#include <EGL/eglplatform.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
struct AHardwareBuffer;
|
||||
struct wl_buffer;
|
||||
struct wl_display;
|
||||
struct wl_resource;
|
||||
|
||||
typedef unsigned int EGLBoolean;
|
||||
typedef unsigned int EGLenum;
|
||||
typedef intptr_t EGLAttribKHR;
|
||||
typedef intptr_t EGLAttrib;
|
||||
typedef void *EGLClientBuffer;
|
||||
typedef void *EGLConfig;
|
||||
typedef void *EGLContext;
|
||||
typedef void *EGLDeviceEXT;
|
||||
typedef void *EGLDisplay;
|
||||
typedef void *EGLImage;
|
||||
typedef void *EGLImageKHR;
|
||||
typedef void *EGLLabelKHR;
|
||||
typedef void *EGLObjectKHR;
|
||||
typedef void *EGLOutputLayerEXT;
|
||||
typedef void *EGLOutputPortEXT;
|
||||
typedef void *EGLStreamKHR;
|
||||
typedef void *EGLSurface;
|
||||
typedef void *EGLSync;
|
||||
typedef void *EGLSyncKHR;
|
||||
typedef void *EGLSyncNV;
|
||||
typedef void (*__eglMustCastToProperFunctionPointerType)(void);
|
||||
typedef khronos_utime_nanoseconds_t EGLTimeKHR;
|
||||
typedef khronos_utime_nanoseconds_t EGLTime;
|
||||
typedef khronos_utime_nanoseconds_t EGLTimeNV;
|
||||
typedef khronos_utime_nanoseconds_t EGLuint64NV;
|
||||
typedef khronos_uint64_t EGLuint64KHR;
|
||||
typedef khronos_stime_nanoseconds_t EGLnsecsANDROID;
|
||||
typedef int EGLNativeFileDescriptorKHR;
|
||||
typedef khronos_ssize_t EGLsizeiANDROID;
|
||||
typedef void (*EGLSetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, const void *value, EGLsizeiANDROID valueSize);
|
||||
typedef EGLsizeiANDROID (*EGLGetBlobFuncANDROID) (const void *key, EGLsizeiANDROID keySize, void *value, EGLsizeiANDROID valueSize);
|
||||
struct EGLClientPixmapHI {
|
||||
void *pData;
|
||||
EGLint iWidth;
|
||||
EGLint iHeight;
|
||||
EGLint iStride;
|
||||
};
|
||||
typedef void (GLAD_API_PTR *EGLDEBUGPROCKHR)(EGLenum error,const char *command,EGLint messageType,EGLLabelKHR threadLabel,EGLLabelKHR objectLabel,const char* message);
|
||||
#define PFNEGLBINDWAYLANDDISPLAYWL PFNEGLBINDWAYLANDDISPLAYWLPROC
|
||||
#define PFNEGLUNBINDWAYLANDDISPLAYWL PFNEGLUNBINDWAYLANDDISPLAYWLPROC
|
||||
#define PFNEGLQUERYWAYLANDBUFFERWL PFNEGLQUERYWAYLANDBUFFERWLPROC
|
||||
#define PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWL PFNEGLCREATEWAYLANDBUFFERFROMIMAGEWLPROC
|
||||
|
||||
|
||||
#define EGL_VERSION_1_0 1
|
||||
GLAD_API_CALL int GLAD_EGL_VERSION_1_0;
|
||||
#define EGL_VERSION_1_1 1
|
||||
GLAD_API_CALL int GLAD_EGL_VERSION_1_1;
|
||||
#define EGL_VERSION_1_2 1
|
||||
GLAD_API_CALL int GLAD_EGL_VERSION_1_2;
|
||||
#define EGL_VERSION_1_3 1
|
||||
GLAD_API_CALL int GLAD_EGL_VERSION_1_3;
|
||||
#define EGL_VERSION_1_4 1
|
||||
GLAD_API_CALL int GLAD_EGL_VERSION_1_4;
|
||||
#define EGL_VERSION_1_5 1
|
||||
GLAD_API_CALL int GLAD_EGL_VERSION_1_5;
|
||||
|
||||
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLBINDAPIPROC)(EGLenum api);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLBINDTEXIMAGEPROC)(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLCHOOSECONFIGPROC)(EGLDisplay dpy, const EGLint * attrib_list, EGLConfig * configs, EGLint config_size, EGLint * num_config);
|
||||
typedef EGLint (GLAD_API_PTR *PFNEGLCLIENTWAITSYNCPROC)(EGLDisplay dpy, EGLSync sync, EGLint flags, EGLTime timeout);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLCOPYBUFFERSPROC)(EGLDisplay dpy, EGLSurface surface, EGLNativePixmapType target);
|
||||
typedef EGLContext (GLAD_API_PTR *PFNEGLCREATECONTEXTPROC)(EGLDisplay dpy, EGLConfig config, EGLContext share_context, const EGLint * attrib_list);
|
||||
typedef EGLImage (GLAD_API_PTR *PFNEGLCREATEIMAGEPROC)(EGLDisplay dpy, EGLContext ctx, EGLenum target, EGLClientBuffer buffer, const EGLAttrib * attrib_list);
|
||||
typedef EGLSurface (GLAD_API_PTR *PFNEGLCREATEPBUFFERFROMCLIENTBUFFERPROC)(EGLDisplay dpy, EGLenum buftype, EGLClientBuffer buffer, EGLConfig config, const EGLint * attrib_list);
|
||||
typedef EGLSurface (GLAD_API_PTR *PFNEGLCREATEPBUFFERSURFACEPROC)(EGLDisplay dpy, EGLConfig config, const EGLint * attrib_list);
|
||||
typedef EGLSurface (GLAD_API_PTR *PFNEGLCREATEPIXMAPSURFACEPROC)(EGLDisplay dpy, EGLConfig config, EGLNativePixmapType pixmap, const EGLint * attrib_list);
|
||||
typedef EGLSurface (GLAD_API_PTR *PFNEGLCREATEPLATFORMPIXMAPSURFACEPROC)(EGLDisplay dpy, EGLConfig config, void * native_pixmap, const EGLAttrib * attrib_list);
|
||||
typedef EGLSurface (GLAD_API_PTR *PFNEGLCREATEPLATFORMWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, void * native_window, const EGLAttrib * attrib_list);
|
||||
typedef EGLSync (GLAD_API_PTR *PFNEGLCREATESYNCPROC)(EGLDisplay dpy, EGLenum type, const EGLAttrib * attrib_list);
|
||||
typedef EGLSurface (GLAD_API_PTR *PFNEGLCREATEWINDOWSURFACEPROC)(EGLDisplay dpy, EGLConfig config, EGLNativeWindowType win, const EGLint * attrib_list);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLDESTROYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLDESTROYIMAGEPROC)(EGLDisplay dpy, EGLImage image);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLDESTROYSURFACEPROC)(EGLDisplay dpy, EGLSurface surface);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLDESTROYSYNCPROC)(EGLDisplay dpy, EGLSync sync);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLGETCONFIGATTRIBPROC)(EGLDisplay dpy, EGLConfig config, EGLint attribute, EGLint * value);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLGETCONFIGSPROC)(EGLDisplay dpy, EGLConfig * configs, EGLint config_size, EGLint * num_config);
|
||||
typedef EGLContext (GLAD_API_PTR *PFNEGLGETCURRENTCONTEXTPROC)(void);
|
||||
typedef EGLDisplay (GLAD_API_PTR *PFNEGLGETCURRENTDISPLAYPROC)(void);
|
||||
typedef EGLSurface (GLAD_API_PTR *PFNEGLGETCURRENTSURFACEPROC)(EGLint readdraw);
|
||||
typedef EGLDisplay (GLAD_API_PTR *PFNEGLGETDISPLAYPROC)(EGLNativeDisplayType display_id);
|
||||
typedef EGLint (GLAD_API_PTR *PFNEGLGETERRORPROC)(void);
|
||||
typedef EGLDisplay (GLAD_API_PTR *PFNEGLGETPLATFORMDISPLAYPROC)(EGLenum platform, void * native_display, const EGLAttrib * attrib_list);
|
||||
typedef __eglMustCastToProperFunctionPointerType (GLAD_API_PTR *PFNEGLGETPROCADDRESSPROC)(const char * procname);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLGETSYNCATTRIBPROC)(EGLDisplay dpy, EGLSync sync, EGLint attribute, EGLAttrib * value);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLINITIALIZEPROC)(EGLDisplay dpy, EGLint * major, EGLint * minor);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLMAKECURRENTPROC)(EGLDisplay dpy, EGLSurface draw, EGLSurface read, EGLContext ctx);
|
||||
typedef EGLenum (GLAD_API_PTR *PFNEGLQUERYAPIPROC)(void);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLQUERYCONTEXTPROC)(EGLDisplay dpy, EGLContext ctx, EGLint attribute, EGLint * value);
|
||||
typedef const char * (GLAD_API_PTR *PFNEGLQUERYSTRINGPROC)(EGLDisplay dpy, EGLint name);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLQUERYSURFACEPROC)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint * value);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLRELEASETEXIMAGEPROC)(EGLDisplay dpy, EGLSurface surface, EGLint buffer);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLRELEASETHREADPROC)(void);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLSURFACEATTRIBPROC)(EGLDisplay dpy, EGLSurface surface, EGLint attribute, EGLint value);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLSWAPBUFFERSPROC)(EGLDisplay dpy, EGLSurface surface);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLSWAPINTERVALPROC)(EGLDisplay dpy, EGLint interval);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLTERMINATEPROC)(EGLDisplay dpy);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLWAITCLIENTPROC)(void);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLWAITGLPROC)(void);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLWAITNATIVEPROC)(EGLint engine);
|
||||
typedef EGLBoolean (GLAD_API_PTR *PFNEGLWAITSYNCPROC)(EGLDisplay dpy, EGLSync sync, EGLint flags);
|
||||
|
||||
GLAD_API_CALL PFNEGLBINDAPIPROC glad_eglBindAPI;
|
||||
#define eglBindAPI glad_eglBindAPI
|
||||
GLAD_API_CALL PFNEGLBINDTEXIMAGEPROC glad_eglBindTexImage;
|
||||
#define eglBindTexImage glad_eglBindTexImage
|
||||
GLAD_API_CALL PFNEGLCHOOSECONFIGPROC glad_eglChooseConfig;
|
||||
#define eglChooseConfig glad_eglChooseConfig
|
||||
GLAD_API_CALL PFNEGLCLIENTWAITSYNCPROC glad_eglClientWaitSync;
|
||||
#define eglClientWaitSync glad_eglClientWaitSync
|
||||
GLAD_API_CALL PFNEGLCOPYBUFFERSPROC glad_eglCopyBuffers;
|
||||
#define eglCopyBuffers glad_eglCopyBuffers
|
||||
GLAD_API_CALL PFNEGLCREATECONTEXTPROC glad_eglCreateContext;
|
||||
#define eglCreateContext glad_eglCreateContext
|
||||
GLAD_API_CALL PFNEGLCREATEIMAGEPROC glad_eglCreateImage;
|
||||
#define eglCreateImage glad_eglCreateImage
|
||||
GLAD_API_CALL PFNEGLCREATEPBUFFERFROMCLIENTBUFFERPROC glad_eglCreatePbufferFromClientBuffer;
|
||||
#define eglCreatePbufferFromClientBuffer glad_eglCreatePbufferFromClientBuffer
|
||||
GLAD_API_CALL PFNEGLCREATEPBUFFERSURFACEPROC glad_eglCreatePbufferSurface;
|
||||
#define eglCreatePbufferSurface glad_eglCreatePbufferSurface
|
||||
GLAD_API_CALL PFNEGLCREATEPIXMAPSURFACEPROC glad_eglCreatePixmapSurface;
|
||||
#define eglCreatePixmapSurface glad_eglCreatePixmapSurface
|
||||
GLAD_API_CALL PFNEGLCREATEPLATFORMPIXMAPSURFACEPROC glad_eglCreatePlatformPixmapSurface;
|
||||
#define eglCreatePlatformPixmapSurface glad_eglCreatePlatformPixmapSurface
|
||||
GLAD_API_CALL PFNEGLCREATEPLATFORMWINDOWSURFACEPROC glad_eglCreatePlatformWindowSurface;
|
||||
#define eglCreatePlatformWindowSurface glad_eglCreatePlatformWindowSurface
|
||||
GLAD_API_CALL PFNEGLCREATESYNCPROC glad_eglCreateSync;
|
||||
#define eglCreateSync glad_eglCreateSync
|
||||
GLAD_API_CALL PFNEGLCREATEWINDOWSURFACEPROC glad_eglCreateWindowSurface;
|
||||
#define eglCreateWindowSurface glad_eglCreateWindowSurface
|
||||
GLAD_API_CALL PFNEGLDESTROYCONTEXTPROC glad_eglDestroyContext;
|
||||
#define eglDestroyContext glad_eglDestroyContext
|
||||
GLAD_API_CALL PFNEGLDESTROYIMAGEPROC glad_eglDestroyImage;
|
||||
#define eglDestroyImage glad_eglDestroyImage
|
||||
GLAD_API_CALL PFNEGLDESTROYSURFACEPROC glad_eglDestroySurface;
|
||||
#define eglDestroySurface glad_eglDestroySurface
|
||||
GLAD_API_CALL PFNEGLDESTROYSYNCPROC glad_eglDestroySync;
|
||||
#define eglDestroySync glad_eglDestroySync
|
||||
GLAD_API_CALL PFNEGLGETCONFIGATTRIBPROC glad_eglGetConfigAttrib;
|
||||
#define eglGetConfigAttrib glad_eglGetConfigAttrib
|
||||
GLAD_API_CALL PFNEGLGETCONFIGSPROC glad_eglGetConfigs;
|
||||
#define eglGetConfigs glad_eglGetConfigs
|
||||
GLAD_API_CALL PFNEGLGETCURRENTCONTEXTPROC glad_eglGetCurrentContext;
|
||||
#define eglGetCurrentContext glad_eglGetCurrentContext
|
||||
GLAD_API_CALL PFNEGLGETCURRENTDISPLAYPROC glad_eglGetCurrentDisplay;
|
||||
#define eglGetCurrentDisplay glad_eglGetCurrentDisplay
|
||||
GLAD_API_CALL PFNEGLGETCURRENTSURFACEPROC glad_eglGetCurrentSurface;
|
||||
#define eglGetCurrentSurface glad_eglGetCurrentSurface
|
||||
GLAD_API_CALL PFNEGLGETDISPLAYPROC glad_eglGetDisplay;
|
||||
#define eglGetDisplay glad_eglGetDisplay
|
||||
GLAD_API_CALL PFNEGLGETERRORPROC glad_eglGetError;
|
||||
#define eglGetError glad_eglGetError
|
||||
GLAD_API_CALL PFNEGLGETPLATFORMDISPLAYPROC glad_eglGetPlatformDisplay;
|
||||
#define eglGetPlatformDisplay glad_eglGetPlatformDisplay
|
||||
GLAD_API_CALL PFNEGLGETPROCADDRESSPROC glad_eglGetProcAddress;
|
||||
#define eglGetProcAddress glad_eglGetProcAddress
|
||||
GLAD_API_CALL PFNEGLGETSYNCATTRIBPROC glad_eglGetSyncAttrib;
|
||||
#define eglGetSyncAttrib glad_eglGetSyncAttrib
|
||||
GLAD_API_CALL PFNEGLINITIALIZEPROC glad_eglInitialize;
|
||||
#define eglInitialize glad_eglInitialize
|
||||
GLAD_API_CALL PFNEGLMAKECURRENTPROC glad_eglMakeCurrent;
|
||||
#define eglMakeCurrent glad_eglMakeCurrent
|
||||
GLAD_API_CALL PFNEGLQUERYAPIPROC glad_eglQueryAPI;
|
||||
#define eglQueryAPI glad_eglQueryAPI
|
||||
GLAD_API_CALL PFNEGLQUERYCONTEXTPROC glad_eglQueryContext;
|
||||
#define eglQueryContext glad_eglQueryContext
|
||||
GLAD_API_CALL PFNEGLQUERYSTRINGPROC glad_eglQueryString;
|
||||
#define eglQueryString glad_eglQueryString
|
||||
GLAD_API_CALL PFNEGLQUERYSURFACEPROC glad_eglQuerySurface;
|
||||
#define eglQuerySurface glad_eglQuerySurface
|
||||
GLAD_API_CALL PFNEGLRELEASETEXIMAGEPROC glad_eglReleaseTexImage;
|
||||
#define eglReleaseTexImage glad_eglReleaseTexImage
|
||||
GLAD_API_CALL PFNEGLRELEASETHREADPROC glad_eglReleaseThread;
|
||||
#define eglReleaseThread glad_eglReleaseThread
|
||||
GLAD_API_CALL PFNEGLSURFACEATTRIBPROC glad_eglSurfaceAttrib;
|
||||
#define eglSurfaceAttrib glad_eglSurfaceAttrib
|
||||
GLAD_API_CALL PFNEGLSWAPBUFFERSPROC glad_eglSwapBuffers;
|
||||
#define eglSwapBuffers glad_eglSwapBuffers
|
||||
GLAD_API_CALL PFNEGLSWAPINTERVALPROC glad_eglSwapInterval;
|
||||
#define eglSwapInterval glad_eglSwapInterval
|
||||
GLAD_API_CALL PFNEGLTERMINATEPROC glad_eglTerminate;
|
||||
#define eglTerminate glad_eglTerminate
|
||||
GLAD_API_CALL PFNEGLWAITCLIENTPROC glad_eglWaitClient;
|
||||
#define eglWaitClient glad_eglWaitClient
|
||||
GLAD_API_CALL PFNEGLWAITGLPROC glad_eglWaitGL;
|
||||
#define eglWaitGL glad_eglWaitGL
|
||||
GLAD_API_CALL PFNEGLWAITNATIVEPROC glad_eglWaitNative;
|
||||
#define eglWaitNative glad_eglWaitNative
|
||||
GLAD_API_CALL PFNEGLWAITSYNCPROC glad_eglWaitSync;
|
||||
#define eglWaitSync glad_eglWaitSync
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
GLAD_API_CALL int gladLoadEGLUserPtr(EGLDisplay display, GLADuserptrloadfunc load, void *userptr);
|
||||
GLAD_API_CALL int gladLoadEGL(EGLDisplay display, GLADloadfunc load);
|
||||
|
||||
#ifdef GLAD_EGL
|
||||
|
||||
GLAD_API_CALL int gladLoaderLoadEGL(EGLDisplay display);
|
||||
|
||||
GLAD_API_CALL void gladLoaderUnloadEGL(void);
|
||||
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Loaded 100 of 4563 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user