Compare commits
982
Commits
2916f53e65
...
new
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cad41e456b | ||
|
|
65c4a9c051 | ||
|
|
3710924503 | ||
|
|
3948607b1e | ||
|
|
6c180372fe | ||
|
|
fed04b66b8 | ||
|
|
a4ca718070 | ||
|
|
8dbd3e1dd2 | ||
|
|
7a9a2b9832 | ||
|
|
e8757c33e3 | ||
|
|
b498a12458 | ||
|
|
c9f098693c | ||
|
|
7aeffac9fc | ||
|
|
37e7e95ace | ||
|
|
e3f56c4d12 | ||
|
|
3675ec634f | ||
|
|
d8273a225c | ||
|
|
c1c8174b27 | ||
|
|
5697f5c064 | ||
|
|
3ce16cf7f4 | ||
|
|
2abd5b0c3c | ||
|
|
4b29bf7a30 | ||
|
|
6f1bbe4f2f | ||
|
|
f64364f37d | ||
|
|
d16e0bbfbf | ||
|
|
70ae41bd29 | ||
|
|
abf6863044 | ||
|
|
4279bd9675 | ||
|
|
5910110b95 | ||
|
|
44594f7011 | ||
|
|
dbb5301ade | ||
|
|
74a4290be4 | ||
|
|
3ce892f846 | ||
|
|
68cebce04a | ||
|
|
1646e964b5 | ||
|
|
2ee97ad4ce | ||
|
|
109ddc9e1e | ||
|
|
804f8aa1fa | ||
|
|
49b97ba508 | ||
|
|
6c11d8165d | ||
|
|
93554b39ba | ||
|
|
6af0e9cf28 | ||
|
|
083deb8357 | ||
|
|
ffb375faeb | ||
|
|
b8cbd8ff6a | ||
|
|
c2bd761383 | ||
|
|
878e3438c8 | ||
|
|
3da65370e0 | ||
|
|
83e646cba9 | ||
|
|
0566166af4 | ||
|
|
ed0b8c3911 | ||
|
|
03d753a83f | ||
|
|
cf51ed1988 | ||
|
|
70f46e89d3 | ||
|
|
efd760fb2e | ||
|
|
f303d24f4a | ||
|
|
9688e88a7c | ||
|
|
c8a6325615 | ||
|
|
798db14bb5 | ||
|
|
178d78ef72 | ||
|
|
8139a0ea54 | ||
|
|
327c2bec70 | ||
|
|
fc0195d9f7 | ||
|
|
db42bca44b | ||
|
|
b3623c84a5 | ||
|
|
45c1f9004b | ||
|
|
845a395ff1 | ||
|
|
f63653c307 | ||
|
|
5b523c68a7 | ||
|
|
03efbe0681 | ||
|
|
cebd3d81e7 | ||
|
|
de53bebeb8 | ||
|
|
6ccaedd48f | ||
|
|
707856fcf2 | ||
|
|
3c3dc35e1d | ||
|
|
f9820bd226 | ||
|
|
fe2ef92ef3 | ||
|
|
9364768397 | ||
|
|
9c28d5a3b7 | ||
|
|
d5078b978c | ||
|
|
d49594d3fb | ||
|
|
619ce932f9 | ||
|
|
b564d0b1c1 | ||
|
|
fc1fc9f170 | ||
|
|
fd5bcfae90 | ||
|
|
3ee0a53688 | ||
|
|
62c081ecf2 | ||
|
|
d9beb647c1 | ||
|
|
f8f8a80a21 | ||
|
|
ac8023d50f | ||
|
|
769f2f5702 | ||
|
|
2f6839bcc4 | ||
|
|
d37109f5f7 | ||
|
|
15bd9fc43c | ||
|
|
8049e90853 | ||
|
|
e47a2c3e5c | ||
|
|
9512c22e1f | ||
|
|
8a77001016 | ||
|
|
9b0214ee55 | ||
|
|
7ad735552a | ||
|
|
ea35472ef8 | ||
|
|
50c5621d8a | ||
|
|
da275cfd52 | ||
|
|
0f4ee5d965 | ||
|
|
af8c0f5ccd | ||
|
|
8ea370a1d1 | ||
|
|
fcf0de72af | ||
|
|
320c5e6ce5 | ||
|
|
7a858cc424 | ||
|
|
c0292842a5 | ||
|
|
717902462b | ||
|
|
1d73b9d224 | ||
|
|
51f262efa0 | ||
|
|
a6e4e3f71f | ||
|
|
4387d223b9 | ||
|
|
00bfaf6360 | ||
|
|
709bd7be52 | ||
|
|
80f4348e21 | ||
|
|
e630827b34 | ||
|
|
106d9b0fc0 | ||
|
|
4a26f79945 | ||
|
|
1a199f6ce3 | ||
|
|
ec59e77867 | ||
|
|
cb28d2b611 | ||
|
|
27b6ddf5cb | ||
|
|
475c865e33 | ||
|
|
0b4ba062bb | ||
|
|
28f5e66662 | ||
|
|
e225a076f0 | ||
|
|
774c8ad0f8 | ||
|
|
52d1e7414d | ||
|
|
af4cb53e5f | ||
|
|
c019271e12 | ||
|
|
82ae2bce9d | ||
|
|
092e259a06 | ||
|
|
08b4bbfe91 | ||
|
|
560c51cf27 | ||
|
|
674f86b18a | ||
|
|
e3f10e0926 | ||
|
|
d7223d7387 | ||
|
|
45331c2a60 | ||
|
|
33f50a2c69 | ||
|
|
6c8e4d5cbd | ||
|
|
3b7215876a | ||
|
|
c74f5890bd | ||
|
|
fbd3c71ba7 | ||
|
|
128f9ab9d4 | ||
|
|
36fb359aa2 | ||
|
|
1bd73d69fe | ||
|
|
fb48285143 | ||
|
|
3de50b8370 | ||
|
|
e61cbe25b7 | ||
|
|
8395830be6 | ||
|
|
6e4ec2b9d8 | ||
|
|
f501bb8e28 | ||
|
|
d07cd3397d | ||
|
|
e008fb108a | ||
|
|
9aaffff7a8 | ||
|
|
7357b4a5df | ||
|
|
1ddc298a74 | ||
|
|
e2a9442aa6 | ||
|
|
aa0180571e | ||
|
|
7f7be39230 | ||
|
|
4d95415232 | ||
|
|
2cbd80a004 | ||
|
|
9abf8101da | ||
|
|
24badd06a5 | ||
|
|
7a03ef8eaf | ||
|
|
f3ea507313 | ||
|
|
4b0388a0e1 | ||
|
|
a84137b5ff | ||
|
|
ca02ee0352 | ||
|
|
fbaa54145e | ||
|
|
28754ffbf2 | ||
|
|
470c0eba7a | ||
|
|
7098dcec43 | ||
|
|
07137f57af | ||
|
|
8b7491a3d3 | ||
|
|
8cfa8ddfeb | ||
|
|
ef284a15a1 | ||
|
|
3723921573 | ||
|
|
195399635e | ||
|
|
46e2a924d3 | ||
|
|
b693ea4102 | ||
|
|
a73f55beb0 | ||
|
|
0bd2491ab7 | ||
|
|
860c797c9c | ||
|
|
38c5080f9f | ||
|
|
fae191d8fe | ||
|
|
d83a953e2d | ||
|
|
2dcf0d0f0d | ||
|
|
6dee37d8c1 | ||
|
|
3bad03afb3 | ||
|
|
6a6d8448f7 | ||
|
|
189babd2cf | ||
|
|
988a0f2294 | ||
|
|
85bf455731 | ||
|
|
589e4224f3 | ||
|
|
bd7fa154b4 | ||
|
|
a292f1992b | ||
|
|
88ddf429b7 | ||
|
|
7a1f6662df | ||
|
|
afc68bccc6 | ||
|
|
b4cdc4a64f | ||
|
|
3ad5afb81c | ||
|
|
bed3f20118 | ||
|
|
de67315178 | ||
|
|
8d5c0c7cad | ||
|
|
a8271e01bd | ||
|
|
900b3f8558 | ||
|
|
fdc4e056f9 | ||
|
|
7b98e40ccf | ||
|
|
01d89cf22c | ||
|
|
503a3c799a | ||
|
|
0b21388844 | ||
|
|
117bdf0c00 | ||
|
|
172dc5d37b | ||
|
|
874c6258ab | ||
|
|
a2d0a12c1a | ||
|
|
38b24e1c3d | ||
|
|
5ecbbe296b | ||
|
|
9d7a769d8f | ||
|
|
9b75e5ed83 | ||
|
|
a9ab8dc1d8 | ||
|
|
a34831aa02 | ||
|
|
84ebaa0751 | ||
|
|
55352805ee | ||
|
|
c0a3f2e16a | ||
|
|
28ff331a28 | ||
|
|
f9a53ec719 | ||
|
|
6a403e6caf | ||
|
|
a6f449bb93 | ||
|
|
0614bfc446 | ||
|
|
bb020c36c1 | ||
|
|
f17b0bfcfb | ||
|
|
2a85c9503f | ||
|
|
182428d6d6 | ||
|
|
8181a28557 | ||
|
|
88aed11d98 | ||
|
|
67010592b8 | ||
|
|
dd22d6424a | ||
|
|
e53775b97f | ||
|
|
d326f6c1ac | ||
|
|
556111c00a | ||
|
|
ebc7110e63 | ||
|
|
af49d1c8bb | ||
|
|
c71dbb1dfc | ||
|
|
432aa3c4fa | ||
|
|
5c93503710 | ||
|
|
0d58050def | ||
|
|
27bb78209a | ||
|
|
3201f5a25b | ||
|
|
d3df8a96d3 | ||
|
|
7ec5266b1f | ||
|
|
e74ff7c805 | ||
|
|
1d5f3c2959 | ||
|
|
469034b223 | ||
|
|
f3a394de21 | ||
|
|
cb23d4c11b | ||
|
|
bbf5b706f0 | ||
|
|
1e890f6d86 | ||
|
|
2fe543a603 | ||
|
|
24631990bd | ||
|
|
0c8c0d24ba | ||
|
|
454b8a91ba | ||
|
|
a74f1568e9 | ||
|
|
3f35d56be4 | ||
|
|
722fe2ccfb | ||
|
|
d85737cc08 | ||
|
|
ce29435831 | ||
|
|
d3715eece8 | ||
|
|
335d79f2c4 | ||
|
|
a9e33660cb | ||
|
|
8faf881399 | ||
|
|
c4969a36cc | ||
|
|
26fcaf6e75 | ||
|
|
a162002af2 | ||
|
|
9810fd51ab | ||
|
|
857c6b3d47 | ||
|
|
e1498f538d | ||
|
|
aa246eff94 | ||
|
|
5be21a21d5 | ||
|
|
8131bcd4d4 | ||
|
|
4ba11e3363 | ||
|
|
acf2be3f66 | ||
|
|
f5df0195e2 | ||
|
|
d26995b48d | ||
|
|
617f8120ae | ||
|
|
06c517c9aa | ||
|
|
593ed6408c | ||
|
|
fb7d3ed122 | ||
|
|
19b88ec858 | ||
|
|
160e65be7f | ||
|
|
079b0d2cf6 | ||
|
|
78f1310f41 | ||
|
|
eb1974c113 | ||
|
|
551409a023 | ||
|
|
a11e14daac | ||
|
|
7441e15e76 | ||
|
|
46506228a6 | ||
|
|
17c49c74cf | ||
|
|
3f8024d4db | ||
|
|
8675e44d28 | ||
|
|
1301d9a718 | ||
|
|
da3db50ca8 | ||
|
|
2ca6780305 | ||
|
|
be68fe5a35 | ||
|
|
dc41c0e302 | ||
|
|
51388c90d5 | ||
|
|
f8c9d33df2 | ||
|
|
ed0420fdce | ||
|
|
47a6f396fa | ||
|
|
9edb2aa0c1 | ||
|
|
003b647d83 | ||
|
|
2849ff8844 | ||
|
|
9f3089742a | ||
|
|
b286a9bbcd | ||
|
|
6204e745ba | ||
|
|
bbe0e48d23 | ||
|
|
79054080c0 | ||
|
|
81024c4c09 | ||
|
|
9068d96130 | ||
|
|
6f47543720 | ||
|
|
5a08384ae1 | ||
|
|
45d8fda0e4 | ||
|
|
a9e664492f | ||
|
|
3c8b6cb2cc | ||
|
|
2b3abbe13b | ||
|
|
241a52b94a | ||
|
|
82c300b077 | ||
|
|
0f8b629e20 | ||
|
|
36f6ac65f2 | ||
|
|
a25871a849 | ||
|
|
57766a9104 | ||
|
|
3770ae1645 | ||
|
|
d73edb403f | ||
|
|
b14196ff0d | ||
|
|
88903fee94 | ||
|
|
1e8311fc04 | ||
|
|
2b78370cb8 | ||
|
|
8f78bba9e9 | ||
|
|
41a4be678e | ||
|
|
8b2b4b7c3d | ||
|
|
1f3a29f89d | ||
|
|
c4c93097cd | ||
|
|
eedb7769e6 | ||
|
|
98db62a4bc | ||
|
|
df48c8e500 | ||
|
|
db9cc0f4c6 | ||
|
|
a79ee429b4 | ||
|
|
6acfca6d48 | ||
|
|
1cd6f4cb72 | ||
|
|
3271e8c7d6 | ||
|
|
0bcde064af | ||
|
|
957980b3c5 | ||
|
|
03eb328d81 | ||
|
|
e1716a741f | ||
|
|
e24707c847 | ||
|
|
7c4b8c307f | ||
|
|
109318aeaf | ||
|
|
1f2657cea0 | ||
|
|
382c435bac | ||
|
|
130fe4ca5d | ||
|
|
31ba3fe127 | ||
|
|
f68b31158f | ||
|
|
653ca9a72d | ||
|
|
ba7857f4df | ||
|
|
23e617ea21 | ||
|
|
cdf5a5229c | ||
|
|
f841a35a53 | ||
|
|
efd31237be | ||
|
|
6502822583 | ||
|
|
a9e6f2b2a5 | ||
|
|
510a94b42c | ||
|
|
d805be47ce | ||
|
|
f9ea8e380a | ||
|
|
5cb05beb30 | ||
|
|
677768e6ab | ||
|
|
ed6c951783 | ||
|
|
54254348b8 | ||
|
|
782fd07a8d | ||
|
|
a8fd55cb38 | ||
|
|
d7f515575a | ||
|
|
bafbf2ec2f | ||
|
|
7415944e0a | ||
|
|
1ff990ff44 | ||
|
|
73e73d8772 | ||
|
|
6d876bb767 | ||
|
|
2be0fe9f06 | ||
|
|
e1fb082927 | ||
|
|
65ca5ae4c4 | ||
|
|
2cea43dc70 | ||
|
|
44a0700800 | ||
|
|
1613a378f1 | ||
|
|
deed98a27d | ||
|
|
9d0cb8fb46 | ||
|
|
d8fe0f6923 | ||
|
|
581dbc2b3c | ||
|
|
7301d2ad76 | ||
|
|
3232a14d1d | ||
|
|
84c1f88d42 | ||
|
|
3695b10e4b | ||
|
|
6da02b25fa | ||
|
|
3bc544fba1 | ||
|
|
368d370f49 | ||
|
|
bb29c0edef | ||
|
|
6edcf75a0c | ||
|
|
31cc186424 | ||
|
|
0e94c1fa6d | ||
|
|
6d9e2dd3e1 | ||
|
|
4a4adeb3c8 | ||
|
|
ff77f8cfa0 | ||
|
|
36db89c36e | ||
|
|
a9948142ad | ||
|
|
8d05510584 | ||
|
|
d373de7a29 | ||
|
|
1efa9a9f7b | ||
|
|
0fb3ba2f91 | ||
|
|
3b4c5b5153 | ||
|
|
9293aeeec8 | ||
|
|
03ae83b119 | ||
|
|
abd63cc6cf | ||
|
|
2e43aa2c44 | ||
|
|
3d984e13c2 | ||
|
|
010900fe21 | ||
|
|
ffed626447 | ||
|
|
61f69af35a | ||
|
|
bd248ee91c | ||
|
|
194255bffe | ||
|
|
52ee627079 | ||
|
|
bd4200e707 | ||
|
|
73e7d6c7f3 | ||
|
|
a41b0e916b | ||
|
|
19f2a2c616 | ||
|
|
998601f722 | ||
|
|
7c3386cf3e | ||
|
|
d161182997 | ||
|
|
1646dc2dbd | ||
|
|
b640295be2 | ||
|
|
b89ae2391b | ||
|
|
a0fad441d0 | ||
|
|
340084dac3 | ||
|
|
c78135aa09 | ||
|
|
d19f8bbd30 | ||
|
|
4205899f5a | ||
|
|
7dd3940770 | ||
|
|
00d94e3015 | ||
|
|
7bacb3ee2b | ||
|
|
8e49be5ac4 | ||
|
|
3b94598d2c | ||
|
|
bddc9af3b6 | ||
|
|
2451d73a7c | ||
|
|
1dd2efa182 | ||
|
|
acea610773 | ||
|
|
8f2f1fd496 | ||
|
|
39c775872a | ||
|
|
bdb3cbd109 | ||
|
|
ff84ce2b04 | ||
|
|
225f405592 | ||
|
|
715ecffa18 | ||
|
|
e51cdc8992 | ||
|
|
133685ea37 | ||
|
|
6aff98d555 | ||
|
|
acdc524284 | ||
|
|
1ee5ec7b43 | ||
|
|
46a5403511 | ||
|
|
87bfb92576 | ||
|
|
c7a3e5601c | ||
|
|
4009130f6e | ||
|
|
c91243f6e9 | ||
|
|
0e3871ac26 | ||
|
|
55baafec8a | ||
|
|
b5a66993ca | ||
|
|
0b570b5fd6 | ||
|
|
378227c377 | ||
|
|
650645eaff | ||
|
|
62c71f3fe6 | ||
|
|
041ec3d710 | ||
|
|
5f2d871bad | ||
|
|
a30b151e4d | ||
|
|
5a651d2d1f | ||
|
|
4b3826edd9 | ||
|
|
bae1ff3759 | ||
|
|
fd82486431 | ||
|
|
c9cd91cbd8 | ||
|
|
c8abd374fe | ||
|
|
2b9ee8f721 | ||
|
|
d02673e04a | ||
|
|
f0117b8e6e | ||
|
|
bb7c41c754 | ||
|
|
efa583c154 | ||
|
|
d16ea13c14 | ||
|
|
673d8e0a18 | ||
|
|
37cfdde1ee | ||
|
|
0778ffb57a | ||
|
|
42099f7241 | ||
|
|
c52e1d22b7 | ||
|
|
0d7b0aadd1 | ||
|
|
4cd3355ef1 | ||
|
|
98d70b96d1 | ||
|
|
64735bdf43 | ||
|
|
7b87347b77 | ||
|
|
b5b29d7061 | ||
|
|
9ec21f85a0 | ||
|
|
da1a5a3f1b | ||
|
|
0885da8d44 | ||
|
|
8af961c6d3 | ||
|
|
ef5febdde3 | ||
|
|
6d7fbd3926 | ||
|
|
2680d373d8 | ||
|
|
2b2ddb3cf2 | ||
|
|
85ff95296b | ||
|
|
314a2de41a | ||
|
|
26fafab47a | ||
|
|
e56ff20e2d | ||
|
|
55d44f229d | ||
|
|
1c5e50cc4d | ||
|
|
ea898da6c2 | ||
|
|
dbb7e9f53c | ||
|
|
cbb68a399d | ||
|
|
0e794f28b1 | ||
|
|
87d2d9123e | ||
|
|
6823a4ddb5 | ||
|
|
20a7c70081 | ||
|
|
9caa33b3bb | ||
|
|
2d7e61460a | ||
|
|
a4b7fb3f44 | ||
|
|
70056cf4ca | ||
|
|
5f4ab71ade | ||
|
|
f3adb3257b | ||
|
|
438edda7fd | ||
|
|
d5b0441e6f | ||
|
|
9ba0ceb000 | ||
|
|
9474a68995 | ||
|
|
09c35f0aa6 | ||
|
|
a2113442cb | ||
|
|
d91808487f | ||
|
|
933949cc19 | ||
|
|
407620387d | ||
|
|
98947dea26 | ||
|
|
ebff7af9b5 | ||
|
|
b23c4b83ae | ||
|
|
c0cff40628 | ||
|
|
97513e354c | ||
|
|
c277ae7aff | ||
|
|
e1835e6282 | ||
|
|
5ac21db997 | ||
|
|
ca0e9fc3b2 | ||
|
|
66ebcb1608 | ||
|
|
ff92a78dda | ||
|
|
7356286fe0 | ||
|
|
54e8e68f86 | ||
|
|
d21cd7f78b | ||
|
|
1d7516982a | ||
|
|
c77a11442c | ||
|
|
5bd43a4643 | ||
|
|
9b87dfa1a9 | ||
|
|
2e3173ea40 | ||
|
|
68eac7cf83 | ||
|
|
6709505630 | ||
|
|
af6e962a5d | ||
|
|
18e6bdabaa | ||
|
|
9743942eae | ||
|
|
23062137a8 | ||
|
|
46f7fb5ccd | ||
|
|
9c90c49a6b | ||
|
|
4517b63557 | ||
|
|
58c239f4b4 | ||
|
|
cc8845ba3e | ||
|
|
6b69ce2901 | ||
|
|
55300ed21c | ||
|
|
7346dd4339 | ||
|
|
2caf3b92ce | ||
|
|
af2cd72a1f | ||
|
|
3d455ec1f8 | ||
|
|
15982d7735 | ||
|
|
5ae3542bd9 | ||
|
|
b1b02ae24b | ||
|
|
f0964e2c92 | ||
|
|
e9661d2998 | ||
|
|
ea6468f2a9 | ||
|
|
a2b38d3b83 | ||
|
|
d67ef02941 | ||
|
|
549ebe25d8 | ||
|
|
9a98348582 | ||
|
|
c5f5b025a6 | ||
|
|
23eaffa3a7 | ||
|
|
c161809248 | ||
|
|
4bf26dc818 | ||
|
|
5dd22fad6c | ||
|
|
2c3fdf7803 | ||
|
|
e984b9f5d7 | ||
|
|
a3c2e37b17 | ||
|
|
edf1b5a0a3 | ||
|
|
8efdf59ebd | ||
|
|
5c4537b2fa | ||
|
|
71e6079054 | ||
|
|
dd048d9b0d | ||
|
|
93074d653e | ||
|
|
9139c4350a | ||
|
|
38ce768168 | ||
|
|
82b3dc576c | ||
|
|
2167889f48 | ||
|
|
e9b02c2acf | ||
|
|
9ee446431b | ||
|
|
df106e3988 | ||
|
|
d0a057e0ee | ||
|
|
8b49902bf6 | ||
|
|
71c1e56564 | ||
|
|
1b12e67de2 | ||
|
|
291bb4bb81 | ||
|
|
342ddb19f8 | ||
|
|
9c9d2d548e | ||
|
|
d7a0bb4509 | ||
|
|
2b1a3323a8 | ||
|
|
99d030003c | ||
|
|
92a753560b | ||
|
|
af9904c892 | ||
|
|
e5e8c49f6c | ||
|
|
b37e5f45ca | ||
|
|
e1f08b07aa | ||
|
|
073ee8dca9 | ||
|
|
a26e51cf46 | ||
|
|
dfed732825 | ||
|
|
87aa70c6d2 | ||
|
|
aa2979ffe7 | ||
|
|
236e16aa6d | ||
|
|
184bb970e6 | ||
|
|
bd54469891 | ||
|
|
2f5dccc3ef | ||
|
|
592edb90a0 | ||
|
|
3db7e6b1b9 | ||
|
|
13c4df0d85 | ||
|
|
ef25fb09da | ||
|
|
03cf4a9efe | ||
|
|
53dd36efdd | ||
|
|
ad9e841a42 | ||
|
|
14f3f464c7 | ||
|
|
cbe51cc8d0 | ||
|
|
efaa3f6eea | ||
|
|
52cce9a3b0 | ||
|
|
b7b390311e | ||
|
|
c1eeddd14b | ||
|
|
1a7a55dfc3 | ||
|
|
fe5927ea6a | ||
|
|
119c794ad7 | ||
|
|
e2076b2c1c | ||
|
|
5208c5148e | ||
|
|
d80660b097 | ||
|
|
b916d0278b | ||
|
|
d51e13e620 | ||
|
|
40ad4326ef | ||
|
|
b8afc1684a | ||
|
|
8348b31ac8 | ||
|
|
411f2dbcce | ||
|
|
ee89c08160 | ||
|
|
357607a89f | ||
|
|
8d6dc2df44 | ||
|
|
5207582ab3 | ||
|
|
71768e6154 | ||
|
|
ecbe235523 | ||
|
|
afef079d1e | ||
|
|
df17696c69 | ||
|
|
065bf0908f | ||
|
|
5b6755e9cf | ||
|
|
b08482acf1 | ||
|
|
80c9c1d389 | ||
|
|
bb7db57bda | ||
|
|
6a83ac767c | ||
|
|
7e47ef9d74 | ||
|
|
e7ec603526 | ||
|
|
2d8ae09bd8 | ||
|
|
b2affbc0a7 | ||
|
|
d50bc61ada | ||
|
|
ec6b032b45 | ||
|
|
bc72f48496 | ||
|
|
dcf06fbd36 | ||
|
|
96311d72c2 | ||
|
|
07938cccc7 | ||
|
|
097c8c00f9 | ||
|
|
aa5b41fe31 | ||
|
|
0d56859d94 | ||
|
|
1af5f238e4 | ||
|
|
dd697d5650 | ||
|
|
5cf299a1c7 | ||
|
|
67bf825cc9 | ||
|
|
56e1696cd4 | ||
|
|
d955fb6430 | ||
|
|
dd910a31aa | ||
|
|
708c4d0ec3 | ||
|
|
ad13d6c6a1 | ||
|
|
1c32158142 | ||
|
|
5cea284906 | ||
|
|
13dba8b604 | ||
|
|
22398ddcef | ||
|
|
94e2cc6210 | ||
|
|
da3513f63d | ||
|
|
2c83e4ba9f | ||
|
|
c862071126 | ||
|
|
fed819e9b2 | ||
|
|
c6f4518684 | ||
|
|
053778a502 | ||
|
|
78e1ae885a | ||
|
|
982d28a3e0 | ||
|
|
c2cad858a5 | ||
|
|
794e0574ad | ||
|
|
c190271565 | ||
|
|
ae8a869f64 | ||
|
|
69d64eb8e4 | ||
|
|
b2f2df650a | ||
|
|
6af570fab2 | ||
|
|
9ed902017c | ||
|
|
32b41c98e1 | ||
|
|
6bdb4ae30d | ||
|
|
25dc97e3cc | ||
|
|
cc85983736 | ||
|
|
6e78ee188d | ||
|
|
9b73f1717f | ||
|
|
c7b9a53535 | ||
|
|
2b9be6675c | ||
|
|
fb93453482 | ||
|
|
81b08b2eba | ||
|
|
d1b03c4cb3 | ||
|
|
9544d15a18 | ||
|
|
0392dd0e7f | ||
|
|
9c25fde548 | ||
|
|
2c9d0c6cff | ||
|
|
9897dbe031 | ||
|
|
e78f117cfd | ||
|
|
07afc3813a | ||
|
|
d788de8637 | ||
|
|
d749ac8a91 | ||
|
|
f71c271c97 | ||
|
|
e1d7b7308f | ||
|
|
26a71a823a | ||
|
|
5e39097faa | ||
|
|
0df7845f2c | ||
|
|
af5bf987c8 | ||
|
|
024ace1078 | ||
|
|
8d00fe9d16 | ||
|
|
ab422b14dd | ||
|
|
95c0690216 | ||
|
|
6cb80e9e23 | ||
|
|
83b799caa8 | ||
|
|
a793ac2ff7 | ||
|
|
aec937b04b | ||
|
|
8ee46fd204 | ||
|
|
726233e55f | ||
|
|
7940f4c487 | ||
|
|
b16dbaceec | ||
|
|
f39b2060a8 | ||
|
|
aed202ebf9 | ||
|
|
a495179e5f | ||
|
|
4e1b404820 | ||
|
|
8c74ee31e0 | ||
|
|
77d3c54ebb | ||
|
|
b5de39926b | ||
|
|
3a8dafbb91 | ||
|
|
6b22f547fe | ||
|
|
de78be3e25 | ||
|
|
9f507be7bc | ||
|
|
9aaf271996 | ||
|
|
b01c0d37b0 | ||
|
|
538079880d | ||
|
|
fe0529d021 | ||
|
|
d068f0f2c3 | ||
|
|
f9a64b8d54 | ||
|
|
01cbfaae95 | ||
|
|
f9006a90d5 | ||
|
|
7daeaee6b5 | ||
|
|
03218ce20f | ||
|
|
6f33522c1c | ||
|
|
3697cc3eef | ||
|
|
51a1077fda | ||
|
|
8740c2b165 | ||
|
|
6ed2bdd4c5 | ||
|
|
c32df89490 | ||
|
|
bd5a67676b | ||
|
|
903dab49e3 | ||
|
|
1668c4b0d2 | ||
|
|
2179a27bf5 | ||
|
|
6e7a0cba76 | ||
|
|
69b37b30bc | ||
|
|
ae941a0fdb | ||
|
|
1b741a81e5 | ||
|
|
edf321515b | ||
|
|
c874e6c197 | ||
|
|
9a59c22288 | ||
|
|
750e8840f0 | ||
|
|
cf59989167 | ||
|
|
7c194ab4b4 | ||
|
|
be422d0a1e | ||
|
|
68b63d3007 | ||
|
|
8525138594 | ||
|
|
7b9f8b190e | ||
|
|
67f62daa9f | ||
|
|
0ec701f30b | ||
|
|
c53439066e | ||
|
|
7278bd0c6f | ||
|
|
b842e5821a | ||
|
|
f7d4cce485 | ||
|
|
4f502b707f | ||
|
|
09f182228f | ||
|
|
69ce48a8b9 | ||
|
|
5c2788efe4 | ||
|
|
768323b5b6 | ||
|
|
e203f225e2 | ||
|
|
ab1e2476a0 | ||
|
|
312f32e786 | ||
|
|
397466f0a8 | ||
|
|
1a773cb8ba | ||
|
|
8441c325fa | ||
|
|
cd4a1afbba | ||
|
|
ae75a932bf | ||
|
|
0fa2beede4 | ||
|
|
8e5d5ca1d7 | ||
|
|
2a68414eec | ||
|
|
3f1c8e28e9 | ||
|
|
348531352e | ||
|
|
6770cc422a | ||
|
|
7c157e22c7 | ||
|
|
0cfc6d0503 | ||
|
|
f7fbd16e57 | ||
|
|
542aeadf0f | ||
|
|
84593867dc | ||
|
|
9f23533069 | ||
|
|
4f8f6a47cb | ||
|
|
7d7a3f30e6 | ||
|
|
d39ed1ea5a | ||
|
|
5c8b314689 | ||
|
|
9953d7d388 | ||
|
|
5adf8a0773 | ||
|
|
26bfb912f1 | ||
|
|
c07d0b32a9 | ||
|
|
562da971e9 | ||
|
|
3eb24da475 | ||
|
|
8977d50992 | ||
|
|
13365dd390 | ||
|
|
aee06f51f0 | ||
|
|
d6c497731f | ||
|
|
f23e26d9da | ||
|
|
ec324e02f2 | ||
|
|
e2ce809762 | ||
|
|
d054cf9e36 | ||
|
|
943e775364 | ||
|
|
b9ec6523d6 | ||
|
|
5206d47b43 | ||
|
|
aaa8622956 | ||
|
|
587d716aae | ||
|
|
5a8710cc76 | ||
|
|
307f3a9dec | ||
|
|
eff5fc3d9a | ||
|
|
5a3004f1d1 | ||
|
|
db589b7d91 | ||
|
|
0a83175b66 | ||
|
|
bc4776f096 | ||
|
|
ab534bb998 | ||
|
|
cf2aacd75b | ||
|
|
9f88374627 | ||
|
|
b7d898b505 | ||
|
|
12c1fb6000 | ||
|
|
1ce1fdff8d | ||
|
|
7c11a7e5bc | ||
|
|
7d46b98310 | ||
|
|
68c4834a62 | ||
|
|
c9608ad7a7 | ||
|
|
6ea4132ff9 | ||
|
|
be79356f42 | ||
|
|
d4a2e059d7 | ||
|
|
f3d985ecbc | ||
|
|
bcba693afb | ||
|
|
b4fb7bf99f | ||
|
|
3ef6205ea3 | ||
|
|
3feb43fdad | ||
|
|
d74226dab1 | ||
|
|
5c3db5d991 | ||
|
|
bcb8bea0fe | ||
|
|
0c0650a2c3 | ||
|
|
2c0fd84c72 | ||
|
|
81cd03e0c3 | ||
|
|
349e6e7c94 | ||
|
|
c4c43b23ad | ||
|
|
7622f81309 | ||
|
|
c31bcf7f6a | ||
|
|
fef31b9102 | ||
|
|
20cf016b06 | ||
|
|
67604eca8d | ||
|
|
46f820690d | ||
|
|
e36256abe3 | ||
|
|
b00ca3d48c | ||
|
|
cf2e6bf382 | ||
|
|
fc52afdb00 | ||
|
|
85434b4edb | ||
|
|
f3a6c8df71 | ||
|
|
6e5c5f61db | ||
|
|
12c31ba9d1 | ||
|
|
ea50d893d4 | ||
|
|
bacd0e6e39 | ||
|
|
c0cd4ead04 | ||
|
|
4b04fc65ad | ||
|
|
83243ba32f | ||
|
|
a734ecaa10 | ||
|
|
22e2f703db | ||
|
|
28174b8dc8 | ||
|
|
061352bcff | ||
|
|
2f40724258 | ||
|
|
a45a2a5bd7 | ||
|
|
08221af3f8 | ||
|
|
f799690d3c | ||
|
|
07ab2b4b02 | ||
|
|
cafeda4368 | ||
|
|
517b39649c | ||
|
|
067b0d2e9f | ||
|
|
9b98181d28 | ||
|
|
46a94ecacd | ||
|
|
964a9f64f2 | ||
|
|
b4d94c2cbe | ||
|
|
268e9ffefd | ||
|
|
c8f8170ec2 | ||
|
|
8b20f0bf31 | ||
|
|
fe9af039fc | ||
|
|
6fad5bef4a | ||
|
|
16a0403fd4 | ||
|
|
e32d1f0900 | ||
|
|
3f37b7cdb5 | ||
|
|
059ccf41b6 | ||
|
|
1af2b8f47b | ||
|
|
87f18d0e13 | ||
|
|
8de12da1ec | ||
|
|
71080682cc | ||
|
|
f915a4208b | ||
|
|
14c41d33a7 | ||
|
|
3e61d6f84d | ||
|
|
4541d5219b | ||
|
|
3ce1566a2e | ||
|
|
368729f0f3 | ||
|
|
127392a1ae | ||
|
|
af1329710d | ||
|
|
30232d1275 | ||
|
|
31fa4948d5 | ||
|
|
6c11096fd2 | ||
|
|
7a90d2d38f | ||
|
|
a543bc7c00 | ||
|
|
8af2f044ed | ||
|
|
947f21cac7 | ||
|
|
479aad2f06 | ||
|
|
329925ea54 | ||
|
|
c8a3ebfcec | ||
|
|
1dfde00317 | ||
|
|
1bf6fe6eaf | ||
|
|
995bbe1acd | ||
|
|
1fb9485ee8 | ||
|
|
f9385ed233 | ||
|
|
94ad64675d | ||
|
|
b1be1deb79 | ||
|
|
1b4c270ccb | ||
|
|
9f5894cdcb | ||
|
|
4688358d6a | ||
|
|
c8390bdb12 | ||
|
|
3a753b1299 | ||
|
|
84f2735246 | ||
|
|
fbfcbe9578 | ||
|
|
1411c2e96b | ||
|
|
6f42a6e195 | ||
|
|
1e57183ca1 | ||
|
|
d79e12ffaa | ||
|
|
bcb1616201 | ||
|
|
38127d9260 | ||
|
|
d48d927202 | ||
|
|
150a410f00 | ||
|
|
fbbd2176fd | ||
|
|
3e19771d8f | ||
|
|
3d4317260f | ||
|
|
6d6a0e4886 | ||
|
|
91b93b5b1e | ||
|
|
c3310a036f | ||
|
|
69acbd017c | ||
|
|
81ed15b171 | ||
|
|
d1ab8b0cc8 | ||
|
|
cbdc271a5e | ||
|
|
3c908dc1ed | ||
|
|
217f00ff4c |
No files matched your search
+14
-1
@@ -83,7 +83,6 @@ assets/borrowed
|
|||||||
.VSCode*
|
.VSCode*
|
||||||
|
|
||||||
/vita
|
/vita
|
||||||
|
|
||||||
._*
|
._*
|
||||||
|
|
||||||
*~
|
*~
|
||||||
@@ -95,3 +94,17 @@ assets/borrowed
|
|||||||
# /archive
|
# /archive
|
||||||
|
|
||||||
__pycache__
|
__pycache__
|
||||||
|
|
||||||
|
package-lock.json
|
||||||
|
yarn-error.log
|
||||||
|
yarn.lock
|
||||||
|
|
||||||
|
.editor
|
||||||
|
.venv
|
||||||
|
|
||||||
|
/build2
|
||||||
|
/build*
|
||||||
|
/assets/test
|
||||||
|
/tools_old
|
||||||
|
/assets/test.png
|
||||||
|
/assets/audio/boa.mp3
|
||||||
+81
-59
@@ -1,76 +1,98 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
# Copyright (c) 2026 Dominic Masters
|
||||||
#
|
#
|
||||||
# This software is released under the MIT License.
|
# This software is released under the MIT License.
|
||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
# Setup
|
|
||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
set(CMAKE_C_STANDARD 99)
|
|
||||||
|
set(CMAKE_C_STANDARD 11)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules)
|
|
||||||
|
|
||||||
if(NOT DEFINED DUSK_TARGET_SYSTEM)
|
# Directories
|
||||||
# set(DUSK_TARGET_SYSTEM "linux")
|
|
||||||
set(DUSK_TARGET_SYSTEM "psp")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Prep cache
|
|
||||||
set(DUSK_CACHE_TARGET "dusk-target")
|
|
||||||
|
|
||||||
# Build variables
|
|
||||||
set(DUSK_ROOT_DIR "${CMAKE_SOURCE_DIR}")
|
set(DUSK_ROOT_DIR "${CMAKE_SOURCE_DIR}")
|
||||||
set(DUSK_BUILD_DIR "${CMAKE_BINARY_DIR}")
|
|
||||||
set(DUSK_SOURCES_DIR "${DUSK_ROOT_DIR}/src")
|
set(DUSK_SOURCES_DIR "${DUSK_ROOT_DIR}/src")
|
||||||
set(DUSK_TEMP_DIR "${DUSK_BUILD_DIR}/temp")
|
set(DUSK_ASSETS_DIR "${DUSK_ROOT_DIR}/assets")
|
||||||
set(DUSK_TOOLS_DIR "${DUSK_ROOT_DIR}/tools")
|
set(DUSK_BUILT_ASSETS_DIR "${CMAKE_BINARY_DIR}/assets")
|
||||||
# set(DUSK_ASSETS_DIR "${DUSK_ROOT_DIR}/assets")
|
set(DUSK_GENERATED_HEADERS_DIR "${CMAKE_BINARY_DIR}/generated")
|
||||||
# set(DUSK_ASSETS_BUILD_DIR "${DUSK_BUILD_DIR}/assets")
|
|
||||||
set(DUSK_DATA_DIR "${DUSK_ROOT_DIR}/data")
|
|
||||||
set(DUSK_GENERATED_HEADERS_DIR "${DUSK_BUILD_DIR}/generated")
|
|
||||||
set(DUSK_TARGET_NAME "Dusk" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
|
||||||
set(DUSK_BUILD_BINARY ${DUSK_BUILD_DIR}/Dusk CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
|
||||||
set(DUSK_ASSETS "" CACHE INTERNAL ${DUSK_CACHE_TARGET})
|
|
||||||
|
|
||||||
# Toolchain
|
|
||||||
|
|
||||||
# Create directories
|
|
||||||
file(MAKE_DIRECTORY ${DUSK_GENERATED_HEADERS_DIR})
|
file(MAKE_DIRECTORY ${DUSK_GENERATED_HEADERS_DIR})
|
||||||
file(MAKE_DIRECTORY ${DUSK_ASSETS_BUILD_DIR})
|
|
||||||
|
|
||||||
# Compilers
|
project(DuskCore VERSION 1.0.0 LANGUAGES C)
|
||||||
if(DUSK_TARGET_SYSTEM STREQUAL "psp")
|
|
||||||
find_package(pspsdk REQUIRED)
|
# Work out the target platform unless one was given explicitly.
|
||||||
|
include(${DUSK_ROOT_DIR}/cmake/determineplatform.cmake)
|
||||||
|
|
||||||
|
# Platform defaults and definitions (sets DUSK_DEFAULT_* and
|
||||||
|
# DUSK_PLATFORM_DIRS / DUSK_PLATFORM_DEFINITIONS).
|
||||||
|
set(DUSK_TARGET_FILE
|
||||||
|
"${DUSK_ROOT_DIR}/cmake/${DUSK_TARGET_SYSTEM}/target.cmake"
|
||||||
|
)
|
||||||
|
if(NOT EXISTS "${DUSK_TARGET_FILE}")
|
||||||
|
message(FATAL_ERROR "Unknown DUSK_TARGET_SYSTEM: ${DUSK_TARGET_SYSTEM}")
|
||||||
endif()
|
endif()
|
||||||
|
include("${DUSK_TARGET_FILE}")
|
||||||
|
|
||||||
# Init Project
|
# All options and their defaults.
|
||||||
project(${DUSK_TARGET_NAME}
|
include(${DUSK_ROOT_DIR}/cmake/option.cmake)
|
||||||
VERSION 1.0.0
|
|
||||||
LANGUAGES C
|
|
||||||
)
|
|
||||||
|
|
||||||
# Executable
|
# Targets. Tests split the code into a library plus the binary, otherwise all
|
||||||
add_executable(${DUSK_TARGET_NAME})
|
# code is compiled straight into the binary.
|
||||||
|
set(DUSK_BINARY_TARGET_NAME "Dusk")
|
||||||
|
add_executable(${DUSK_BINARY_TARGET_NAME})
|
||||||
|
|
||||||
# Add tools
|
if(DUSK_BUILD_TESTS)
|
||||||
add_subdirectory(tools)
|
set(DUSK_LIBRARY_TARGET_NAME "DuskCore")
|
||||||
|
add_library(${DUSK_LIBRARY_TARGET_NAME} STATIC)
|
||||||
# Add code
|
target_link_libraries(${DUSK_BINARY_TARGET_NAME} PUBLIC
|
||||||
add_subdirectory(src)
|
${DUSK_LIBRARY_TARGET_NAME}
|
||||||
|
|
||||||
# Include generated headers
|
|
||||||
target_include_directories(${DUSK_TARGET_NAME}
|
|
||||||
PUBLIC
|
|
||||||
${DUSK_GENERATED_HEADERS_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Postbuild, create PBP file for PSP.
|
|
||||||
if(DUSK_TARGET_SYSTEM STREQUAL "psp")
|
|
||||||
create_pbp_file(
|
|
||||||
TARGET "${DUSK_TARGET_NAME}"
|
|
||||||
ICON_PATH NULL
|
|
||||||
BACKGROUND_PATH NULL
|
|
||||||
PREVIEW_PATH NULL
|
|
||||||
TITLE "${DUSK_TARGET_NAME}"
|
|
||||||
VERSION 01.00
|
|
||||||
)
|
)
|
||||||
|
else()
|
||||||
|
set(DUSK_LIBRARY_TARGET_NAME "${DUSK_BINARY_TARGET_NAME}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||||
|
DUSK_TARGET_SYSTEM="${DUSK_TARGET_SYSTEM}"
|
||||||
|
DUSK_GAME_NAME="${DUSK_GAME_NAME}"
|
||||||
|
DUSK_GAME_AUTHOR="${DUSK_GAME_AUTHOR}"
|
||||||
|
DUSK_VERSION="${DUSK_VERSION}"
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||||
|
${DUSK_PLATFORM_DEFINITIONS}
|
||||||
|
)
|
||||||
|
foreach(OPT ASSERTIONS_FAKED BACKTRACE TRACK_MEMORY NETWORK)
|
||||||
|
if(DUSK_${OPT})
|
||||||
|
target_compile_definitions(${DUSK_LIBRARY_TARGET_NAME} PUBLIC DUSK_${OPT})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(DUSK_BACKTRACE)
|
||||||
|
target_link_options(${DUSK_LIBRARY_TARGET_NAME} PUBLIC -rdynamic)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Tools (run during the build to generate headers)
|
||||||
|
add_subdirectory(tools)
|
||||||
|
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||||
|
${DUSK_GENERATED_HEADERS_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Core engine code
|
||||||
|
add_subdirectory(${DUSK_SOURCES_DIR}/dusk)
|
||||||
|
|
||||||
|
# Assets, copied into <build>/assets
|
||||||
|
include(${DUSK_ROOT_DIR}/cmake/asset/asset.cmake)
|
||||||
|
# Separate binary dir, so <build>/assets only contains built assets.
|
||||||
|
add_subdirectory(${DUSK_ROOT_DIR}/assets ${CMAKE_BINARY_DIR}/assets_cmake)
|
||||||
|
dusk_assets_finalize(DuskAssets)
|
||||||
|
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} DuskAssets)
|
||||||
|
|
||||||
|
# Game code
|
||||||
|
add_subdirectory(${DUSK_SOURCES_DIR}/${DUSK_GAME})
|
||||||
|
|
||||||
|
# Platform code
|
||||||
|
foreach(DIR ${DUSK_PLATFORM_DIRS})
|
||||||
|
add_subdirectory(${DUSK_SOURCES_DIR}/${DIR})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(DUSK_BUILD_TESTS)
|
||||||
|
enable_testing()
|
||||||
endif()
|
endif()
|
||||||
-257
@@ -1,257 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "fixed.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
|
|
||||||
float_t fx248Fromi32(const int32_t b) {
|
|
||||||
return (float_t)b << FIXED248_FRACTION_BITS;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Fromu32(const uint32_t b) {
|
|
||||||
return (float_t)((int32_t)b << FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Fromf32(const float_t b) {
|
|
||||||
return (float_t)(b * (1 << FIXED248_FRACTION_BITS));
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Fromu16(const uint16_t b) {
|
|
||||||
return (float_t)((int32_t)b << FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Fromu8(const uint8_t b) {
|
|
||||||
return (float_t)((int32_t)b << FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int32_t fx248Toi32(const float_t a) {
|
|
||||||
return a >> FIXED248_FRACTION_BITS;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t fx248Tou32(const float_t a) {
|
|
||||||
return (uint32_t)(a >> FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Tof32(const float_t a) {
|
|
||||||
return (float_t)a / (1 << FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t fx248Tou16(const float_t a) {
|
|
||||||
return (uint16_t)(a >> FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t fx248Tou8(const float_t a) {
|
|
||||||
return (uint8_t)(a >> FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float_t fx248Addfx248(const float_t a, const float_t b) {
|
|
||||||
return a + b;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Addi32(const float_t a, const int32_t b) {
|
|
||||||
return fx248Addfx248(a, fx248Fromi32(b));
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Addu32(const float_t a, const uint32_t b) {
|
|
||||||
return fx248Addfx248(a, fx248Fromu32(b));
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Addf32(const float_t a, const float_t b) {
|
|
||||||
return fx248Addfx248(a, fx248Fromf32(b));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float_t fx248Subfx248(const float_t a, const float_t b) {
|
|
||||||
return a - b;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Subi32(const float_t a, const int32_t b) {
|
|
||||||
return fx248Subfx248(a, fx248Fromi32(b));
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Subu32(const float_t a, const uint32_t b) {
|
|
||||||
return fx248Subfx248(a, fx248Fromu32(b));
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Subf32(const float_t a, const float_t b) {
|
|
||||||
return fx248Subfx248(a, fx248Fromf32(b));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float_t fx248Mulfx248(const float_t a, const float_t b) {
|
|
||||||
return (float_t)(((int64_t)a * (int64_t)b) >> FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Muli32(const float_t a, const int32_t b) {
|
|
||||||
return (float_t)(((int64_t)a * (int64_t)b) >> FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Mulu32(const float_t a, const uint32_t b) {
|
|
||||||
return (float_t)(
|
|
||||||
((int64_t)a * (int64_t)(int32_t)b
|
|
||||||
) >> FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Mulf32(const float_t a, const float_t b) {
|
|
||||||
return (float_t)((
|
|
||||||
(int64_t)a * (int64_t)(b * (1 << FIXED248_FRACTION_BITS))
|
|
||||||
) >> FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float_t fx248Divfx248(const float_t a, const float_t b) {
|
|
||||||
assertFalse(b == 0, "Division by zero in fx248Divfx248");
|
|
||||||
return (float_t)(((int64_t)a << FIXED248_FRACTION_BITS) / (int64_t)b);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Divi32(const float_t a, const int32_t b) {
|
|
||||||
assertFalse(b == 0, "Division by zero in fx248Divi32");
|
|
||||||
return (float_t)(((int64_t)a << FIXED248_FRACTION_BITS) / (int64_t)b);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Divu32(const float_t a, const uint32_t b) {
|
|
||||||
assertFalse(b == 0, "Division by zero in fx248Divu32");
|
|
||||||
return (float_t)(
|
|
||||||
((int64_t)a << FIXED248_FRACTION_BITS
|
|
||||||
) / (int64_t)(int32_t)b);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Divf32(const float_t a, const float_t b) {
|
|
||||||
assertFalse(b == 0, "Division by zero in fx248Divf32");
|
|
||||||
return (float_t)((
|
|
||||||
(int64_t)a << FIXED248_FRACTION_BITS
|
|
||||||
) / (int64_t)(b * (1 << FIXED248_FRACTION_BITS)));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float_t fx248Floor(const float_t a) {
|
|
||||||
return a & ~((1 << FIXED248_FRACTION_BITS) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Ceil(const float_t a) {
|
|
||||||
if(a & ((1 << FIXED248_FRACTION_BITS) - 1)) {
|
|
||||||
return (a & ~((1 << FIXED248_FRACTION_BITS) - 1)) + (1 << FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
return a;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Round(const float_t a) {
|
|
||||||
if(a & ((1 << (FIXED248_FRACTION_BITS - 1)) - 1)) {
|
|
||||||
return (a & ~((1 << FIXED248_FRACTION_BITS) - 1)) + (1 << FIXED248_FRACTION_BITS);
|
|
||||||
}
|
|
||||||
return a & ~((1 << FIXED248_FRACTION_BITS) - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
uint32_t fx248Flooru32(const float_t a) {
|
|
||||||
return (uint32_t)((a >> FIXED248_FRACTION_BITS) & 0xFFFFFFFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t fx248Ceilu32(const float_t a) {
|
|
||||||
return (uint32_t)(((a + ((1 << FIXED248_FRACTION_BITS) - 1)) >> FIXED248_FRACTION_BITS) & 0xFFFFFFFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t fx248Roundu32(const float_t a) {
|
|
||||||
return (uint32_t)(((a + (1 << (FIXED248_FRACTION_BITS - 1))) >> FIXED248_FRACTION_BITS) & 0xFFFFFFFF);
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Sqrt(const float_t a) {
|
|
||||||
if(a == 0) return 0;
|
|
||||||
|
|
||||||
float_t y = a > FIXED248(1, 0) ? a : FIXED248(1, 0);
|
|
||||||
float_t last = 0;
|
|
||||||
int max_iter = 16;
|
|
||||||
while(y != last && max_iter-- > 0) {
|
|
||||||
last = y;
|
|
||||||
int32_t div = (int32_t)(((int64_t)a << FIXED248_FRACTION_BITS) / y);
|
|
||||||
y = (y + div) >> 1;
|
|
||||||
}
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float_t fx248Max(const float_t a, const float_t b) {
|
|
||||||
return (a > b) ? a : b;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Min(const float_t a, const float_t b) {
|
|
||||||
return (a < b) ? a : b;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Clamp(
|
|
||||||
const float_t a,
|
|
||||||
const float_t min,
|
|
||||||
const float_t max
|
|
||||||
) {
|
|
||||||
return (a < min) ? min : (a > max) ? max : a;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t fx248Abs(const float_t a) {
|
|
||||||
return (a < 0) ? -a : a;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float_t fx248Atan2(
|
|
||||||
const float_t y,
|
|
||||||
const float_t x
|
|
||||||
) {
|
|
||||||
// Handle special cases
|
|
||||||
if (x == 0) {
|
|
||||||
if (y > 0) return FX248_HALF_PI;
|
|
||||||
if (y < 0) return -FX248_HALF_PI;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use absolute values for quadrant correction
|
|
||||||
float_t abs_y = y;
|
|
||||||
if (abs_y < 0) abs_y = -abs_y;
|
|
||||||
|
|
||||||
float_t angle;
|
|
||||||
if (abs_y < fx248Abs(x)) {
|
|
||||||
float_t z = fx248Divfx248(y, x);
|
|
||||||
float_t z2 = fx248Mulfx248(z, z);
|
|
||||||
float_t z3 = fx248Mulfx248(z2, z);
|
|
||||||
float_t z5 = fx248Mulfx248(z3, z2);
|
|
||||||
angle = fx248Subfx248(
|
|
||||||
fx248Addfx248(z, fx248Divfx248(z5, fx248Fromi32(5))),
|
|
||||||
fx248Divfx248(z3, fx248Fromi32(3))
|
|
||||||
);
|
|
||||||
if (x < 0) {
|
|
||||||
if (y < 0) {
|
|
||||||
angle -= FX248_PI;
|
|
||||||
} else {
|
|
||||||
angle += FX248_PI;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
float_t z = fx248Divfx248(x, y);
|
|
||||||
float_t z2 = fx248Mulfx248(z, z);
|
|
||||||
float_t z3 = fx248Mulfx248(z2, z);
|
|
||||||
float_t z5 = fx248Mulfx248(z3, z2);
|
|
||||||
angle = fx248Subfx248(
|
|
||||||
fx248Addfx248(z, fx248Divfx248(z5, fx248Fromi32(5))),
|
|
||||||
fx248Divfx248(z3, fx248Fromi32(3))
|
|
||||||
);
|
|
||||||
if (y > 0) {
|
|
||||||
angle = FX248_HALF_PI - angle;
|
|
||||||
} else {
|
|
||||||
angle = -FX248_HALF_PI - angle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return angle;
|
|
||||||
}
|
|
||||||
-379
@@ -1,379 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "dusk.h"
|
|
||||||
|
|
||||||
typedef int32_t float_t;
|
|
||||||
|
|
||||||
#define FIXED248_FRACTION_BITS 8
|
|
||||||
#define FIXED248_HIGH_MULTIPLIER (1 << FIXED248_FRACTION_BITS)
|
|
||||||
#define FIXED248_MIN INT32_MIN
|
|
||||||
#define FIXED248_MAX INT32_MAX
|
|
||||||
#define FIXED248(i, f) ((float_t)( \
|
|
||||||
((i) << FIXED248_FRACTION_BITS) + \
|
|
||||||
(((f) * FIXED248_HIGH_MULTIPLIER) / 100) \
|
|
||||||
))
|
|
||||||
#define FIXED248_ONE (FIXED248(1, 0))
|
|
||||||
#define FIXED248_ZERO (FIXED248(0, 0))
|
|
||||||
#define FX248_PI 804
|
|
||||||
#define FX248_HALF_PI 402
|
|
||||||
#define FX248_3PI_4 603
|
|
||||||
#define FX248_NEG_PI -804
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert an int32_t value to a float_t value.
|
|
||||||
*
|
|
||||||
* @param b The int32_t value to convert.
|
|
||||||
* @return The converted float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Fromi32(const int32_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a uint32_t value to a float_t value.
|
|
||||||
*
|
|
||||||
* @param b The uint32_t value to convert.
|
|
||||||
* @return The converted float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Fromu32(const uint32_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to a float_t value.
|
|
||||||
*
|
|
||||||
* @param b The float_t value to convert.
|
|
||||||
* @return The converted float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Fromf32(const float_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a uint16_t value to a float_t value.
|
|
||||||
*
|
|
||||||
* @param b The uint16_t value to convert.
|
|
||||||
* @return The converted float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Fromu16(const uint16_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a uint8_t value to a float_t value.
|
|
||||||
*
|
|
||||||
* @param b The uint8_t value to convert.
|
|
||||||
* @return The converted float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Fromu8(const uint8_t b);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to an int32_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to convert.
|
|
||||||
* @return The converted int32_t value.
|
|
||||||
*/
|
|
||||||
int32_t fx248Toi32(const float_t a);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to a uint32_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to convert.
|
|
||||||
* @return The converted uint32_t value.
|
|
||||||
*/
|
|
||||||
uint32_t fx248Tou32(const float_t a);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to a float_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to convert.
|
|
||||||
* @return The converted float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Tof32(const float_t a);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to a uint16_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to convert.
|
|
||||||
* @return The converted uint16_t value.
|
|
||||||
*/
|
|
||||||
uint16_t fx248Tou16(const float_t a);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to an uint8_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to convert.
|
|
||||||
* @return The converted uint8_t value.
|
|
||||||
*/
|
|
||||||
uint8_t fx248Tou8(const float_t a);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a float_t value to another float_t value.
|
|
||||||
*
|
|
||||||
* @param a First float_t value.
|
|
||||||
* @param b Second float_t value to add to the first value.
|
|
||||||
* @return The result of the addition as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Addfx248(const float_t a, const float_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add an int32_t value to a float_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to which the int32_t will be added.
|
|
||||||
* @param b The int32_t value to add to the float_t value.
|
|
||||||
* @return The result of the addition as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Addi32(const float_t a, const int32_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a uint32_t value to a float_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to which the uint32_t will be added.
|
|
||||||
* @param b The uint32_t value to add to the float_t value.
|
|
||||||
* @return The result of the addition as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Addu32(const float_t a, const uint32_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Add a float_t value to a float_t value.
|
|
||||||
*
|
|
||||||
* @param a Pointer to the float_t value (will be modified).
|
|
||||||
* @param b The float_t value to add to the float_t value.
|
|
||||||
* @return The result of the addition as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Addf32(const float_t a, const float_t b);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract a float_t value from another float_t value.
|
|
||||||
*
|
|
||||||
* @param a First float_t value.
|
|
||||||
* @param b The float_t value to subtract from the first value.
|
|
||||||
* @return The result of the subtraction as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Subfx248(const float_t a, const float_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract an int32_t value from a float_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value from which the int32_t will be subtracted.
|
|
||||||
* @param b The int32_t value to subtract from the float_t value.
|
|
||||||
* @return The result of the subtraction as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Subi32(const float_t a, const int32_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract a uint32_t value from a float_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value from which the uint32_t will be subtracted.
|
|
||||||
* @param b The uint32_t value to subtract from the float_t value.
|
|
||||||
* @return The result of the subtraction as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Subu32(const float_t a, const uint32_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract a float_t value from a float_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value from which the float_t will be subtracted.
|
|
||||||
* @param b The float_t value to subtract from the float_t value.
|
|
||||||
* @return The result of the subtraction as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Subf32(const float_t a, const float_t b);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply two float_t values.
|
|
||||||
*
|
|
||||||
* @param a First float_t value.
|
|
||||||
* @param b Second float_t value to multiply with the first value.
|
|
||||||
* @return The result of the multiplication as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Mulfx248(const float_t a, const float_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply a float_t value by an int32_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to multiply.
|
|
||||||
* @param b The int32_t value to multiply with the float_t value.
|
|
||||||
* @return The result of the multiplication as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Muli32(const float_t a, const int32_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply a float_t value by a uint32_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to multiply.
|
|
||||||
* @param b The uint32_t value to multiply with the float_t value.
|
|
||||||
* @return The result of the multiplication as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Mulu32(const float_t a, const uint32_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Multiply a float_t value by a float_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to multiply.
|
|
||||||
* @param b The float_t value to multiply with the float_t value.
|
|
||||||
* @return The result of the multiplication as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Mulf32(const float_t a, const float_t b);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Divide two float_t values.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to be divided.
|
|
||||||
* @param b The float_t value to divide by.
|
|
||||||
* @return The result of the division as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Divfx248(const float_t a, const float_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Divide a float_t value by an int32_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to be divided.
|
|
||||||
* @param b The int32_t value to divide by.
|
|
||||||
* @return The result of the division as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Divi32(const float_t a, const int32_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Divide a float_t value by a uint32_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to be divided.
|
|
||||||
* @param b The uint32_t value to divide by.
|
|
||||||
* @return The result of the division as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Divu32(const float_t a, const uint32_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Divide a float_t value by a float_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to be divided.
|
|
||||||
* @param b The float_t value to divide by.
|
|
||||||
* @return The result of the division as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Divf32(const float_t a, const float_t b);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to an int32_t value, rounding towards zero.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to convert.
|
|
||||||
* @return The converted int32_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Floor(const float_t a);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to an int32_t value, rounding towards positive
|
|
||||||
* infinity.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to convert.
|
|
||||||
* @return The converted int32_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Ceil(const float_t a);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to an int32_t value, rounding to the nearest
|
|
||||||
* integer.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to convert.
|
|
||||||
* @return The converted int32_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Round(const float_t a);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to a uint32_t value, rounding towards zero.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to convert.
|
|
||||||
* @return The converted uint32_t value.
|
|
||||||
*/
|
|
||||||
uint32_t fx248Flooru32(const float_t a);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to a uint32_t value, rounding towards positive
|
|
||||||
* infinity.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to convert.
|
|
||||||
* @return The converted uint32_t value.
|
|
||||||
*/
|
|
||||||
uint32_t fx248Ceilu32(const float_t a);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Convert a float_t value to a uint32_t value, rounding to the nearest
|
|
||||||
* integer.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to convert.
|
|
||||||
* @return The converted uint32_t value.
|
|
||||||
*/
|
|
||||||
uint32_t fx248Roundu32(const float_t a);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the square root of a float_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to calculate the square root of.
|
|
||||||
*/
|
|
||||||
float_t fx248Sqrt(const float_t a);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the maximum of two float_t values.
|
|
||||||
*
|
|
||||||
* @param a First float_t value.
|
|
||||||
* @param b Second float_t value.
|
|
||||||
* @return The maximum of the two values.
|
|
||||||
*/
|
|
||||||
float_t fx248Max(const float_t a, const float_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the minimum of two float_t values.
|
|
||||||
*
|
|
||||||
* @param a First float_t value.
|
|
||||||
* @param b Second float_t value.
|
|
||||||
* @return The minimum of the two values.
|
|
||||||
*/
|
|
||||||
float_t fx248Min(const float_t a, const float_t b);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clamp a float_t value between a minimum and maximum value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to clamp.
|
|
||||||
* @param min The minimum value to clamp to.
|
|
||||||
* @param max The maximum value to clamp to.
|
|
||||||
* @return The clamped float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Clamp(
|
|
||||||
const float_t a,
|
|
||||||
const float_t min,
|
|
||||||
const float_t max
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the absolute value of a float_t value.
|
|
||||||
*
|
|
||||||
* @param a The float_t value to calculate the absolute value of.
|
|
||||||
* @return The absolute value as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Abs(const float_t a);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculate the arctangent of a float_t value.
|
|
||||||
*
|
|
||||||
* @param y Y coordinate value.
|
|
||||||
* @param x X coordinate value.
|
|
||||||
* @return The arctangent of the value as a float_t value.
|
|
||||||
*/
|
|
||||||
float_t fx248Atan2(
|
|
||||||
const float_t y,
|
|
||||||
const float_t x
|
|
||||||
);
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
add_asset(cube.obj)
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
# Unit cube, centered on the origin, with per face normals and UVs.
|
||||||
|
o Cube
|
||||||
|
|
||||||
|
v -0.5 -0.5 -0.5
|
||||||
|
v 0.5 -0.5 -0.5
|
||||||
|
v 0.5 0.5 -0.5
|
||||||
|
v -0.5 0.5 -0.5
|
||||||
|
v -0.5 -0.5 0.5
|
||||||
|
v 0.5 -0.5 0.5
|
||||||
|
v 0.5 0.5 0.5
|
||||||
|
v -0.5 0.5 0.5
|
||||||
|
|
||||||
|
vt 0.0 0.0
|
||||||
|
vt 1.0 0.0
|
||||||
|
vt 1.0 1.0
|
||||||
|
vt 0.0 1.0
|
||||||
|
|
||||||
|
vn 0.0 0.0 -1.0
|
||||||
|
vn 0.0 0.0 1.0
|
||||||
|
vn -1.0 0.0 0.0
|
||||||
|
vn 1.0 0.0 0.0
|
||||||
|
vn 0.0 -1.0 0.0
|
||||||
|
vn 0.0 1.0 0.0
|
||||||
|
|
||||||
|
# Back (-Z)
|
||||||
|
f 2/1/1 1/2/1 4/3/1
|
||||||
|
f 2/1/1 4/3/1 3/4/1
|
||||||
|
# Front (+Z)
|
||||||
|
f 5/1/2 6/2/2 7/3/2
|
||||||
|
f 5/1/2 7/3/2 8/4/2
|
||||||
|
# Left (-X)
|
||||||
|
f 1/1/3 5/2/3 8/3/3
|
||||||
|
f 1/1/3 8/3/3 4/4/3
|
||||||
|
# Right (+X)
|
||||||
|
f 6/1/4 2/2/4 3/3/4
|
||||||
|
f 6/1/4 3/3/4 7/4/4
|
||||||
|
# Bottom (-Y)
|
||||||
|
f 1/1/5 2/2/5 6/3/5
|
||||||
|
f 1/1/5 6/3/5 5/4/5
|
||||||
|
# Top (+Y)
|
||||||
|
f 8/1/6 7/2/6 3/3/6
|
||||||
|
f 8/1/6 3/3/6 4/4/6
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Asset building. Include this from the root CMakeLists.txt.
|
||||||
|
#
|
||||||
|
# Assets are registered with add_asset() and built by dusk_assets_finalize().
|
||||||
|
# Each asset is dispatched on its file extension to a handler function named
|
||||||
|
# dusk_asset_<extension> (e.g. dusk_asset_obj), defined in its own file in this
|
||||||
|
# directory. Extensions without a handler fall back to a plain copy.
|
||||||
|
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/copy.cmake)
|
||||||
|
include(${CMAKE_CURRENT_LIST_DIR}/obj.cmake)
|
||||||
|
|
||||||
|
# Registers an asset to be built into the project. The path is relative to the
|
||||||
|
# calling CMakeLists.txt, and is kept relative to the root assets directory in
|
||||||
|
# the output, so assets/models/a.obj ends up at <build>/assets/models/a.obj.
|
||||||
|
#
|
||||||
|
# This only records the asset. The build rules are created by
|
||||||
|
# dusk_assets_finalize() from the root CMakeLists.txt, because a custom command
|
||||||
|
# output can only be used by targets in the directory it was defined in.
|
||||||
|
function(add_asset ASSET_PATH)
|
||||||
|
set(ASSET_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/${ASSET_PATH}")
|
||||||
|
if(NOT EXISTS "${ASSET_SOURCE}")
|
||||||
|
message(FATAL_ERROR "add_asset: ${ASSET_SOURCE} does not exist")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_property(GLOBAL APPEND PROPERTY DUSK_ASSET_SOURCES "${ASSET_SOURCE}")
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Determines the lowercase extension of an asset, without the leading dot.
|
||||||
|
function(dusk_asset_extension ASSET_SOURCE OUT_VAR)
|
||||||
|
get_filename_component(ASSET_EXT "${ASSET_SOURCE}" LAST_EXT)
|
||||||
|
string(TOLOWER "${ASSET_EXT}" ASSET_EXT)
|
||||||
|
string(REGEX REPLACE "^\\." "" ASSET_EXT "${ASSET_EXT}")
|
||||||
|
set(${OUT_VAR} "${ASSET_EXT}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Creates the TARGET_NAME target, which builds every asset registered with
|
||||||
|
# add_asset(). Call once from the root CMakeLists.txt after adding the assets.
|
||||||
|
function(dusk_assets_finalize TARGET_NAME)
|
||||||
|
get_property(ASSET_SOURCES GLOBAL PROPERTY DUSK_ASSET_SOURCES)
|
||||||
|
|
||||||
|
set(ASSET_OUTPUTS "")
|
||||||
|
foreach(ASSET_SOURCE IN LISTS ASSET_SOURCES)
|
||||||
|
file(RELATIVE_PATH ASSET_RELATIVE "${DUSK_ASSETS_DIR}" "${ASSET_SOURCE}")
|
||||||
|
dusk_asset_extension("${ASSET_SOURCE}" ASSET_EXT)
|
||||||
|
|
||||||
|
# Dispatch on the extension, falling back to a plain copy.
|
||||||
|
set(ASSET_OUTPUT "")
|
||||||
|
if(COMMAND dusk_asset_${ASSET_EXT})
|
||||||
|
cmake_language(CALL dusk_asset_${ASSET_EXT}
|
||||||
|
"${ASSET_SOURCE}" "${ASSET_RELATIVE}" ASSET_OUTPUT
|
||||||
|
)
|
||||||
|
else()
|
||||||
|
message(STATUS "Asset ${ASSET_RELATIVE}: no handler for '.${ASSET_EXT}', copying")
|
||||||
|
dusk_asset_copy("${ASSET_SOURCE}" "${ASSET_RELATIVE}" ASSET_OUTPUT)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND ASSET_OUTPUTS "${ASSET_OUTPUT}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_custom_target(${TARGET_NAME} ALL DEPENDS ${ASSET_OUTPUTS})
|
||||||
|
endfunction()
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Handler that copies an asset into the built assets directory as is. Every
|
||||||
|
# handler has the signature (SOURCE RELATIVE OUT_VAR) and must set OUT_VAR, in
|
||||||
|
# the caller's scope, to the file it produces.
|
||||||
|
function(dusk_asset_copy ASSET_SOURCE ASSET_RELATIVE OUT_VAR)
|
||||||
|
set(ASSET_OUTPUT "${DUSK_BUILT_ASSETS_DIR}/${ASSET_RELATIVE}")
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT "${ASSET_OUTPUT}"
|
||||||
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||||
|
"${ASSET_SOURCE}" "${ASSET_OUTPUT}"
|
||||||
|
DEPENDS "${ASSET_SOURCE}"
|
||||||
|
COMMENT "Copying asset ${ASSET_RELATIVE}"
|
||||||
|
VERBATIM
|
||||||
|
)
|
||||||
|
|
||||||
|
set(${OUT_VAR} "${ASSET_OUTPUT}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Handler for .obj (Wavefront mesh) assets. Currently just copies the file.
|
||||||
|
function(dusk_asset_obj ASSET_SOURCE ASSET_RELATIVE OUT_VAR)
|
||||||
|
dusk_asset_copy("${ASSET_SOURCE}" "${ASSET_RELATIVE}" ASSET_OUTPUT)
|
||||||
|
set(${OUT_VAR} "${ASSET_OUTPUT}" PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Determines DUSK_TARGET_SYSTEM when it was not explicitly provided with
|
||||||
|
# -DDUSK_TARGET_SYSTEM=<target>. Must be included after project() so that the
|
||||||
|
# compiler and CMAKE_SYSTEM_NAME are known.
|
||||||
|
#
|
||||||
|
# Console toolchains all cross compile as "Generic", so they are recognised by
|
||||||
|
# the compiler they configure.
|
||||||
|
|
||||||
|
if(DUSK_TARGET_SYSTEM)
|
||||||
|
message(STATUS "Dusk target: ${DUSK_TARGET_SYSTEM} (explicit)")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_C_COMPILER MATCHES "psp-")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "psp")
|
||||||
|
elseif(CMAKE_C_COMPILER MATCHES "arm-vita-eabi")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "vita")
|
||||||
|
elseif(CMAKE_C_COMPILER MATCHES "powerpc-eabi")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "dolphin")
|
||||||
|
elseif(CMAKE_C_COMPILER MATCHES "ps2")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "ps2")
|
||||||
|
elseif(CMAKE_C_COMPILER MATCHES "sh-elf")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "dreamcast")
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "windows")
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
set(DUSK_DETECTED_SYSTEM "linux")
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR
|
||||||
|
"Could not determine the target platform (system: ${CMAKE_SYSTEM_NAME}, "
|
||||||
|
"compiler: ${CMAKE_C_COMPILER}). Pass -DDUSK_TARGET_SYSTEM=<target>."
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(DUSK_TARGET_SYSTEM "${DUSK_DETECTED_SYSTEM}" CACHE STRING
|
||||||
|
"Target platform" FORCE
|
||||||
|
)
|
||||||
|
set_property(CACHE DUSK_TARGET_SYSTEM PROPERTY STRINGS
|
||||||
|
linux windows psp dolphin vita ps2 dreamcast
|
||||||
|
)
|
||||||
|
message(STATUS "Dusk target: ${DUSK_TARGET_SYSTEM} (detected)")
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the dolphin target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskdolphin)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
# Assertions are faked (compiled out) unless this is a Debug build.
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
else()
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
|
||||||
|
endif()
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_BIG
|
||||||
|
DUSK_DOLPHIN
|
||||||
|
DUSK_THREAD_PTHREAD
|
||||||
|
)
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the dreamcast target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskdreamcast)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
# Assertions are faked (compiled out) unless this is a Debug build.
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
else()
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
|
||||||
|
endif()
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||||
|
DUSK_DREAMCAST
|
||||||
|
)
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the linux target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS dusklinux dusksdl3 duskvulkan)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE ON)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY ON)
|
||||||
|
|
||||||
|
# Linux runs on both endiannesses, so detect it from the target compiler.
|
||||||
|
include(TestBigEndian)
|
||||||
|
test_big_endian(DUSK_IS_BIG_ENDIAN)
|
||||||
|
if(DUSK_IS_BIG_ENDIAN)
|
||||||
|
set(DUSK_ENDIAN_DEFINITION DUSK_PLATFORM_ENDIAN_BIG)
|
||||||
|
else()
|
||||||
|
set(DUSK_ENDIAN_DEFINITION DUSK_PLATFORM_ENDIAN_LITTLE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
${DUSK_ENDIAN_DEFINITION}
|
||||||
|
DUSK_LINUX
|
||||||
|
DUSK_THREAD_PTHREAD
|
||||||
|
DUSK_TIME_DYNAMIC
|
||||||
|
)
|
||||||
@@ -1,103 +0,0 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
if(NOT TARGET pspsdk)
|
|
||||||
message(STATUS "Looking for PSPSDK...")
|
|
||||||
|
|
||||||
set(PSPSDK_FOUND FALSE CACHE INTERNAL "PSPSDK found")
|
|
||||||
set(PSPSDK_DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/_pspsdk")
|
|
||||||
set(PSPSDK_SEARCH_ROOTS
|
|
||||||
"${PSPSDK_ROOT}"
|
|
||||||
"$ENV{PSPDEV}"
|
|
||||||
"$ENV{HOME}/pspdev"
|
|
||||||
"/usr/local/pspdev"
|
|
||||||
"/opt/pspdev"
|
|
||||||
"/usr/pspdev"
|
|
||||||
"${PSPSDK_DOWNLOAD_DIR}/pspdev"
|
|
||||||
)
|
|
||||||
|
|
||||||
foreach(root IN LISTS PSPSDK_SEARCH_ROOTS)
|
|
||||||
list(APPEND PSPSDK_BIN_HINTS "${root}/bin")
|
|
||||||
list(APPEND PSPSDK_INCLUDE_HINTS "${root}/include")
|
|
||||||
list(APPEND PSPSDK_LIB_HINTS "${root}/lib")
|
|
||||||
endforeach()
|
|
||||||
|
|
||||||
# Find PSP GCC
|
|
||||||
find_program(PSPSDK_PSP_GCC NAMES psp-gcc HINTS ${PSPSDK_BIN_HINTS})
|
|
||||||
|
|
||||||
# If we did not find it, download it.
|
|
||||||
if(NOT PSPSDK_PSP_GCC)
|
|
||||||
message(STATUS "psp-gcc not found in system paths. Downloading PSPSDK tarball...")
|
|
||||||
file(DOWNLOAD
|
|
||||||
"https://github.com/pspdev/pspdev/releases/latest/download/pspdev-ubuntu-latest-x86_64.tar.gz"
|
|
||||||
"${CMAKE_BINARY_DIR}/pspsdk.tar.gz"
|
|
||||||
EXPECTED_HASH SHA256=afe338e92f6eeec21c56a64eeb65201e6b95ecbae938ae38688bbf0f17b69ead
|
|
||||||
SHOW_PROGRESS
|
|
||||||
)
|
|
||||||
|
|
||||||
# Make output dir
|
|
||||||
file(MAKE_DIRECTORY "${PSPSDK_DOWNLOAD_DIR}")
|
|
||||||
|
|
||||||
# Extract the tarball
|
|
||||||
execute_process(
|
|
||||||
COMMAND
|
|
||||||
${CMAKE_COMMAND} -E tar xzf "${CMAKE_BINARY_DIR}/pspsdk.tar.gz"
|
|
||||||
WORKING_DIRECTORY
|
|
||||||
"${PSPSDK_DOWNLOAD_DIR}"
|
|
||||||
RESULT_VARIABLE
|
|
||||||
tar_result
|
|
||||||
)
|
|
||||||
if(NOT tar_result EQUAL 0)
|
|
||||||
message(FATAL_ERROR "Failed to extract PSPSDK tarball")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Retry discovery with extracted fallback
|
|
||||||
find_program(PSPSDK_PSP_GCC NAMES psp-gcc HINTS ${PSPSDK_BIN_HINTS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(PSPSDK_PSP_GCC)
|
|
||||||
get_filename_component(PSPSDK_BIN_ROOT "${PSPSDK_PSP_GCC}" DIRECTORY)
|
|
||||||
get_filename_component(PSPSDK_ROOT "${PSPSDK_BIN_ROOT}" DIRECTORY)
|
|
||||||
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
|
||||||
set(ENV{PSPDEV} "${PSPSDK_ROOT}")
|
|
||||||
set(CMAKE_TOOLCHAIN_FILE "${PSPSDK_ROOT}/psp/share/pspdev.cmake")
|
|
||||||
set(BUILD_PRX ON CACHE BOOL "Build PRX modules")
|
|
||||||
|
|
||||||
include("${PSPSDK_ROOT}/psp/share/pspdev.cmake")
|
|
||||||
set(CMAKE_C_COMPILER ${PSPSDK_BIN_ROOT}/psp-gcc)
|
|
||||||
set(CMAKE_CXX_COMPILER ${PSPSDK_BIN_ROOT}/psp-g++)
|
|
||||||
|
|
||||||
if(NOT DEFINED PSP)
|
|
||||||
message(FATAL_ERROR "PSP environment variable is not set correctly.")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
add_library(pspsdk INTERFACE IMPORTED)
|
|
||||||
set_target_properties(pspsdk PROPERTIES
|
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${PSPSDK_INCLUDE_DIR}"
|
|
||||||
INTERFACE_LINK_DIRECTORIES "${PSPSDK_LIB_DIR}"
|
|
||||||
)
|
|
||||||
target_include_directories(pspsdk
|
|
||||||
INTERFACE
|
|
||||||
${PSPDEV}/psp/include
|
|
||||||
${PSPDEV}/psp/sdk/include
|
|
||||||
)
|
|
||||||
target_link_directories(pspsdk
|
|
||||||
INTERFACE
|
|
||||||
${PSPDEV}/lib
|
|
||||||
${PSPDEV}/psp/lib
|
|
||||||
${PSPDEV}/psp/sdk/lib
|
|
||||||
)
|
|
||||||
target_link_libraries(pspsdk INTERFACE
|
|
||||||
pspdebug
|
|
||||||
pspdisplay
|
|
||||||
pspge
|
|
||||||
pspctrl
|
|
||||||
pspgu
|
|
||||||
pspaudio
|
|
||||||
pspaudiolib
|
|
||||||
psputility
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# All user facing CMake options and their defaults. Included by the root
|
||||||
|
# CMakeLists.txt after the platform's target.cmake, which supplies the
|
||||||
|
# DUSK_DEFAULT_* values used below. DUSK_TARGET_SYSTEM itself is declared by
|
||||||
|
# determineplatform.cmake.
|
||||||
|
|
||||||
|
# General
|
||||||
|
option(DUSK_BUILD_TESTS "Enable tests." OFF)
|
||||||
|
option(DUSK_NETWORK "Enable network support." ON)
|
||||||
|
|
||||||
|
# Game metadata
|
||||||
|
set(DUSK_GAME "duskexample" CACHE STRING
|
||||||
|
"Directory under src/ containing the game to build (provides game/game.c)."
|
||||||
|
)
|
||||||
|
set(DUSK_GAME_NAME "Dusk" CACHE STRING "Game display name.")
|
||||||
|
set(DUSK_GAME_AUTHOR "YourWishes" CACHE STRING "Game author / coder.")
|
||||||
|
if(NOT DEFINED DUSK_VERSION)
|
||||||
|
string(TIMESTAMP DUSK_VERSION "debug-%y%m%d%H%M%S")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Platform dependent defaults
|
||||||
|
option(DUSK_ASSERTIONS_FAKED
|
||||||
|
"Compile assertions out (they do nothing)."
|
||||||
|
${DUSK_DEFAULT_ASSERTIONS_FAKED}
|
||||||
|
)
|
||||||
|
option(DUSK_BACKTRACE
|
||||||
|
"Log a stack trace on assertion failure."
|
||||||
|
${DUSK_DEFAULT_BACKTRACE}
|
||||||
|
)
|
||||||
|
option(DUSK_TRACK_MEMORY
|
||||||
|
"Track memoryAllocate() call sites to help find memory leaks."
|
||||||
|
${DUSK_DEFAULT_TRACK_MEMORY}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Tests mock assertions, so they can never be faked.
|
||||||
|
if(DUSK_BUILD_TESTS AND DUSK_ASSERTIONS_FAKED)
|
||||||
|
message(STATUS "DUSK_BUILD_TESTS: forcing DUSK_ASSERTIONS_FAKED off")
|
||||||
|
set(DUSK_ASSERTIONS_FAKED OFF CACHE BOOL "" FORCE)
|
||||||
|
endif()
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the ps2 target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskps2)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
# Assertions are faked (compiled out) unless this is a Debug build.
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
else()
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
|
||||||
|
endif()
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||||
|
DUSK_PS2
|
||||||
|
)
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the psp target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskpsp)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
# Assertions are faked (compiled out) unless this is a Debug build.
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
else()
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
|
||||||
|
endif()
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||||
|
DUSK_PSP
|
||||||
|
DUSK_THREAD_PTHREAD
|
||||||
|
)
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the vita target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskvita)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
# Assertions are faked (compiled out) unless this is a Debug build.
|
||||||
|
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
else()
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED ON)
|
||||||
|
endif()
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY OFF)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||||
|
DUSK_VITA
|
||||||
|
DUSK_THREAD_PTHREAD
|
||||||
|
)
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
# Platform setup for the windows target, included by the root CMakeLists.txt.
|
||||||
|
# Only sets defaults and definitions; the root applies them.
|
||||||
|
|
||||||
|
# Source directories to build for this platform.
|
||||||
|
set(DUSK_PLATFORM_DIRS duskwindows dusksdl3 duskvulkan)
|
||||||
|
|
||||||
|
# Default values for the shared options declared in the root CMakeLists.txt.
|
||||||
|
set(DUSK_DEFAULT_ASSERTIONS_FAKED OFF)
|
||||||
|
set(DUSK_DEFAULT_BACKTRACE OFF)
|
||||||
|
set(DUSK_DEFAULT_TRACK_MEMORY ON)
|
||||||
|
|
||||||
|
# Platform definitions.
|
||||||
|
set(DUSK_PLATFORM_DEFINITIONS
|
||||||
|
DUSK_PLATFORM_ENDIAN_LITTLE
|
||||||
|
DUSK_WINDOWS
|
||||||
|
)
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 336 B |
Binary file not shown.
@@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<tileset version="1.10" tiledversion="1.11.1" name="entities" tilewidth="16" tileheight="16" tilecount="64" columns="8">
|
|
||||||
<image source="entities.png" width="128" height="128"/>
|
|
||||||
</tileset>
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"key": "test_event",
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"text": "This is a bucket"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"type": "text",
|
|
||||||
"text": "Dear God"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"meta": {
|
|
||||||
"language": {
|
|
||||||
"name": "English",
|
|
||||||
"code": "en"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"test": {
|
|
||||||
"npc": {
|
|
||||||
"text": "Hello, {{ name }}."
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
{
|
|
||||||
"automappingRulesFile": "",
|
|
||||||
"commands": [
|
|
||||||
],
|
|
||||||
"compatibilityVersion": 1100,
|
|
||||||
"extensionsPath": "extensions",
|
|
||||||
"folders": [
|
|
||||||
"."
|
|
||||||
],
|
|
||||||
"properties": [
|
|
||||||
],
|
|
||||||
"propertyTypes": [
|
|
||||||
{
|
|
||||||
"id": 1,
|
|
||||||
"name": "npcInteractType",
|
|
||||||
"storageType": "string",
|
|
||||||
"type": "enum",
|
|
||||||
"values": [
|
|
||||||
"NPC_INTERACT_TYPE_NONE",
|
|
||||||
"NPC_INTERACT_TYPE_TEXT",
|
|
||||||
"NPC_INTERACT_TYPE_CONVO",
|
|
||||||
"NPC_INTERACT_TYPE_EVENT"
|
|
||||||
],
|
|
||||||
"valuesAsFlags": false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": 2,
|
|
||||||
"name": "tileSolidType",
|
|
||||||
"storageType": "string",
|
|
||||||
"type": "enum",
|
|
||||||
"values": [
|
|
||||||
"TILE_SOLID_NONE",
|
|
||||||
"TILE_SOLID_FULL",
|
|
||||||
"TILE_SOLID_TRIANGLE_TOP_RIGHT",
|
|
||||||
"TILE_SOLID_TRIANGLE_TOP_LEFT",
|
|
||||||
"TILE_SOLID_TRIANGLE_BOTTOM_RIGHT",
|
|
||||||
"TILE_SOLID_TRIANGLE_BOTTOM_LEFT"
|
|
||||||
],
|
|
||||||
"valuesAsFlags": false
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
{
|
|
||||||
"activeFile": "map.tmj",
|
|
||||||
"expandedProjectPaths": [
|
|
||||||
".",
|
|
||||||
"templates"
|
|
||||||
],
|
|
||||||
"fileStates": {
|
|
||||||
":/automap-tiles.tsx": {
|
|
||||||
"scaleInDock": 1
|
|
||||||
},
|
|
||||||
"entities.tsx": {
|
|
||||||
"scaleInDock": 1,
|
|
||||||
"scaleInEditor": 1
|
|
||||||
},
|
|
||||||
"map.tmj": {
|
|
||||||
"scale": 3,
|
|
||||||
"selectedLayer": 2,
|
|
||||||
"viewCenter": {
|
|
||||||
"x": 6603.333333333333,
|
|
||||||
"y": 6846.5
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"minogram.tsx": {
|
|
||||||
"scaleInDock": 1,
|
|
||||||
"scaleInEditor": 16
|
|
||||||
},
|
|
||||||
"overworld.tsx": {
|
|
||||||
"scaleInDock": 1,
|
|
||||||
"scaleInEditor": 4
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"last.externalTilesetPath": "/home/yourwishes/htdocs/dusk/data",
|
|
||||||
"last.imagePath": "/home/yourwishes/htdocs/dusk/data",
|
|
||||||
"last.objectTemplatePath": "/home/yourwishes/htdocs/dusk/data/templates",
|
|
||||||
"openFiles": [
|
|
||||||
"map.tmj",
|
|
||||||
"overworld.tsx"
|
|
||||||
],
|
|
||||||
"project": "map project.tiled-project",
|
|
||||||
"property.type": "string",
|
|
||||||
"recentFiles": [
|
|
||||||
"overworld.tsx",
|
|
||||||
"map.tmj",
|
|
||||||
"minogram.tsx",
|
|
||||||
"entities.tsx"
|
|
||||||
],
|
|
||||||
"tileset.lastUsedFilter": "Tiled tileset files (*.tsx *.xml)",
|
|
||||||
"tileset.lastUsedFormat": "tsx",
|
|
||||||
"tileset.margin": 1,
|
|
||||||
"tileset.spacing": 1,
|
|
||||||
"tileset.tileSize": {
|
|
||||||
"height": 9,
|
|
||||||
"width": 5
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-477
@@ -1,477 +0,0 @@
|
|||||||
{ "compressionlevel":-1,
|
|
||||||
"height":720,
|
|
||||||
"infinite":true,
|
|
||||||
"layers":[
|
|
||||||
{
|
|
||||||
"chunks":[
|
|
||||||
{
|
|
||||||
"data":[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":384,
|
|
||||||
"y":416
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
|
|
||||||
1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 4, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 18, 19, 20, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 34, 35, 36, 1, 1],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":400,
|
|
||||||
"y":416
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
19, 19, 19, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 19, 19, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":416,
|
|
||||||
"y":416
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 115, 115, 115, 115, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":432,
|
|
||||||
"y":416
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":448,
|
|
||||||
"y":416
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":464,
|
|
||||||
"y":416
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":384,
|
|
||||||
"y":432
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":400,
|
|
||||||
"y":432
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 49, 49, 49, 49, 49, 49, 49, 49, 49, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 49, 49, 49, 67, 49, 49, 49, 49, 49, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 49, 49, 49, 49, 67, 49, 49, 49, 49, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 49, 49, 49, 49, 67, 49, 49, 49, 49, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 49, 49, 49, 49, 49, 67, 49, 49, 49, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 49, 49, 49, 49, 49, 49, 49, 49, 49, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 49, 49, 49, 49, 49, 49, 49, 67, 49, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 49, 49, 49, 49, 49, 49, 49, 67, 49, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 49, 49, 49, 49, 49, 49, 49, 49, 49, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 49, 49, 49, 49, 49, 49, 49, 49, 49, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":416,
|
|
||||||
"y":432
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[1, 115, 115, 115, 115, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 115, 115, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 115, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
115, 115, 115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
115, 115, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":432,
|
|
||||||
"y":432
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":448,
|
|
||||||
"y":432
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":464,
|
|
||||||
"y":432
|
|
||||||
}],
|
|
||||||
"height":32,
|
|
||||||
"id":1,
|
|
||||||
"name":"Base Layer",
|
|
||||||
"opacity":1,
|
|
||||||
"startx":384,
|
|
||||||
"starty":416,
|
|
||||||
"type":"tilelayer",
|
|
||||||
"visible":true,
|
|
||||||
"width":96,
|
|
||||||
"x":0,
|
|
||||||
"y":0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"chunks":[
|
|
||||||
{
|
|
||||||
"data":[0, 0, 0, 2, 3, 3, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 18, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 18, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 18, 0, 0, 0, 0, 6, 3, 3, 3, 3, 3, 3, 3,
|
|
||||||
0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 18, 0, 0, 0, 0, 22, 35, 35, 35, 35, 35, 35, 35,
|
|
||||||
0, 0, 0, 18, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 18, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 18, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 18, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 34, 35, 35, 35, 35, 36, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":400,
|
|
||||||
"y":416
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[0, 0, 2, 3, 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 18, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 18, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
3, 3, 5, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
35, 35, 21, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 18, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 18, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 18, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 18, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 18, 0, 0, 20, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 34, 35, 35, 36, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":416,
|
|
||||||
"y":416
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
98, 99, 99, 100, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
114, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
114, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
114, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
114, 0, 0, 116, 0, 0, 0, 234, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
114, 0, 0, 0, 99, 99, 99, 100, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
114, 0, 0, 0, 0, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":432,
|
|
||||||
"y":416
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 50, 51, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 66, 0, 68, 0, 85, 0, 71, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 82, 69, 54, 52, 0, 55, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 39, 0, 66, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 82, 69, 0, 52, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 82, 69, 54, 52, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 71, 0, 0, 0, 0, 82, 69, 0, 52, 0, 0, 0, 0, 130,
|
|
||||||
0, 0, 0, 0, 0, 55, 0, 0, 66, 0, 68, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 82, 83, 84, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":416,
|
|
||||||
"y":432
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data":[114, 0, 0, 0, 0, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
130, 131, 131, 0, 0, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 98, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 132, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
|
|
||||||
"height":16,
|
|
||||||
"width":16,
|
|
||||||
"x":432,
|
|
||||||
"y":432
|
|
||||||
}],
|
|
||||||
"height":32,
|
|
||||||
"id":5,
|
|
||||||
"locked":true,
|
|
||||||
"name":"Overlay Base Layer",
|
|
||||||
"opacity":1,
|
|
||||||
"startx":400,
|
|
||||||
"starty":416,
|
|
||||||
"type":"tilelayer",
|
|
||||||
"visible":true,
|
|
||||||
"width":48,
|
|
||||||
"x":0,
|
|
||||||
"y":0
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"draworder":"topdown",
|
|
||||||
"id":3,
|
|
||||||
"name":"Object Layer 1",
|
|
||||||
"objects":[
|
|
||||||
{
|
|
||||||
"gid":257,
|
|
||||||
"height":16,
|
|
||||||
"id":6,
|
|
||||||
"name":"Player Spawn",
|
|
||||||
"rotation":0,
|
|
||||||
"type":"player_spawn",
|
|
||||||
"visible":true,
|
|
||||||
"width":16,
|
|
||||||
"x":6578.25,
|
|
||||||
"y":6794.25
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id":13,
|
|
||||||
"properties":[
|
|
||||||
{
|
|
||||||
"name":"interactEvent",
|
|
||||||
"type":"string",
|
|
||||||
"value":"test_event"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name":"interactText",
|
|
||||||
"type":"string",
|
|
||||||
"value":"test.npc.text"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name":"interactType",
|
|
||||||
"propertytype":"npcInteractType",
|
|
||||||
"type":"string",
|
|
||||||
"value":"NPC_INTERACT_TYPE_EVENT"
|
|
||||||
}],
|
|
||||||
"template":"templates\/NPC.tx",
|
|
||||||
"x":6539.95833333333,
|
|
||||||
"y":6849.66666666666
|
|
||||||
}],
|
|
||||||
"opacity":1,
|
|
||||||
"type":"objectgroup",
|
|
||||||
"visible":true,
|
|
||||||
"x":0,
|
|
||||||
"y":0
|
|
||||||
}],
|
|
||||||
"nextlayerid":6,
|
|
||||||
"nextobjectid":14,
|
|
||||||
"orientation":"orthogonal",
|
|
||||||
"renderorder":"right-down",
|
|
||||||
"tiledversion":"1.11.1",
|
|
||||||
"tileheight":16,
|
|
||||||
"tilesets":[
|
|
||||||
{
|
|
||||||
"firstgid":1,
|
|
||||||
"source":"overworld.tsx"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"firstgid":257,
|
|
||||||
"source":"entities.tsx"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"firstgid":321,
|
|
||||||
"source":":\/automap-tiles.tsx"
|
|
||||||
}],
|
|
||||||
"tilewidth":16,
|
|
||||||
"type":"map",
|
|
||||||
"version":"1.10",
|
|
||||||
"width":500
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<tileset version="1.10" tiledversion="1.11.1" name="minogram" tilewidth="6" tileheight="10" spacing="0" margin="0" tilecount="91" columns="13">
|
|
||||||
<image source="minogram_6x10.png" width="78" height="70"/>
|
|
||||||
</tileset>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.1 KiB |
@@ -1,21 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<tileset version="1.10" tiledversion="1.11.1" name="overworld" tilewidth="16" tileheight="16" tilecount="256" columns="16">
|
|
||||||
<image source="tilemap.png" width="256" height="256"/>
|
|
||||||
<tile id="18">
|
|
||||||
<properties>
|
|
||||||
<property name="solidType" propertytype="tileSolidType" value="TILE_SOLID_NONE"/>
|
|
||||||
</properties>
|
|
||||||
</tile>
|
|
||||||
<tile id="54">
|
|
||||||
<objectgroup draworder="index" id="3">
|
|
||||||
<object id="3" x="5.04743" y="5.92885" width="7.93676" height="6.0751"/>
|
|
||||||
</objectgroup>
|
|
||||||
</tile>
|
|
||||||
<tile id="81">
|
|
||||||
<objectgroup draworder="index" id="2">
|
|
||||||
<object id="1" x="3.18182" y="0.181818">
|
|
||||||
<polygon points="-0.09375,-0.09375 -1.44602,6.42898 6.09091,13 12.9148,13.0057 12.8523,-0.125"/>
|
|
||||||
</object>
|
|
||||||
</objectgroup>
|
|
||||||
</tile>
|
|
||||||
</tileset>
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<template>
|
|
||||||
<tileset firstgid="1" source="../entities.tsx"/>
|
|
||||||
<object name="NPC" type="ENTITY_TYPE_NPC" gid="1" width="16" height="16">
|
|
||||||
<properties>
|
|
||||||
<property name="interactText" value=""/>
|
|
||||||
<property name="interactType" propertytype="npcInteractType" value="NPC_INTERACT_TYPE_NONE"/>
|
|
||||||
</properties>
|
|
||||||
</object>
|
|
||||||
</template>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 9.6 KiB |
Binary file not shown.
@@ -0,0 +1,5 @@
|
|||||||
|
FROM ubuntu:latest
|
||||||
|
ENV DEBIAN_FRONTEND=noninteractive
|
||||||
|
WORKDIR /workdir
|
||||||
|
COPY scripts/linux/install.sh /tmp/install.sh
|
||||||
|
RUN chmod +x /tmp/install.sh && /tmp/install.sh && rm /tmp/install.sh
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
FROM pspdev/pspdev:latest
|
||||||
|
WORKDIR /workdir
|
||||||
|
COPY scripts/psp/install.sh /tmp/install.sh
|
||||||
|
RUN chmod +x /tmp/install.sh && /tmp/install.sh && rm /tmp/install.sh
|
||||||
|
VOLUME ["/workdir"]
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
docker build -t dusk-linux -f docker/linux/Dockerfile .
|
||||||
|
docker run --rm -v "$(pwd):/workdir" dusk-linux /bin/bash -c "./scripts/linux/build.sh"
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
cmake -S . -B build-linux -DDUSK_TARGET_SYSTEM=linux
|
||||||
|
cmake --build build-linux -- -j"$(nproc)"
|
||||||
Executable
+42
@@ -0,0 +1,42 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Installs the packages required to build and test Dusk on Linux.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SUDO=""
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
SUDO="sudo"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v apt-get >/dev/null 2>&1; then
|
||||||
|
$SUDO apt-get update
|
||||||
|
$SUDO apt-get install -y \
|
||||||
|
build-essential \
|
||||||
|
cmake \
|
||||||
|
git \
|
||||||
|
python3 \
|
||||||
|
python3-pip \
|
||||||
|
python3-polib \
|
||||||
|
python3-pil \
|
||||||
|
python3-dotenv \
|
||||||
|
python3-numpy \
|
||||||
|
libsdl3-dev \
|
||||||
|
libvulkan-dev \
|
||||||
|
libzip-dev \
|
||||||
|
libbz2-dev \
|
||||||
|
liblzma-dev \
|
||||||
|
zlib1g-dev \
|
||||||
|
libssl-dev \
|
||||||
|
xz-utils
|
||||||
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
|
$SUDO dnf install -y \
|
||||||
|
git make gcc cmake python python-polib python3-pillow python3-dotenv \
|
||||||
|
python3-numpy SDL2-devel mesa-libGL-devel zlib-devel libzip-devel \
|
||||||
|
bzip2-devel openssl-devel xz xz-devel
|
||||||
|
elif command -v pacman >/dev/null 2>&1; then
|
||||||
|
$SUDO pacman -Sy --noconfirm --needed \
|
||||||
|
base-devel git cmake python python-polib python-pillow python-dotenv \
|
||||||
|
python-numpy sdl2 mesa libzip bzip2 openssl xz zlib
|
||||||
|
else
|
||||||
|
echo "Unsupported package manager; install dependencies manually." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
docker build -t dusk-linux -f docker/linux/Dockerfile .
|
||||||
|
docker run --rm -v "$(pwd):/workdir" dusk-linux /bin/bash -c "./scripts/linux/test.sh"
|
||||||
Executable
+7
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
rm -rf build-tests
|
||||||
|
cmake -S . -B build-tests -DDUSK_BUILD_TESTS=ON -DDUSK_TARGET_SYSTEM=linux
|
||||||
|
cmake --build build-tests -- -j"$(nproc)"
|
||||||
|
ctest --output-on-failure --test-dir build-tests
|
||||||
Executable
+5
@@ -0,0 +1,5 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
docker build -t dusk-psp -f docker/psp/Dockerfile .
|
||||||
|
docker run --rm -v "$(pwd):/workdir" dusk-psp /bin/bash -c "./scripts/psp/build.sh"
|
||||||
Executable
+12
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
cd "$(dirname "$0")/../.."
|
||||||
|
if [ -z "$PSPDEV" ]; then
|
||||||
|
echo "PSPDEV environment variable is not set." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
psp-cmake -S . -B build-psp \
|
||||||
|
-DDUSK_TARGET_SYSTEM=psp \
|
||||||
|
-DBUILD_PRX=1 \
|
||||||
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
|
cmake --build build-psp -- -j"$(nproc)"
|
||||||
Executable
+30
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Installs the packages required to build Dusk for the PSP. The PSP toolchain
|
||||||
|
# itself (pspdev) must already be installed; the pspdev/pspdev docker image
|
||||||
|
# provides it.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
SUDO=""
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
SUDO="sudo"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if command -v apk >/dev/null 2>&1; then
|
||||||
|
$SUDO apk add --no-cache git cmake make python3 py3-pip py3-dotenv
|
||||||
|
elif command -v apt-get >/dev/null 2>&1; then
|
||||||
|
$SUDO apt-get update
|
||||||
|
$SUDO apt-get install -y git cmake make python3 python3-pip python3-dotenv
|
||||||
|
elif command -v dnf >/dev/null 2>&1; then
|
||||||
|
$SUDO dnf install -y git cmake make python python3-dotenv
|
||||||
|
elif command -v pacman >/dev/null 2>&1; then
|
||||||
|
$SUDO pacman -Sy --noconfirm --needed git cmake make python python-dotenv
|
||||||
|
else
|
||||||
|
echo "Unsupported package manager; install dependencies manually." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$PSPDEV" ] || ! command -v psp-cmake >/dev/null 2>&1; then
|
||||||
|
echo "pspdev toolchain not found. Install it from https://pspdev.github.io/" >&2
|
||||||
|
echo "and set PSPDEV, or use scripts/psp/build-docker.sh." >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
add_subdirectory(dusk)
|
|
||||||
|
|
||||||
if(DUSK_TARGET_SYSTEM STREQUAL "linux")
|
|
||||||
add_subdirectory(dusksdl2)
|
|
||||||
elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
|
|
||||||
add_subdirectory(duskpsp)
|
|
||||||
add_subdirectory(dusksdl2)
|
|
||||||
else()
|
|
||||||
message(FATAL_ERROR "Unsupported target system: ${DUSK_TARGET_SYSTEM}")
|
|
||||||
endif()
|
|
||||||
+11
-26
@@ -1,37 +1,22 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
# Copyright (c) 2026 Dominic Masters
|
||||||
#
|
#
|
||||||
# This software is released under the MIT License.
|
# This software is released under the MIT License.
|
||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
# Libs
|
# Headers are included relative to this directory (e.g. "util/string.h").
|
||||||
target_link_libraries(${DUSK_TARGET_NAME}
|
target_include_directories(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
|
||||||
PUBLIC
|
${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
m
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Includes
|
# Modules
|
||||||
target_include_directories(${DUSK_TARGET_NAME}
|
add_subdirectory(asset)
|
||||||
PRIVATE
|
|
||||||
${CMAKE_CURRENT_LIST_DIR}
|
|
||||||
)
|
|
||||||
|
|
||||||
# Sources
|
|
||||||
target_sources(${DUSK_TARGET_NAME}
|
|
||||||
PRIVATE
|
|
||||||
game.c
|
|
||||||
input.c
|
|
||||||
)
|
|
||||||
|
|
||||||
# Subdirs
|
|
||||||
add_subdirectory(assert)
|
add_subdirectory(assert)
|
||||||
add_subdirectory(console)
|
add_subdirectory(console)
|
||||||
add_subdirectory(display)
|
add_subdirectory(display)
|
||||||
|
add_subdirectory(engine)
|
||||||
add_subdirectory(error)
|
add_subdirectory(error)
|
||||||
add_subdirectory(entity)
|
add_subdirectory(perf)
|
||||||
add_subdirectory(event)
|
add_subdirectory(resource)
|
||||||
add_subdirectory(item)
|
add_subdirectory(time)
|
||||||
add_subdirectory(locale)
|
add_subdirectory(thread)
|
||||||
add_subdirectory(physics)
|
|
||||||
add_subdirectory(ui)
|
|
||||||
add_subdirectory(util)
|
add_subdirectory(util)
|
||||||
add_subdirectory(world)
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
# Sources
|
# Sources
|
||||||
target_sources(${DUSK_TARGET_NAME}
|
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||||
PRIVATE
|
PUBLIC
|
||||||
assert.c
|
assert.c
|
||||||
)
|
)
|
||||||
+103
-18
@@ -1,31 +1,81 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2023 Dominic Masters
|
* Copyright (c) 2026 Dominic Masters
|
||||||
*
|
*
|
||||||
* This software is released under the MIT License.
|
* This software is released under the MIT License.
|
||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
|
#include "log/log.h"
|
||||||
|
#include "util/string.h"
|
||||||
|
#include "util/memory.h"
|
||||||
|
|
||||||
#ifndef ASSERTIONS_FAKED
|
#ifdef DUSK_THREAD_PTHREAD
|
||||||
void assertTrueImpl(
|
pthread_t ASSERT_MAIN_THREAD_ID = 0;
|
||||||
const char *file,
|
#endif
|
||||||
const int32_t line,
|
|
||||||
const bool x,
|
#ifndef DUSK_ASSERTIONS_FAKED
|
||||||
const char *message
|
void assertInit(void) {
|
||||||
) {
|
#ifdef DUSK_THREAD_PTHREAD
|
||||||
if(x != true) {
|
ASSERT_MAIN_THREAD_ID = pthread_self();
|
||||||
fprintf(
|
#endif
|
||||||
stderr,
|
|
||||||
"Assertion Failed in %s:%i\n\n%s\n",
|
|
||||||
file,
|
|
||||||
line,
|
|
||||||
message
|
|
||||||
);
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef DUSK_TEST_ASSERT
|
||||||
|
void assertTrueImpl(
|
||||||
|
const char *file,
|
||||||
|
const int32_t line,
|
||||||
|
const bool x,
|
||||||
|
const char *message
|
||||||
|
) {
|
||||||
|
mock_assert(
|
||||||
|
x == true,
|
||||||
|
message,
|
||||||
|
file,
|
||||||
|
line
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#ifdef DUSK_BACKTRACE
|
||||||
|
#include <execinfo.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
void assertLogBacktrace(void) {
|
||||||
|
void *frames[64];
|
||||||
|
int count = backtrace(frames, 64);
|
||||||
|
char **symbols = backtrace_symbols(frames, count);
|
||||||
|
memoryTrack(symbols);
|
||||||
|
logError("Stack trace:\n");
|
||||||
|
if(symbols) {
|
||||||
|
for(int i = 0; i < count; i++) {
|
||||||
|
logError(" %s\n", symbols[i]);
|
||||||
|
}
|
||||||
|
memoryFree(symbols);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void assertTrueImpl(
|
||||||
|
const char *file,
|
||||||
|
const int32_t line,
|
||||||
|
const bool x,
|
||||||
|
const char *message
|
||||||
|
) {
|
||||||
|
if(x != true) {
|
||||||
|
logError(
|
||||||
|
"Assertion Failed in %s:%i\n\n%s\n\n",
|
||||||
|
file,
|
||||||
|
line,
|
||||||
|
message
|
||||||
|
);
|
||||||
|
#ifdef DUSK_BACKTRACE
|
||||||
|
assertLogBacktrace();
|
||||||
|
#endif
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void assertFalseImpl(
|
void assertFalseImpl(
|
||||||
const char *file,
|
const char *file,
|
||||||
const int32_t line,
|
const int32_t line,
|
||||||
@@ -82,4 +132,39 @@
|
|||||||
) {
|
) {
|
||||||
assertUnreachableImpl(file, line, message);
|
assertUnreachableImpl(file, line, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void assertStringEqualImpl(
|
||||||
|
const char *file,
|
||||||
|
const int32_t line,
|
||||||
|
const char *a,
|
||||||
|
const char *b,
|
||||||
|
const char *message
|
||||||
|
) {
|
||||||
|
assertTrueImpl(file, line, stringCompare(a, b) == 0, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void assertIsMainThreadImpl(
|
||||||
|
const char *file,
|
||||||
|
const int32_t line,
|
||||||
|
const char *message
|
||||||
|
) {
|
||||||
|
#ifdef DUSK_THREAD_PTHREAD
|
||||||
|
assertTrueImpl(
|
||||||
|
file, line, pthread_self() == ASSERT_MAIN_THREAD_ID, message
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void assertNotMainThreadImpl(
|
||||||
|
const char *file,
|
||||||
|
const int32_t line,
|
||||||
|
const char *message
|
||||||
|
) {
|
||||||
|
#ifdef DUSK_THREAD_PTHREAD
|
||||||
|
assertTrueImpl(
|
||||||
|
file, line, pthread_self() != ASSERT_MAIN_THREAD_ID, message
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
+170
-6
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2023 Dominic Masters
|
* Copyright (c) 2026 Dominic Masters
|
||||||
*
|
*
|
||||||
* This software is released under the MIT License.
|
* This software is released under the MIT License.
|
||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
@@ -8,7 +8,35 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "dusk.h"
|
#include "dusk.h"
|
||||||
|
|
||||||
#ifndef ASSERTIONS_FAKED
|
#ifdef DUSK_TEST_ASSERT
|
||||||
|
#include <cmocka.h>
|
||||||
|
|
||||||
|
#ifdef DUSK_ASSERTIONS_FAKED
|
||||||
|
#error "Cannot fake assertions when DUSK_TEST_ASSERT is set."
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef DUSK_THREAD_PTHREAD
|
||||||
|
#include "thread/thread.h"
|
||||||
|
extern pthread_t ASSERT_MAIN_THREAD_ID;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef DUSK_ASSERTIONS_FAKED
|
||||||
|
#define DUSK_ASSERTIONS 1
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the assert system. Must be the very first call in engine
|
||||||
|
* startup.
|
||||||
|
*/
|
||||||
|
void assertInit(void);
|
||||||
|
|
||||||
|
#ifdef DUSK_BACKTRACE
|
||||||
|
/**
|
||||||
|
* Logs a stack trace of the current call stack to the error log.
|
||||||
|
*/
|
||||||
|
void assertLogBacktrace(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Assert a given value to be true.
|
* Assert a given value to be true.
|
||||||
*
|
*
|
||||||
@@ -96,41 +124,151 @@
|
|||||||
const char *message
|
const char *message
|
||||||
);
|
);
|
||||||
|
|
||||||
void assertMemoryRangeMatchesImpl(
|
/**
|
||||||
|
* Asserts two strings to be equal.
|
||||||
|
*
|
||||||
|
* @param file File that the assertion is being made from.
|
||||||
|
* @param line Line that the assertion is being made from.
|
||||||
|
* @param a First string to compare.
|
||||||
|
* @param b Second string to compare.
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
|
void assertStringEqualImpl(
|
||||||
const char *file,
|
const char *file,
|
||||||
const int32_t line,
|
const int32_t line,
|
||||||
const void *start,
|
const char *a,
|
||||||
const void *end,
|
const char *b,
|
||||||
const size_t size,
|
|
||||||
const char *message
|
const char *message
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the current thread is the main thread.
|
||||||
|
*
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
|
void assertIsMainThreadImpl(
|
||||||
|
const char *file,
|
||||||
|
const int32_t line,
|
||||||
|
const char *message
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the current thread is NOT the main thread.
|
||||||
|
*
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
|
void assertNotMainThreadImpl(
|
||||||
|
const char *file,
|
||||||
|
const int32_t line,
|
||||||
|
const char *message
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts a given value to be true.
|
||||||
|
*
|
||||||
|
* @param x Value to assert as true.
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
#define assertTrue(x, message) \
|
#define assertTrue(x, message) \
|
||||||
assertTrueImpl(__FILE__, __LINE__, x, message)
|
assertTrueImpl(__FILE__, __LINE__, x, message)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts a given statement to be false.
|
||||||
|
*
|
||||||
|
* @param x Value to assert as false.
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
#define assertFalse(x, message) \
|
#define assertFalse(x, message) \
|
||||||
assertFalseImpl(__FILE__, __LINE__, x, message)
|
assertFalseImpl(__FILE__, __LINE__, x, message)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that a given line of code is unreachable. Essentially a forced
|
||||||
|
* assertion failure, good for "edge cases"
|
||||||
|
*
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
#define assertUnreachable(message) \
|
#define assertUnreachable(message) \
|
||||||
assertUnreachableImpl(__FILE__, __LINE__, message)
|
assertUnreachableImpl(__FILE__, __LINE__, message)
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts a pointer is not null.
|
||||||
|
*
|
||||||
|
* @param pointer Pointer to check.
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
#define assertNotNull(pointer, message) \
|
#define assertNotNull(pointer, message) \
|
||||||
assertNotNullImpl(__FILE__, __LINE__, pointer, message)
|
assertNotNullImpl(__FILE__, __LINE__, pointer, message)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts a pointer is null.
|
||||||
|
*
|
||||||
|
* @param pointer Pointer to check.
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
#define assertNull(pointer, message) \
|
#define assertNull(pointer, message) \
|
||||||
assertNullImpl(__FILE__, __LINE__, pointer, message)
|
assertNullImpl(__FILE__, __LINE__, pointer, message)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts a function or code path is deprecated.
|
||||||
|
*
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
#define assertDeprecated(message) \
|
#define assertDeprecated(message) \
|
||||||
assertDeprecatedImpl(__FILE__, __LINE__, message)
|
assertDeprecatedImpl(__FILE__, __LINE__, message)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts a string's length is less than a maximum.
|
||||||
|
*
|
||||||
|
* @param str String to check.
|
||||||
|
* @param len Maximum length.
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
#define assertStrLenMax(str, len, message) \
|
#define assertStrLenMax(str, len, message) \
|
||||||
assertTrue(strlen(str) < len, message)
|
assertTrue(strlen(str) < len, message)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts a string's length is at least a minimum.
|
||||||
|
*
|
||||||
|
* @param str String to check.
|
||||||
|
* @param len Minimum length.
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
#define assertStrLenMin(str, len, message) \
|
#define assertStrLenMin(str, len, message) \
|
||||||
assertTrue(strlen(str) >= len, message)
|
assertTrue(strlen(str) >= len, message)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts two strings to be equal.
|
||||||
|
*
|
||||||
|
* @param a First string to compare.
|
||||||
|
* @param b Second string to compare.
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
|
#define assertStringEqual(a, b, message) \
|
||||||
|
assertStringEqualImpl(__FILE__, __LINE__, a, b, message)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the current thread is the main thread.
|
||||||
|
*
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
|
#define assertIsMainThread(message) \
|
||||||
|
assertIsMainThreadImpl(__FILE__, __LINE__, message)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the current thread is NOT the main thread.
|
||||||
|
*
|
||||||
|
* @param message Message to throw against assertion failure.
|
||||||
|
*/
|
||||||
|
#define assertNotMainThread(message) \
|
||||||
|
assertNotMainThreadImpl(__FILE__, __LINE__, message)
|
||||||
|
|
||||||
#else
|
#else
|
||||||
// If assertions are faked, we define the macros to do nothing.
|
// If assertions are faked, we define the macros to do nothing.
|
||||||
|
#define assertInit() ((void)0)
|
||||||
|
#define assertMainThreadInit() ((void)0)
|
||||||
|
#define assertIsMainThread(message) ((void)0)
|
||||||
|
#define assertNotMainThread(message) ((void)0)
|
||||||
#define assertTrue(x, message) ((void)0)
|
#define assertTrue(x, message) ((void)0)
|
||||||
#define assertFalse(x, message) ((void)0)
|
#define assertFalse(x, message) ((void)0)
|
||||||
#define assertUnreachable(message) ((void)0)
|
#define assertUnreachable(message) ((void)0)
|
||||||
@@ -139,5 +277,31 @@
|
|||||||
#define assertDeprecated(message) ((void)0)
|
#define assertDeprecated(message) ((void)0)
|
||||||
#define assertStrLenMax(str, len, message) ((void)0)
|
#define assertStrLenMax(str, len, message) ((void)0)
|
||||||
#define assertStrLenMin(str, len, message) ((void)0)
|
#define assertStrLenMin(str, len, message) ((void)0)
|
||||||
|
#define assertStringEqual(a, b, message) ((void)0)
|
||||||
|
#define assertIsMainThread(message) ((void)0)
|
||||||
|
#define assertNotMainThread(message) ((void)0)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// Static Assertions. These are compile time only, so they are never faked.
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts a constant expression at compile time. Never faked, even when
|
||||||
|
* DUSK_ASSERTIONS_FAKED is set.
|
||||||
|
*
|
||||||
|
* @param x Constant expression that must be true.
|
||||||
|
* @param message Message to show on failure, must be a string literal.
|
||||||
|
*/
|
||||||
|
#define assertStatic(x, message) \
|
||||||
|
_Static_assert(x, message)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts the size of a struct at compile time.
|
||||||
|
*
|
||||||
|
* @param struct The struct type to check.
|
||||||
|
* @param size The size in bytes the struct must be.
|
||||||
|
*/
|
||||||
|
#define assertStructSize(struct, size) \
|
||||||
|
assertStatic(sizeof(struct) == size, "Size of " #struct " must be " #size)
|
||||||
|
|
||||||
|
// EOF
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||||
|
PUBLIC
|
||||||
|
asset.c
|
||||||
|
assetfile.c
|
||||||
|
)
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "asset/asset.h"
|
||||||
|
#include "assert/assert.h"
|
||||||
|
#include "util/memory.h"
|
||||||
|
#include "util/string.h"
|
||||||
|
|
||||||
|
asset_t ASSET;
|
||||||
|
|
||||||
|
errorret_t assetInit(void) {
|
||||||
|
memoryZero(&ASSET, sizeof(asset_t));
|
||||||
|
|
||||||
|
// The platform must set ASSET.baseDirectory or throw an error.
|
||||||
|
errorChain(assetInitPlatform());
|
||||||
|
assertStrLenMin(ASSET.baseDirectory, 1, "Asset directory empty without error.");
|
||||||
|
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t assetGetPath(
|
||||||
|
const char_t *filename,
|
||||||
|
char_t *out,
|
||||||
|
const size_t outSize
|
||||||
|
) {
|
||||||
|
assertNotNull(filename, "Filename cannot be NULL.");
|
||||||
|
assertNotNull(out, "Output cannot be NULL.");
|
||||||
|
|
||||||
|
if(filename[0] == '\0') {
|
||||||
|
errorThrow("Asset filename cannot be empty.");
|
||||||
|
}
|
||||||
|
if(filename[0] == '/' || stringIncludesString(filename, "..")) {
|
||||||
|
errorThrow("Invalid asset filename: %s", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
int32_t len = stringFormat(out, outSize, "%s/%s", ASSET.baseDirectory, filename);
|
||||||
|
if(len < 0 || (size_t)len >= outSize) {
|
||||||
|
errorThrow("Asset path too long: %s", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool_t assetFileExists(const char_t *filename) {
|
||||||
|
char_t path[ASSET_PATH_MAX];
|
||||||
|
errorret_t ret = assetGetPath(filename, path, sizeof(path));
|
||||||
|
if(errorIsNotOk(ret)) {
|
||||||
|
errorCatch(ret);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILE *file = fopen(path, "rb");
|
||||||
|
if(file == NULL) return false;
|
||||||
|
fclose(file);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t assetDispose(void) {
|
||||||
|
errorChain(assetDisposePlatform());
|
||||||
|
memoryZero(&ASSET, sizeof(asset_t));
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "error/error.h"
|
||||||
|
#include "asset/assetplatform.h"
|
||||||
|
#include "asset/assetfile.h"
|
||||||
|
|
||||||
|
#ifndef assetInitPlatform
|
||||||
|
#error "Platform must define assetInitPlatform function."
|
||||||
|
#endif
|
||||||
|
#ifndef assetDisposePlatform
|
||||||
|
#error "Platform must define assetDisposePlatform function."
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define ASSET_BASE_DIRECTORY_MAX 256
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
// Directory that every asset filename is resolved relative to. Set by the
|
||||||
|
// platform in assetInitPlatform.
|
||||||
|
char_t baseDirectory[ASSET_BASE_DIRECTORY_MAX];
|
||||||
|
} asset_t;
|
||||||
|
|
||||||
|
extern asset_t ASSET;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the asset system. The platform locates the assets and sets
|
||||||
|
* ASSET.baseDirectory, or throws an error if it cannot.
|
||||||
|
*
|
||||||
|
* @return An errorret_t indicating success or failure.
|
||||||
|
*/
|
||||||
|
errorret_t assetInit(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Builds the full path of an asset on disk.
|
||||||
|
*
|
||||||
|
* @param filename Asset filename, relative to the asset directory.
|
||||||
|
* @param out Buffer to write the null terminated path into.
|
||||||
|
* @param outSize Size of the buffer in bytes.
|
||||||
|
* @return An error if the filename is invalid or the path does not fit.
|
||||||
|
*/
|
||||||
|
errorret_t assetGetPath(
|
||||||
|
const char_t *filename,
|
||||||
|
char_t *out,
|
||||||
|
const size_t outSize
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether an asset exists.
|
||||||
|
*
|
||||||
|
* @param filename Asset filename, relative to the asset directory.
|
||||||
|
* @return True if the asset exists and can be opened for reading.
|
||||||
|
*/
|
||||||
|
bool_t assetFileExists(const char_t *filename);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disposes of the asset system.
|
||||||
|
*
|
||||||
|
* @return An errorret_t indicating success or failure.
|
||||||
|
*/
|
||||||
|
errorret_t assetDispose(void);
|
||||||
@@ -0,0 +1,158 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "asset/asset.h"
|
||||||
|
#include "assert/assert.h"
|
||||||
|
#include "util/memory.h"
|
||||||
|
#include "util/string.h"
|
||||||
|
#include "util/math.h"
|
||||||
|
|
||||||
|
errorret_t assetFileInit(assetfile_t *file, const char_t *filename) {
|
||||||
|
assertNotNull(file, "Asset file cannot be NULL.");
|
||||||
|
assertNotNull(filename, "Filename cannot be NULL.");
|
||||||
|
assertStrLenMax(filename, ASSET_FILE_NAME_MAX, "Filename too long.");
|
||||||
|
|
||||||
|
memoryZero(file, sizeof(assetfile_t));
|
||||||
|
stringCopy(file->filename, filename, ASSET_FILE_NAME_MAX);
|
||||||
|
|
||||||
|
// Open temporarily to find the size.
|
||||||
|
char_t path[ASSET_PATH_MAX];
|
||||||
|
errorChain(assetGetPath(filename, path, sizeof(path)));
|
||||||
|
|
||||||
|
FILE *handle = fopen(path, "rb");
|
||||||
|
if(handle == NULL) {
|
||||||
|
errorThrow("Failed to open asset file: %s", filename);
|
||||||
|
}
|
||||||
|
if(fseek(handle, 0, SEEK_END) != 0) {
|
||||||
|
fclose(handle);
|
||||||
|
errorThrow("Failed to seek asset file: %s", filename);
|
||||||
|
}
|
||||||
|
long size = ftell(handle);
|
||||||
|
fclose(handle);
|
||||||
|
if(size < 0) {
|
||||||
|
errorThrow("Failed to get size of asset file: %s", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
file->size = (size_t)size;
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t assetFileOpen(assetfile_t *file) {
|
||||||
|
assertNotNull(file, "Asset file cannot be NULL.");
|
||||||
|
assertNull(file->file, "Asset file already open.");
|
||||||
|
|
||||||
|
char_t path[ASSET_PATH_MAX];
|
||||||
|
errorChain(assetGetPath(file->filename, path, sizeof(path)));
|
||||||
|
|
||||||
|
file->file = fopen(path, "rb");
|
||||||
|
if(file->file == NULL) {
|
||||||
|
errorThrow("Failed to open asset file: %s", file->filename);
|
||||||
|
}
|
||||||
|
file->position = 0;
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t assetFileRewind(assetfile_t *file) {
|
||||||
|
assertNotNull(file, "Asset file cannot be NULL.");
|
||||||
|
assertNotNull(file->file, "Asset file must be opened before rewinding.");
|
||||||
|
|
||||||
|
if(fseek(file->file, 0, SEEK_SET) != 0) {
|
||||||
|
errorThrow("Failed to rewind asset file: %s", file->filename);
|
||||||
|
}
|
||||||
|
file->position = 0;
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t assetFileRead(
|
||||||
|
assetfile_t *file,
|
||||||
|
void *buffer,
|
||||||
|
const size_t bufferSize
|
||||||
|
) {
|
||||||
|
assertNotNull(file, "Asset file cannot be NULL.");
|
||||||
|
assertNotNull(file->file, "Asset file must be opened before reading.");
|
||||||
|
|
||||||
|
// No buffer, skip the bytes.
|
||||||
|
if(buffer == NULL) {
|
||||||
|
size_t skipped = 0;
|
||||||
|
uint8_t temp[256];
|
||||||
|
while(skipped < bufferSize) {
|
||||||
|
size_t chunk = mathMin(bufferSize - skipped, sizeof(temp));
|
||||||
|
size_t got = fread(temp, 1, chunk, file->file);
|
||||||
|
skipped += got;
|
||||||
|
if(got < chunk) break;
|
||||||
|
}
|
||||||
|
file->position += skipped;
|
||||||
|
file->lastRead = skipped;
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t got = fread(buffer, 1, bufferSize, file->file);
|
||||||
|
if(got < bufferSize && ferror(file->file)) {
|
||||||
|
errorThrow("Failed to read from asset file: %s", file->filename);
|
||||||
|
}
|
||||||
|
file->position += got;
|
||||||
|
file->lastRead = got;
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t assetFileClose(assetfile_t *file) {
|
||||||
|
assertNotNull(file, "Asset file cannot be NULL.");
|
||||||
|
assertNotNull(file->file, "Asset file must be opened before closing.");
|
||||||
|
|
||||||
|
int result = fclose(file->file);
|
||||||
|
file->file = NULL;
|
||||||
|
file->position = 0;
|
||||||
|
if(result != 0) {
|
||||||
|
errorThrow("Failed to close asset file: %s", file->filename);
|
||||||
|
}
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t assetFileDispose(assetfile_t *file) {
|
||||||
|
assertNotNull(file, "Asset file cannot be NULL.");
|
||||||
|
if(file->file != NULL) {
|
||||||
|
errorChain(assetFileClose(file));
|
||||||
|
}
|
||||||
|
memoryZero(file, sizeof(assetfile_t));
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t assetFileReadEntire(
|
||||||
|
assetfile_t *file,
|
||||||
|
uint8_t **outBuffer,
|
||||||
|
size_t *outSize
|
||||||
|
) {
|
||||||
|
assertNotNull(file, "Asset file cannot be NULL.");
|
||||||
|
assertNotNull(outBuffer, "outBuffer cannot be NULL.");
|
||||||
|
assertNotNull(outSize, "outSize cannot be NULL.");
|
||||||
|
assertNull(file->file, "Asset file must be closed before reading entire.");
|
||||||
|
|
||||||
|
if(file->size == 0) {
|
||||||
|
errorThrow("Asset file is empty: %s", file->filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
errorChain(assetFileOpen(file));
|
||||||
|
|
||||||
|
uint8_t *buffer = (uint8_t *)memoryAllocate(file->size);
|
||||||
|
errorret_t ret = assetFileRead(file, buffer, file->size);
|
||||||
|
if(errorIsOk(ret) && file->lastRead != file->size) {
|
||||||
|
ret = errorThrowImpl(
|
||||||
|
&ERROR_STATE, ERROR_NOT_OK, __FILE__, __func__, __LINE__,
|
||||||
|
"Failed to read entire asset file: %s", file->filename
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if(errorIsNotOk(ret)) {
|
||||||
|
memoryFree(buffer);
|
||||||
|
assetFileClose(file);
|
||||||
|
errorChain(ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
errorChain(assetFileClose(file));
|
||||||
|
*outBuffer = buffer;
|
||||||
|
*outSize = file->size;
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "error/error.h"
|
||||||
|
|
||||||
|
#define ASSET_FILE_NAME_MAX 128
|
||||||
|
|
||||||
|
// Full on disk path, base directory plus filename.
|
||||||
|
#define ASSET_PATH_MAX 512
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char_t filename[ASSET_FILE_NAME_MAX];
|
||||||
|
FILE *file;
|
||||||
|
size_t size;
|
||||||
|
size_t position;
|
||||||
|
size_t lastRead;
|
||||||
|
} assetfile_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes an asset file, checking it exists and reading its size. Does not
|
||||||
|
* open it.
|
||||||
|
*
|
||||||
|
* @param file The asset file to initialize.
|
||||||
|
* @param filename Asset filename, relative to the asset directory.
|
||||||
|
* @return An error if the file does not exist or cannot be read.
|
||||||
|
*/
|
||||||
|
errorret_t assetFileInit(assetfile_t *file, const char_t *filename);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Opens an asset file for reading, positioned at the start.
|
||||||
|
*
|
||||||
|
* @param file The asset file to open. Must not already be open.
|
||||||
|
* @return An error if the file cannot be opened.
|
||||||
|
*/
|
||||||
|
errorret_t assetFileOpen(assetfile_t *file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Moves an open asset file back to its start.
|
||||||
|
*
|
||||||
|
* @param file The asset file to rewind. Must be open.
|
||||||
|
* @return An error if the file cannot be rewound.
|
||||||
|
*/
|
||||||
|
errorret_t assetFileRewind(assetfile_t *file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads bytes from an open asset file. The number of bytes actually read is
|
||||||
|
* stored in file->lastRead, which is less than bufferSize at the end of the
|
||||||
|
* file.
|
||||||
|
*
|
||||||
|
* @param file The asset file to read from. Must be open.
|
||||||
|
* @param buffer Buffer to read into. If NULL the bytes are skipped.
|
||||||
|
* @param bufferSize Number of bytes to read.
|
||||||
|
* @return An error if reading fails.
|
||||||
|
*/
|
||||||
|
errorret_t assetFileRead(
|
||||||
|
assetfile_t *file,
|
||||||
|
void *buffer,
|
||||||
|
const size_t bufferSize
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes an open asset file.
|
||||||
|
*
|
||||||
|
* @param file The asset file to close. Must be open.
|
||||||
|
* @return An error if the file cannot be closed.
|
||||||
|
*/
|
||||||
|
errorret_t assetFileClose(assetfile_t *file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disposes an asset file, closing it first if it is still open.
|
||||||
|
*
|
||||||
|
* @param file The asset file to dispose.
|
||||||
|
* @return An error if the file cannot be closed.
|
||||||
|
*/
|
||||||
|
errorret_t assetFileDispose(assetfile_t *file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a whole asset file into a newly allocated buffer. The file is opened
|
||||||
|
* and closed by this call, and must not already be open.
|
||||||
|
*
|
||||||
|
* @param file The asset file to read, already initialized.
|
||||||
|
* @param outBuffer Output buffer, allocated with memoryAllocate. The caller
|
||||||
|
* must memoryFree it.
|
||||||
|
* @param outSize Output size of the buffer in bytes.
|
||||||
|
* @return An error if the file cannot be read in full.
|
||||||
|
*/
|
||||||
|
errorret_t assetFileReadEntire(
|
||||||
|
assetfile_t *file,
|
||||||
|
uint8_t **outBuffer,
|
||||||
|
size_t *outSize
|
||||||
|
);
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
# Copyright (c) 2026 Dominic Masters
|
||||||
#
|
#
|
||||||
# This software is released under the MIT License.
|
# This software is released under the MIT License.
|
||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
# Sources
|
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||||
target_sources(${DUSK_TARGET_NAME}
|
PUBLIC
|
||||||
PRIVATE
|
|
||||||
console.c
|
console.c
|
||||||
consolecmd.c
|
|
||||||
consolevar.c
|
|
||||||
)
|
)
|
||||||
+14
-346
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2025 Dominic Masters
|
* Copyright (c) 2026 Dominic Masters
|
||||||
*
|
*
|
||||||
* This software is released under the MIT License.
|
* This software is released under the MIT License.
|
||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
@@ -9,35 +9,15 @@
|
|||||||
#include "assert/assert.h"
|
#include "assert/assert.h"
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
#include "input.h"
|
#include "log/log.h"
|
||||||
|
|
||||||
console_t CONSOLE;
|
console_t CONSOLE;
|
||||||
|
|
||||||
void consoleInit() {
|
void consoleInit(void) {
|
||||||
memoryZero(&CONSOLE, sizeof(console_t));
|
memoryZero(&CONSOLE, sizeof(console_t));
|
||||||
|
CONSOLE.visible = false;
|
||||||
// Register the get and set command.
|
// CONSOLE.visible = true;
|
||||||
CONSOLE.cmdGet = consoleRegCmd("get", cmdGet);
|
threadMutexInit(&CONSOLE.printMutex);
|
||||||
CONSOLE.cmdSet = consoleRegCmd("set", cmdSet);
|
|
||||||
consoleRegCmd("echo", cmdEcho);
|
|
||||||
|
|
||||||
consolePrint(" = Dawn Console = ");
|
|
||||||
}
|
|
||||||
|
|
||||||
consolecmd_t * consoleRegCmd(const char_t *name, consolecmdfunc_t function) {
|
|
||||||
consolecmd_t *cmd = &CONSOLE.commands[CONSOLE.commandCount++];
|
|
||||||
consoleCmdInit(cmd, name, function);
|
|
||||||
return cmd;
|
|
||||||
}
|
|
||||||
|
|
||||||
consolevar_t * consoleRegVar(
|
|
||||||
const char_t *name,
|
|
||||||
const char_t *value,
|
|
||||||
consolevarchanged_t event
|
|
||||||
) {
|
|
||||||
consolevar_t *var = &CONSOLE.variables[CONSOLE.variableCount++];
|
|
||||||
consoleVarInitListener(var, name, value, event);
|
|
||||||
return var;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void consolePrint(const char_t *message, ...) {
|
void consolePrint(const char_t *message, ...) {
|
||||||
@@ -48,334 +28,22 @@ void consolePrint(const char_t *message, ...) {
|
|||||||
int32_t len = stringFormatVA(buffer, CONSOLE_LINE_MAX, message, args);
|
int32_t len = stringFormatVA(buffer, CONSOLE_LINE_MAX, message, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
|
|
||||||
// Move all lines back
|
threadMutexLock(&CONSOLE.printMutex);
|
||||||
memoryMove(
|
memoryMove(
|
||||||
CONSOLE.line[0],
|
CONSOLE.line[0],
|
||||||
CONSOLE.line[1],
|
CONSOLE.line[1],
|
||||||
(CONSOLE_HISTORY_MAX - 1) * CONSOLE_LINE_MAX
|
(CONSOLE_HISTORY_MAX - 1) * CONSOLE_LINE_MAX
|
||||||
);
|
);
|
||||||
|
memoryCopy(CONSOLE.line[CONSOLE_HISTORY_MAX - 1], buffer, len + 1);
|
||||||
|
threadMutexUnlock(&CONSOLE.printMutex);
|
||||||
|
|
||||||
// Copy the new line
|
logDebug("%s\n", buffer);
|
||||||
memoryCopy(
|
|
||||||
CONSOLE.line[CONSOLE_HISTORY_MAX - 1],
|
|
||||||
buffer,
|
|
||||||
len + 1
|
|
||||||
);
|
|
||||||
printf("%s\n", buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void consoleExec(const char_t *line) {
|
void consoleUpdate(void) {
|
||||||
assertNotNull(line, "line must not be NULL");
|
// TODO: Toggle console visibility once the input system exists.
|
||||||
assertTrue(
|
|
||||||
CONSOLE.execBufferCount < CONSOLE_EXEC_BUFFER_MAX,
|
|
||||||
"Too many commands in the buffer."
|
|
||||||
);
|
|
||||||
|
|
||||||
char_t buffer[CONSOLE_LINE_MAX];
|
|
||||||
size_t i = 0, j = 0;
|
|
||||||
char_t c;
|
|
||||||
consoleexecstate_t state = CONSOLE_EXEC_STATE_INITIAL;
|
|
||||||
consolecmdexec_t *exec = NULL;
|
|
||||||
|
|
||||||
while(state != CONSOLE_EXEC_STATE_FULLY_PARSED) {
|
|
||||||
c = line[i];
|
|
||||||
|
|
||||||
switch(state) {
|
|
||||||
case CONSOLE_EXEC_STATE_INITIAL:
|
|
||||||
assertTrue(j == 0, "Buffer not empty?");
|
|
||||||
|
|
||||||
if(c == '\0') {
|
|
||||||
state = CONSOLE_EXEC_STATE_FULLY_PARSED;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(stringIsWhitespace(c) || c == ';') {
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
state = CONSOLE_EXEC_STATE_PARSE_CMD;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CONSOLE_EXEC_STATE_PARSE_CMD:
|
|
||||||
if(stringIsWhitespace(c) || c == '\0' || c == ';') {
|
|
||||||
state = CONSOLE_EXEC_STATE_CMD_PARSED;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(c == '"') {
|
|
||||||
// Can't handle quotes within the command.
|
|
||||||
consolePrint("Invalid command");
|
|
||||||
while(c != '\0' && c != ';') c = line[++i];
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer[j++] = c;
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if(j >= CONSOLE_LINE_MAX) {
|
|
||||||
consolePrint("Command too long");
|
|
||||||
state = CONSOLE_EXEC_STATE_FULLY_PARSED;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CONSOLE_EXEC_STATE_CMD_PARSED:
|
|
||||||
if(j == 0) {
|
|
||||||
state = CONSOLE_EXEC_STATE_INITIAL;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create exec
|
|
||||||
assertNull(exec, "Existing command parsing?");
|
|
||||||
|
|
||||||
exec = &CONSOLE.execBuffer[CONSOLE.execBufferCount];
|
|
||||||
memoryZero(exec, sizeof(consolecmdexec_t));
|
|
||||||
|
|
||||||
buffer[j] = '\0';
|
|
||||||
stringCopy(exec->command, buffer, CONSOLE_LINE_MAX);
|
|
||||||
state = CONSOLE_EXEC_STATE_FIND_ARG;
|
|
||||||
|
|
||||||
j = 0;// Free up buffer
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CONSOLE_EXEC_STATE_FIND_ARG:
|
|
||||||
if(c == '\0' || c == ';') {
|
|
||||||
state = CONSOLE_EXEC_STATE_CMD_FINISHED;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(stringIsWhitespace(c)) {
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(c == '"') {
|
|
||||||
state = CONSOLE_EXEC_STATE_PARSE_ARG_QUOTED;
|
|
||||||
i++;
|
|
||||||
} else {
|
|
||||||
state = CONSOLE_EXEC_STATE_PARSE_ARG;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CONSOLE_EXEC_STATE_PARSE_ARG:
|
|
||||||
if(stringIsWhitespace(c) || c == '\0' || c == ';') {
|
|
||||||
state = CONSOLE_EXEC_STATE_ARG_PARSED;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer[j++] = c;
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if(j >= CONSOLE_LINE_MAX) {
|
|
||||||
consolePrint("Arg too long");
|
|
||||||
state = CONSOLE_EXEC_STATE_FULLY_PARSED;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CONSOLE_EXEC_STATE_PARSE_ARG_QUOTED:
|
|
||||||
if(c == '"') {
|
|
||||||
state = CONSOLE_EXEC_STATE_ARG_PARSED;
|
|
||||||
i++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(c == '\0' || c == ';') {
|
|
||||||
consolePrint("Unterminated quote");
|
|
||||||
state = CONSOLE_EXEC_STATE_FULLY_PARSED;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(c == '\\') {
|
|
||||||
c = line[++i];
|
|
||||||
|
|
||||||
if(c == '\0' || c == ';') {
|
|
||||||
consolePrint("Unterminated quote");
|
|
||||||
state = CONSOLE_EXEC_STATE_FULLY_PARSED;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buffer[j++] = c;
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if(j >= CONSOLE_LINE_MAX) {
|
|
||||||
consolePrint("Arg too long");
|
|
||||||
state = CONSOLE_EXEC_STATE_FULLY_PARSED;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CONSOLE_EXEC_STATE_ARG_PARSED:
|
|
||||||
buffer[j] = '\0';
|
|
||||||
stringCopy(exec->argv[exec->argc++], buffer, CONSOLE_LINE_MAX);
|
|
||||||
state = CONSOLE_EXEC_STATE_FIND_ARG;
|
|
||||||
j = 0;// Free up buffer
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CONSOLE_EXEC_STATE_CMD_FINISHED:
|
|
||||||
assertNotNull(exec, "No command found?");
|
|
||||||
|
|
||||||
// Now, is there a command that matches?
|
|
||||||
for(uint32_t k = 0; k < CONSOLE.commandCount; k++) {
|
|
||||||
consolecmd_t *cmd = &CONSOLE.commands[k];
|
|
||||||
if(stringCompare(cmd->name, exec->command) != 0) continue;
|
|
||||||
exec->cmd = cmd;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(exec->cmd == NULL) {
|
|
||||||
// Command wasn't found, is there a variable that matches?
|
|
||||||
for(uint32_t k = 0; k < CONSOLE.variableCount; k++) {
|
|
||||||
consolevar_t *var = &CONSOLE.variables[k];
|
|
||||||
if(stringCompare(var->name, exec->command) != 0) continue;
|
|
||||||
|
|
||||||
// Matching variable found, is this a GET or a SET?
|
|
||||||
if(exec->argc == 0) {
|
|
||||||
exec->cmd = CONSOLE.cmdGet;
|
|
||||||
stringCopy(exec->argv[0], exec->command, CONSOLE_LINE_MAX);
|
|
||||||
exec->argc = 1;
|
|
||||||
} else {
|
|
||||||
exec->cmd = CONSOLE.cmdSet;
|
|
||||||
stringCopy(exec->argv[1], exec->argv[0], CONSOLE_LINE_MAX);
|
|
||||||
stringCopy(exec->argv[0], exec->command, CONSOLE_LINE_MAX);
|
|
||||||
exec->argc = 2;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(exec->cmd == NULL) {
|
|
||||||
consolePrint("Command not found", exec->command);
|
|
||||||
exec = NULL;
|
|
||||||
state = CONSOLE_EXEC_STATE_INITIAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Prep for next command.
|
|
||||||
exec = NULL;
|
|
||||||
state = CONSOLE_EXEC_STATE_INITIAL;
|
|
||||||
CONSOLE.execBufferCount++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
assertUnreachable("Invalid state.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmdGet(const consolecmdexec_t *exec) {
|
void consoleDispose(void) {
|
||||||
assertTrue(
|
threadMutexDispose(&CONSOLE.printMutex);
|
||||||
exec->argc >= 1,
|
|
||||||
"Get command requires 1 argument."
|
|
||||||
);
|
|
||||||
|
|
||||||
for(uint32_t i = 0; i < CONSOLE.variableCount; i++) {
|
|
||||||
consolevar_t *var = &CONSOLE.variables[i];
|
|
||||||
if(stringCompare(var->name, exec->argv[0]) != 0) continue;
|
|
||||||
consolePrint("%s", var->value);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
consolePrint("Error: Variable '%s' not found.", exec->argv[0]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmdSet(const consolecmdexec_t *exec) {
|
|
||||||
assertTrue(exec->argc >= 2, "set command requires 2 arguments.");
|
|
||||||
|
|
||||||
for(uint32_t i = 0; i < CONSOLE.variableCount; i++) {
|
|
||||||
consolevar_t *var = &CONSOLE.variables[i];
|
|
||||||
if(stringCompare(var->name, exec->argv[0]) != 0) continue;
|
|
||||||
consoleVarSetValue(var, exec->argv[1]);
|
|
||||||
consolePrint("%s %s", var->name, var->value);
|
|
||||||
for(i = 0; i < var->eventCount; i++) {
|
|
||||||
assertNotNull(var->events[i], "Event is NULL");
|
|
||||||
var->events[i](var);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
consolePrint("Error: Variable '%s' not found.", exec->argv[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cmdEcho(const consolecmdexec_t *exec) {
|
|
||||||
assertTrue(
|
|
||||||
exec->argc >= 1,
|
|
||||||
"echo command requires 1 argument."
|
|
||||||
);
|
|
||||||
|
|
||||||
consolePrint("%s", exec->argv[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// May move these later
|
|
||||||
void consoleUpdate() {
|
|
||||||
for(uint32_t i = 0; i < CONSOLE.execBufferCount; i++) {
|
|
||||||
consolecmdexec_t *exec = &CONSOLE.execBuffer[i];
|
|
||||||
assertNotNull(exec->cmd, "Command execution has no command.");
|
|
||||||
exec->cmd->function(exec);
|
|
||||||
}
|
|
||||||
|
|
||||||
// #if DUSK_KEYBOARD_SUPPORT == 1
|
|
||||||
// uint8_t key;
|
|
||||||
// while((key = inputKeyboardPop()) != 0) {
|
|
||||||
// printf("Key pressed: %c\n", key);
|
|
||||||
// switch(key) {
|
|
||||||
// case 0:
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case INPUT_KEY_ENTER:
|
|
||||||
// consoleExec(CONSOLE.inputBuffer);
|
|
||||||
// CONSOLE.inputIndex = 0;
|
|
||||||
// CONSOLE.inputBuffer[0] = '\0';
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// case INPUT_KEY_BACKSPACE:
|
|
||||||
// if(CONSOLE.inputIndex > 0) {
|
|
||||||
// CONSOLE.inputIndex--;
|
|
||||||
// CONSOLE.inputBuffer[CONSOLE.inputIndex] = '\0';
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// default:
|
|
||||||
// if(
|
|
||||||
// key >= INPUT_KEY_ASCII_START && key <= INPUT_KEY_ASCII_END &&
|
|
||||||
// CONSOLE.inputIndex < CONSOLE_LINE_MAX - 1
|
|
||||||
// ) {
|
|
||||||
// CONSOLE.inputBuffer[CONSOLE.inputIndex++] = key;
|
|
||||||
// CONSOLE.inputBuffer[CONSOLE.inputIndex] = '\0';
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// #endif
|
|
||||||
|
|
||||||
// Clear the exec buffer
|
|
||||||
CONSOLE.execBufferCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// void consoleDraw() {
|
|
||||||
// if(!CONSOLE.open) return;
|
|
||||||
|
|
||||||
// size_t i = 0;
|
|
||||||
// char_t *line;
|
|
||||||
// int32_t fontSize = 10;
|
|
||||||
// do {
|
|
||||||
// line = CONSOLE.line[i];
|
|
||||||
// if(line[0] == '\0') {
|
|
||||||
// i++;
|
|
||||||
// continue;
|
|
||||||
// }
|
|
||||||
// DrawText(line, 0, i*fontSize, fontSize, YELLOW);
|
|
||||||
// i++;
|
|
||||||
// } while(i < CONSOLE_HISTORY_MAX);
|
|
||||||
|
|
||||||
// DrawText(
|
|
||||||
// CONSOLE.inputBuffer, 0,
|
|
||||||
// (CONSOLE_HISTORY_MAX + 1) * fontSize,
|
|
||||||
// fontSize,
|
|
||||||
// PINK
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
+16
-76
@@ -1,50 +1,23 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2025 Dominic Masters
|
* Copyright (c) 2026 Dominic Masters
|
||||||
*
|
*
|
||||||
* This software is released under the MIT License.
|
* This software is released under the MIT License.
|
||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "consolevar.h"
|
#include "error/error.h"
|
||||||
#include "consolecmd.h"
|
#include "dusk.h"
|
||||||
|
#include "thread/thread.h"
|
||||||
|
|
||||||
typedef enum {
|
#define CONSOLE_LINE_MAX 128
|
||||||
CONSOLE_EXEC_STATE_INITIAL,
|
#define CONSOLE_HISTORY_MAX 16
|
||||||
CONSOLE_EXEC_STATE_PARSE_CMD,
|
#define CONSOLE_EXEC_BUFFER_MAX 32
|
||||||
CONSOLE_EXEC_STATE_CMD_PARSED,
|
|
||||||
|
|
||||||
CONSOLE_EXEC_STATE_FIND_ARG,
|
|
||||||
CONSOLE_EXEC_STATE_PARSE_ARG,
|
|
||||||
CONSOLE_EXEC_STATE_PARSE_ARG_QUOTED,
|
|
||||||
CONSOLE_EXEC_STATE_ARG_PARSED,
|
|
||||||
|
|
||||||
CONSOLE_EXEC_STATE_CMD_FINISHED,
|
|
||||||
CONSOLE_EXEC_STATE_FULLY_PARSED
|
|
||||||
} consoleexecstate_t;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
consolecmd_t commands[CONSOLE_COMMANDS_MAX];
|
|
||||||
uint32_t commandCount;
|
|
||||||
|
|
||||||
consolevar_t variables[CONSOLE_VARIABLES_MAX];
|
|
||||||
uint32_t variableCount;
|
|
||||||
|
|
||||||
char_t line[CONSOLE_HISTORY_MAX][CONSOLE_LINE_MAX];
|
char_t line[CONSOLE_HISTORY_MAX][CONSOLE_LINE_MAX];
|
||||||
|
|
||||||
consolecmdexec_t execBuffer[CONSOLE_EXEC_BUFFER_MAX];
|
|
||||||
uint32_t execBufferCount;
|
|
||||||
|
|
||||||
consolecmd_t *cmdGet;
|
|
||||||
consolecmd_t *cmdSet;
|
|
||||||
|
|
||||||
bool_t visible;
|
bool_t visible;
|
||||||
|
threadmutex_t printMutex;
|
||||||
// May move these later
|
|
||||||
// #if DUSK_KEYBOARD_SUPPORT == 1
|
|
||||||
// char_t inputBuffer[CONSOLE_LINE_MAX];
|
|
||||||
// int32_t inputIndex;
|
|
||||||
// #endif
|
|
||||||
} console_t;
|
} console_t;
|
||||||
|
|
||||||
extern console_t CONSOLE;
|
extern console_t CONSOLE;
|
||||||
@@ -52,54 +25,21 @@ extern console_t CONSOLE;
|
|||||||
/**
|
/**
|
||||||
* Initializes the console.
|
* Initializes the console.
|
||||||
*/
|
*/
|
||||||
void consoleInit();
|
void consoleInit(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a console command.
|
* Prints a message to the console history.
|
||||||
*
|
*
|
||||||
* @param name The name of the command.
|
* @param message The message to print (printf-style).
|
||||||
* @param function The function to execute when the command is called.
|
|
||||||
* @return The registered command.
|
|
||||||
*/
|
*/
|
||||||
consolecmd_t * consoleRegCmd(const char_t *name, consolecmdfunc_t function);
|
void consolePrint(const char_t *message, ...);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a console variable.
|
* Processes pending queued script lines. Call once per frame from main thread.
|
||||||
*
|
|
||||||
* @param name The name of the variable.
|
|
||||||
* @param value The initial value of the variable.
|
|
||||||
* @param event The event to register.
|
|
||||||
* @return The registered variable.
|
|
||||||
*/
|
*/
|
||||||
consolevar_t * consoleRegVar(
|
void consoleUpdate(void);
|
||||||
const char_t *name,
|
|
||||||
const char_t *value,
|
|
||||||
consolevarchanged_t event
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the value of a console variable.
|
* Disposes of the console.
|
||||||
*
|
|
||||||
* @param name The name of the variable.
|
|
||||||
* @param value The new value of the variable.
|
|
||||||
*/
|
*/
|
||||||
void consolePrint(
|
void consoleDispose(void);
|
||||||
const char_t *message,
|
|
||||||
...
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Executes a console command.
|
|
||||||
*
|
|
||||||
* @param line The line to execute.
|
|
||||||
*/
|
|
||||||
void consoleExec(const char_t *line);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Processes the console's pending commands.
|
|
||||||
*/
|
|
||||||
void consoleUpdate();
|
|
||||||
|
|
||||||
void cmdGet(const consolecmdexec_t *exec);
|
|
||||||
void cmdSet(const consolecmdexec_t *exec);
|
|
||||||
void cmdEcho(const consolecmdexec_t *exec);
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "consolecmd.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
#include "util/memory.h"
|
|
||||||
#include "util/string.h"
|
|
||||||
|
|
||||||
void consoleCmdInit(
|
|
||||||
consolecmd_t *cmd,
|
|
||||||
const char_t *name,
|
|
||||||
consolecmdfunc_t function
|
|
||||||
) {
|
|
||||||
assertNotNull(cmd, "Command is NULL.");
|
|
||||||
assertNotNull(name, "Name is NULL.");
|
|
||||||
assertNotNull(function, "Function is NULL.");
|
|
||||||
assertStrLenMin(name, 1, "Name is empty.");
|
|
||||||
assertStrLenMax(name, CONSOLE_CMD_NAME_MAX, "Name is too long.");
|
|
||||||
|
|
||||||
memoryZero(cmd, sizeof(consolecmd_t));
|
|
||||||
stringCopy(cmd->name, name, CONSOLE_CMD_NAME_MAX);
|
|
||||||
cmd->function = function;
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "dusk.h"
|
|
||||||
#include "consoledefs.h"
|
|
||||||
|
|
||||||
typedef struct consolecmd_s consolecmd_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
consolecmd_t *cmd;
|
|
||||||
char_t command[CONSOLE_LINE_MAX];
|
|
||||||
char_t argv[CONSOLE_CMD_ARGC_MAX][CONSOLE_LINE_MAX];
|
|
||||||
uint32_t argc;
|
|
||||||
} consolecmdexec_t;
|
|
||||||
|
|
||||||
typedef void (*consolecmdfunc_t)(const consolecmdexec_t *exec);
|
|
||||||
|
|
||||||
typedef struct consolecmd_s {
|
|
||||||
char_t name[CONSOLE_CMD_NAME_MAX];
|
|
||||||
consolecmdfunc_t function;
|
|
||||||
} consolecmd_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes a console command.
|
|
||||||
*
|
|
||||||
* @param cmd Pointer to the console command.
|
|
||||||
* @param name The name of the command.
|
|
||||||
* @param function The function to execute when the command is called.
|
|
||||||
*/
|
|
||||||
void consoleCmdInit(
|
|
||||||
consolecmd_t *cmd,
|
|
||||||
const char_t *name,
|
|
||||||
consolecmdfunc_t function
|
|
||||||
);
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#define CONSOLE_CMD_NAME_MAX 32
|
|
||||||
#define CONSOLE_CMD_ARGC_MAX 16
|
|
||||||
|
|
||||||
#define CONSOLE_COMMANDS_MAX 128
|
|
||||||
#define CONSOLE_VARIABLES_MAX 128
|
|
||||||
#define CONSOLE_LINE_MAX 256
|
|
||||||
#define CONSOLE_HISTORY_MAX 32
|
|
||||||
#define CONSOLE_EXEC_BUFFER_MAX 16
|
|
||||||
|
|
||||||
#define CONSOLE_VAR_NAME_MAX 32
|
|
||||||
#define CONSOLE_VAR_VALUE_MAX 128
|
|
||||||
#define CONSOLE_VAR_EVENTS_MAX 8
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "consolevar.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
#include "util/memory.h"
|
|
||||||
#include "util/string.h"
|
|
||||||
|
|
||||||
void consoleVarInit(
|
|
||||||
consolevar_t *var,
|
|
||||||
const char_t *name,
|
|
||||||
const char_t *value
|
|
||||||
) {
|
|
||||||
assertNotNull(var, "var must not be NULL");
|
|
||||||
assertNotNull(name, "name must not be NULL");
|
|
||||||
assertNotNull(value, "value must not be NULL");
|
|
||||||
|
|
||||||
assertStrLenMin(name, 1, "name must not be empty");
|
|
||||||
assertStrLenMax(name, CONSOLE_VAR_NAME_MAX, "name is too long");
|
|
||||||
assertStrLenMax(value, CONSOLE_VAR_VALUE_MAX, "value is too long");
|
|
||||||
|
|
||||||
memoryZero(var, sizeof(consolevar_t));
|
|
||||||
stringCopy(var->name, name, CONSOLE_VAR_NAME_MAX);
|
|
||||||
stringCopy(var->value, value, CONSOLE_VAR_VALUE_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
void consoleVarInitListener(
|
|
||||||
consolevar_t *var,
|
|
||||||
const char_t *name,
|
|
||||||
const char_t *value,
|
|
||||||
consolevarchanged_t event
|
|
||||||
) {
|
|
||||||
consoleVarInit(var, name, value);
|
|
||||||
if(event) consoleVarListen(var, event);
|
|
||||||
}
|
|
||||||
|
|
||||||
void consoleVarSetValue(consolevar_t *var, const char_t *value) {
|
|
||||||
assertNotNull(var, "var must not be NULL");
|
|
||||||
assertNotNull(value, "value must not be NULL");
|
|
||||||
assertStrLenMax(value, CONSOLE_VAR_VALUE_MAX, "value is too long");
|
|
||||||
|
|
||||||
stringCopy(var->value, value, CONSOLE_VAR_VALUE_MAX);
|
|
||||||
|
|
||||||
uint8_t i = 0;
|
|
||||||
while (i < var->eventCount) {
|
|
||||||
var->events[i](var);
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void consoleVarListen(consolevar_t *var, consolevarchanged_t event) {
|
|
||||||
assertNotNull(var, "var must not be NULL");
|
|
||||||
assertNotNull(event, "event must not be NULL");
|
|
||||||
assertTrue(
|
|
||||||
var->eventCount < CONSOLE_VAR_EVENTS_MAX,
|
|
||||||
"Event count is too high"
|
|
||||||
);
|
|
||||||
var->events[var->eventCount++] = event;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "dusk.h"
|
|
||||||
#include "consoledefs.h"
|
|
||||||
|
|
||||||
typedef struct consolevar_s consolevar_t;
|
|
||||||
|
|
||||||
typedef void (*consolevarchanged_t)(const consolevar_t *var);
|
|
||||||
|
|
||||||
typedef struct consolevar_s {
|
|
||||||
char_t name[CONSOLE_VAR_NAME_MAX];
|
|
||||||
char_t value[CONSOLE_VAR_VALUE_MAX];
|
|
||||||
consolevarchanged_t events[CONSOLE_VAR_EVENTS_MAX];
|
|
||||||
uint8_t eventCount;
|
|
||||||
} consolevar_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes a console variable.
|
|
||||||
*
|
|
||||||
* @param var Pointer to the console variable.
|
|
||||||
* @param name The name of the variable.
|
|
||||||
* @param value The initial value of the variable.
|
|
||||||
*/
|
|
||||||
void consoleVarInit(
|
|
||||||
consolevar_t *var,
|
|
||||||
const char_t *name,
|
|
||||||
const char_t *value
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes a console variable with a listener.
|
|
||||||
*
|
|
||||||
* @param var Pointer to the console variable.
|
|
||||||
* @param name The name of the variable.
|
|
||||||
* @param value The initial value of the variable.
|
|
||||||
* @param event The event to register.
|
|
||||||
*/
|
|
||||||
void consoleVarInitListener(
|
|
||||||
consolevar_t *var,
|
|
||||||
const char_t *name,
|
|
||||||
const char_t *value,
|
|
||||||
consolevarchanged_t event
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the value of a console variable.
|
|
||||||
*
|
|
||||||
* @param var Pointer to the console variable.
|
|
||||||
* @param value The new value of the variable.
|
|
||||||
*/
|
|
||||||
void consoleVarSetValue(consolevar_t *var, const char_t *value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers an event to be called when the value of a console variable changes.
|
|
||||||
*
|
|
||||||
* @param var Pointer to the console variable.
|
|
||||||
* @param event The event to register.
|
|
||||||
*/
|
|
||||||
void consoleVarListen(consolevar_t *var, consolevarchanged_t event);
|
|
||||||
@@ -1,11 +1,21 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
# Copyright (c) 2026 Dominic Masters
|
||||||
#
|
#
|
||||||
# This software is released under the MIT License.
|
# This software is released under the MIT License.
|
||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
# Sources
|
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||||
target_sources(${DUSK_TARGET_NAME}
|
PUBLIC
|
||||||
PRIVATE
|
display.c
|
||||||
renderbase.c
|
|
||||||
scene.c
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Subdirectories
|
||||||
|
add_subdirectory(mesh)
|
||||||
|
|
||||||
|
# Color definitions
|
||||||
|
dusk_run_python(
|
||||||
|
dusk_color_defs
|
||||||
|
tools.color
|
||||||
|
--csv ${CMAKE_CURRENT_SOURCE_DIR}/color.csv
|
||||||
|
--output ${DUSK_GENERATED_HEADERS_DIR}/display/color.h
|
||||||
|
)
|
||||||
|
add_dependencies(${DUSK_LIBRARY_TARGET_NAME} dusk_color_defs)
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
name,r,g,b,a
|
||||||
|
black,0,0,0,1
|
||||||
|
white,1,1,1,1
|
||||||
|
red,1,0,0,1
|
||||||
|
green,0,1,0,1
|
||||||
|
blue,0,0,1,1
|
||||||
|
yellow,1,1,0,1
|
||||||
|
cyan,0,1,1,1
|
||||||
|
magenta,1,0,1,1
|
||||||
|
transparent,0,0,0,0
|
||||||
|
transparent_white,1,1,1,0
|
||||||
|
transparent_black,0,0,0,0
|
||||||
|
gray,0.5,0.5,0.5,1
|
||||||
|
light_gray,0.75,0.75,0.75,1
|
||||||
|
dark_gray,0.25,0.25,0.25,1
|
||||||
|
orange,1,0.65,0,1
|
||||||
|
purple,0.5,0,0.5,1
|
||||||
|
brown,0.6,0.4,0.2,1
|
||||||
|
pink,1,0.75,0.8,1
|
||||||
|
lime,0.75,1,0,1
|
||||||
|
navy,0,0,0.5,1
|
||||||
|
teal,0,0.5,0.5,1
|
||||||
|
cornflower_blue,0.39,0.58,0.93,1
|
||||||
|
@@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "display/display.h"
|
||||||
|
#include "util/memory.h"
|
||||||
|
|
||||||
|
display_t DISPLAY = { 0 };
|
||||||
|
|
||||||
|
errorret_t displayInit(void) {
|
||||||
|
memoryZero(&DISPLAY, sizeof(DISPLAY));
|
||||||
|
|
||||||
|
#ifdef displayPlatformInit
|
||||||
|
errorChain(displayPlatformInit());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t displayUpdate(void) {
|
||||||
|
#ifdef displayPlatformUpdate
|
||||||
|
errorChain(displayPlatformUpdate());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t displayDispose(void) {
|
||||||
|
#ifdef displayPlatformDispose
|
||||||
|
errorChain(displayPlatformDispose());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "error/error.h"
|
||||||
|
#include "display/displayplatform.h"
|
||||||
|
|
||||||
|
// Main display struct, platform-specific.
|
||||||
|
typedef displayplatform_t display_t;
|
||||||
|
|
||||||
|
extern display_t DISPLAY;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the display system.
|
||||||
|
*
|
||||||
|
* @return An errorret_t indicating success or failure.
|
||||||
|
*/
|
||||||
|
errorret_t displayInit(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tells the display system to actually draw the frame.
|
||||||
|
*
|
||||||
|
* @return An errorret_t indicating success or failure.
|
||||||
|
*/
|
||||||
|
errorret_t displayUpdate(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disposes of the display system.
|
||||||
|
*
|
||||||
|
* @return An errorret_t indicating success or failure.
|
||||||
|
*/
|
||||||
|
errorret_t displayDispose(void);
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2026 Dominic Masters
|
||||||
|
#
|
||||||
|
# This software is released under the MIT License.
|
||||||
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||||
|
PUBLIC
|
||||||
|
meshformat.c
|
||||||
|
)
|
||||||
@@ -0,0 +1,117 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "display/display.h"
|
||||||
|
#include "display/color.h"
|
||||||
|
#include "display/mesh/meshformat.h"
|
||||||
|
#include "display/mesh/meshplatform.h"
|
||||||
|
|
||||||
|
#ifndef meshInitPlatform
|
||||||
|
#error "meshInitPlatform must be defined"
|
||||||
|
#endif
|
||||||
|
#ifndef meshDrawPlatform
|
||||||
|
#error "meshDrawPlatform must be defined"
|
||||||
|
#endif
|
||||||
|
#ifndef meshGetFormatPlatform
|
||||||
|
#error "meshGetFormatPlatform must be defined"
|
||||||
|
#endif
|
||||||
|
#ifndef meshGetVertexCountPlatform
|
||||||
|
#error "meshGetVertexCountPlatform must be defined"
|
||||||
|
#endif
|
||||||
|
#ifndef meshDisposePlatform
|
||||||
|
#error "meshDisposePlatform must be defined"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef meshprimitivetypeplatform_t meshprimitivetype_t;
|
||||||
|
typedef meshplatform_t mesh_t;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes a mesh.
|
||||||
|
*
|
||||||
|
* @param mesh The mesh to initialize.
|
||||||
|
* @param primitiveType The primitive type (e.g. triangles).
|
||||||
|
* @param format The MESH_FORMAT_* flags describing each vertex's attributes.
|
||||||
|
* @param vertexCount The number of vertices in the mesh.
|
||||||
|
* @param vertices Interleaved vertex data, laid out as described by format
|
||||||
|
* (see meshFormatStride / meshFormatOffset and meshvertex.h).
|
||||||
|
* @return An error indicating success or failure.
|
||||||
|
*/
|
||||||
|
errorret_t meshInit(
|
||||||
|
mesh_t *mesh,
|
||||||
|
const meshprimitivetype_t primitiveType,
|
||||||
|
const meshformat_t format,
|
||||||
|
const int32_t vertexCount,
|
||||||
|
const void *vertices
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructs the mesh to flush the vertices to the GPU. This is surprisingly
|
||||||
|
* only really necessary on modern devices, as we tend to let older devices
|
||||||
|
* read the vertices from the main memory directly.
|
||||||
|
*
|
||||||
|
* @param mesh Mesh to flush the vertices for.
|
||||||
|
* @param vertexOffset Start vertex to flush.
|
||||||
|
* @param vertexCount Count of vertices to flush, set to -1 for all.
|
||||||
|
* @return Error state.
|
||||||
|
*/
|
||||||
|
errorret_t meshFlush(
|
||||||
|
mesh_t *mesh,
|
||||||
|
const int32_t vertexOffset,
|
||||||
|
const int32_t vertexCount
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draws a mesh.
|
||||||
|
*
|
||||||
|
* @param mesh The mesh to draw.
|
||||||
|
* @param vertexOffset The offset in the vertex array to start drawing from.
|
||||||
|
* @param vertexCount The number of vertices to draw. If -1, draws all vertices.
|
||||||
|
* @return An error indicating success or failure.
|
||||||
|
*/
|
||||||
|
errorret_t meshDraw(
|
||||||
|
const mesh_t *mesh,
|
||||||
|
const int32_t vertexOffset,
|
||||||
|
const int32_t vertexCount
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the axis-aligned bounding box of a mesh.
|
||||||
|
*
|
||||||
|
* @param mesh The mesh to get the bounds of.
|
||||||
|
* @param outMin Output parameter for the minimum corner of the bounding box.
|
||||||
|
* @param outMax Output parameter for the maximum corner of the bounding box.
|
||||||
|
*/
|
||||||
|
void meshGetBounds(
|
||||||
|
const mesh_t *mesh,
|
||||||
|
float_t outMin[MESH_VERTEX_POSITION_SIZE],
|
||||||
|
float_t outMax[MESH_VERTEX_POSITION_SIZE]
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the vertex format of a mesh.
|
||||||
|
*
|
||||||
|
* @param mesh The mesh to get the format from.
|
||||||
|
* @return The MESH_FORMAT_* flags the mesh was created with.
|
||||||
|
*/
|
||||||
|
meshformat_t meshGetFormat(const mesh_t *mesh);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the vertex count of a mesh.
|
||||||
|
*
|
||||||
|
* @param mesh The mesh to get the vertex count from.
|
||||||
|
* @return The vertex count of the mesh.
|
||||||
|
*/
|
||||||
|
int32_t meshGetVertexCount(const mesh_t *mesh);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disposes a mesh.
|
||||||
|
*
|
||||||
|
* @param mesh The mesh to dispose.
|
||||||
|
* @return An error indicating success or failure.
|
||||||
|
*/
|
||||||
|
errorret_t meshDispose(mesh_t *mesh);
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "display/mesh/meshformat.h"
|
||||||
|
#include "assert/assert.h"
|
||||||
|
|
||||||
|
#define MESH_FORMAT_ALL ( \
|
||||||
|
MESH_FORMAT_POSITION | MESH_FORMAT_NORMAL | \
|
||||||
|
MESH_FORMAT_COLOR | MESH_FORMAT_UV \
|
||||||
|
)
|
||||||
|
|
||||||
|
bool_t meshFormatIsValid(const meshformat_t format) {
|
||||||
|
if((format & ~MESH_FORMAT_ALL) != 0) return false;
|
||||||
|
return (format & MESH_FORMAT_POSITION) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool_t meshFormatHas(const meshformat_t format, const meshformat_t flags) {
|
||||||
|
return (format & flags) == flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t meshFormatAttributeSize(const meshformat_t attribute) {
|
||||||
|
switch(attribute) {
|
||||||
|
case MESH_FORMAT_POSITION:
|
||||||
|
return sizeof(float_t) * MESH_VERTEX_POSITION_SIZE;
|
||||||
|
|
||||||
|
case MESH_FORMAT_NORMAL:
|
||||||
|
return sizeof(float_t) * MESH_VERTEX_NORMAL_SIZE;
|
||||||
|
|
||||||
|
case MESH_FORMAT_COLOR:
|
||||||
|
return sizeof(uint8_t) * MESH_VERTEX_COLOR_SIZE;
|
||||||
|
|
||||||
|
case MESH_FORMAT_UV:
|
||||||
|
return sizeof(float_t) * MESH_VERTEX_UV_SIZE;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assertUnreachable("Mesh attribute must be exactly one format flag.");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t meshFormatStride(const meshformat_t format) {
|
||||||
|
assertTrue(meshFormatIsValid(format), "Mesh format is not valid.");
|
||||||
|
|
||||||
|
size_t stride = 0;
|
||||||
|
for(meshformat_t flag = 1; flag <= MESH_FORMAT_ALL; flag <<= 1) {
|
||||||
|
if(meshFormatHas(format, flag)) stride += meshFormatAttributeSize(flag);
|
||||||
|
}
|
||||||
|
return stride;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t meshFormatOffset(
|
||||||
|
const meshformat_t format,
|
||||||
|
const meshformat_t attribute
|
||||||
|
) {
|
||||||
|
assertTrue(meshFormatIsValid(format), "Mesh format is not valid.");
|
||||||
|
assertTrue(
|
||||||
|
meshFormatHas(format, attribute),
|
||||||
|
"Mesh format does not contain the requested attribute."
|
||||||
|
);
|
||||||
|
|
||||||
|
// Attributes are interleaved in flag order, so sum everything before it.
|
||||||
|
size_t offset = 0;
|
||||||
|
for(meshformat_t flag = 1; flag < attribute; flag <<= 1) {
|
||||||
|
if(meshFormatHas(format, flag)) offset += meshFormatAttributeSize(flag);
|
||||||
|
}
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
@@ -0,0 +1,88 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "dusk.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Describes which attributes each vertex of a mesh carries. Combine the
|
||||||
|
* MESH_FORMAT_* flags. Position is mandatory.
|
||||||
|
*/
|
||||||
|
typedef uint8_t meshformat_t;
|
||||||
|
|
||||||
|
#define MESH_FORMAT_POSITION 0x01
|
||||||
|
#define MESH_FORMAT_NORMAL 0x02
|
||||||
|
#define MESH_FORMAT_COLOR 0x04
|
||||||
|
#define MESH_FORMAT_UV 0x08
|
||||||
|
|
||||||
|
// Common combinations.
|
||||||
|
#define MESH_FORMAT_P (MESH_FORMAT_POSITION)
|
||||||
|
#define MESH_FORMAT_PC (MESH_FORMAT_POSITION | MESH_FORMAT_COLOR)
|
||||||
|
#define MESH_FORMAT_PU (MESH_FORMAT_POSITION | MESH_FORMAT_UV)
|
||||||
|
#define MESH_FORMAT_PCU \
|
||||||
|
(MESH_FORMAT_POSITION | MESH_FORMAT_COLOR | MESH_FORMAT_UV)
|
||||||
|
#define MESH_FORMAT_PN (MESH_FORMAT_POSITION | MESH_FORMAT_NORMAL)
|
||||||
|
#define MESH_FORMAT_PNU \
|
||||||
|
(MESH_FORMAT_POSITION | MESH_FORMAT_NORMAL | MESH_FORMAT_UV)
|
||||||
|
#define MESH_FORMAT_PNC \
|
||||||
|
(MESH_FORMAT_POSITION | MESH_FORMAT_NORMAL | MESH_FORMAT_COLOR)
|
||||||
|
#define MESH_FORMAT_PNCU ( \
|
||||||
|
MESH_FORMAT_POSITION | MESH_FORMAT_NORMAL | \
|
||||||
|
MESH_FORMAT_COLOR | MESH_FORMAT_UV \
|
||||||
|
)
|
||||||
|
|
||||||
|
// Component counts and sizes of each attribute within a vertex.
|
||||||
|
#define MESH_VERTEX_POSITION_SIZE 3
|
||||||
|
#define MESH_VERTEX_NORMAL_SIZE 3
|
||||||
|
#define MESH_VERTEX_COLOR_SIZE 4
|
||||||
|
#define MESH_VERTEX_UV_SIZE 2
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that a format is valid, i.e. has a position and no unknown bits.
|
||||||
|
*
|
||||||
|
* @param format The format to check.
|
||||||
|
* @return True if the format is valid.
|
||||||
|
*/
|
||||||
|
bool_t meshFormatIsValid(const meshformat_t format);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks whether a format contains every attribute in a set of flags.
|
||||||
|
*
|
||||||
|
* @param format The format to check.
|
||||||
|
* @param flags One or more MESH_FORMAT_* flags that must all be present.
|
||||||
|
* @return True if all of the flags are present in the format.
|
||||||
|
*/
|
||||||
|
bool_t meshFormatHas(const meshformat_t format, const meshformat_t flags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the size in bytes of a single attribute.
|
||||||
|
*
|
||||||
|
* @param attribute Exactly one MESH_FORMAT_* flag.
|
||||||
|
* @return The size in bytes of that attribute.
|
||||||
|
*/
|
||||||
|
size_t meshFormatAttributeSize(const meshformat_t attribute);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the size in bytes of one whole vertex of the given format. Attributes
|
||||||
|
* are interleaved in the order position, normal, color, uv.
|
||||||
|
*
|
||||||
|
* @param format The format to get the stride of.
|
||||||
|
* @return The size in bytes of one vertex.
|
||||||
|
*/
|
||||||
|
size_t meshFormatStride(const meshformat_t format);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the byte offset of an attribute within a vertex of the given format.
|
||||||
|
*
|
||||||
|
* @param format The format of the vertex.
|
||||||
|
* @param attribute Exactly one MESH_FORMAT_* flag, which must be in format.
|
||||||
|
* @return The byte offset of the attribute from the start of the vertex.
|
||||||
|
*/
|
||||||
|
size_t meshFormatOffset(
|
||||||
|
const meshformat_t format,
|
||||||
|
const meshformat_t attribute
|
||||||
|
);
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "display/mesh/meshformat.h"
|
||||||
|
#include "assert/assert.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Typed helpers matching each mesh format's interleaved layout (position,
|
||||||
|
* normal, color, uv). The format flags and meshFormatStride() are the source
|
||||||
|
* of truth; these exist for building meshes in C, and are size checked below.
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float_t pos[MESH_VERTEX_POSITION_SIZE];
|
||||||
|
} meshvertexp_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float_t pos[MESH_VERTEX_POSITION_SIZE];
|
||||||
|
uint8_t color[MESH_VERTEX_COLOR_SIZE];
|
||||||
|
} meshvertexpc_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float_t pos[MESH_VERTEX_POSITION_SIZE];
|
||||||
|
float_t uv[MESH_VERTEX_UV_SIZE];
|
||||||
|
} meshvertexpu_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float_t pos[MESH_VERTEX_POSITION_SIZE];
|
||||||
|
uint8_t color[MESH_VERTEX_COLOR_SIZE];
|
||||||
|
float_t uv[MESH_VERTEX_UV_SIZE];
|
||||||
|
} meshvertexpcu_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float_t pos[MESH_VERTEX_POSITION_SIZE];
|
||||||
|
float_t normal[MESH_VERTEX_NORMAL_SIZE];
|
||||||
|
} meshvertexpn_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float_t pos[MESH_VERTEX_POSITION_SIZE];
|
||||||
|
float_t normal[MESH_VERTEX_NORMAL_SIZE];
|
||||||
|
float_t uv[MESH_VERTEX_UV_SIZE];
|
||||||
|
} meshvertexpnu_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float_t pos[MESH_VERTEX_POSITION_SIZE];
|
||||||
|
float_t normal[MESH_VERTEX_NORMAL_SIZE];
|
||||||
|
uint8_t color[MESH_VERTEX_COLOR_SIZE];
|
||||||
|
} meshvertexpnc_t;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
float_t pos[MESH_VERTEX_POSITION_SIZE];
|
||||||
|
float_t normal[MESH_VERTEX_NORMAL_SIZE];
|
||||||
|
uint8_t color[MESH_VERTEX_COLOR_SIZE];
|
||||||
|
float_t uv[MESH_VERTEX_UV_SIZE];
|
||||||
|
} meshvertexpncu_t;
|
||||||
|
|
||||||
|
assertStructSize(meshvertexp_t, 12);
|
||||||
|
assertStructSize(meshvertexpc_t, 16);
|
||||||
|
assertStructSize(meshvertexpu_t, 20);
|
||||||
|
assertStructSize(meshvertexpcu_t, 24);
|
||||||
|
assertStructSize(meshvertexpn_t, 24);
|
||||||
|
assertStructSize(meshvertexpnu_t, 32);
|
||||||
|
assertStructSize(meshvertexpnc_t, 28);
|
||||||
|
assertStructSize(meshvertexpncu_t, 36);
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "error/error.h"
|
|
||||||
|
|
||||||
#ifndef RENDER_WIDTH
|
|
||||||
#define RENDER_WIDTH 320
|
|
||||||
#endif
|
|
||||||
#ifndef RENDER_HEIGHT
|
|
||||||
#define RENDER_HEIGHT 240
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the rendering system.
|
|
||||||
*/
|
|
||||||
errorret_t renderInit(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Tells the rendering system to actually draw the frame.
|
|
||||||
*/
|
|
||||||
errorret_t renderDraw(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Disposes of the rendering system.
|
|
||||||
*/
|
|
||||||
errorret_t renderDispose(void);
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
SCENE_INITIAL,
|
|
||||||
SCENE_OVERWORLD,
|
|
||||||
} scene_t;
|
|
||||||
|
|
||||||
extern scene_t SCENE_CURRENT;
|
|
||||||
+6
-1
@@ -1,11 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2025 Dominic Masters
|
* Copyright (c) 2026 Dominic Masters
|
||||||
*
|
*
|
||||||
* This software is released under the MIT License.
|
* This software is released under the MIT License.
|
||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
@@ -16,6 +17,10 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
|
#include <memory.h>
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
#include "duskplatform.h"
|
||||||
|
|
||||||
typedef bool bool_t;
|
typedef bool bool_t;
|
||||||
typedef int int_t;
|
typedef int int_t;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
# Sources
|
# Sources
|
||||||
target_sources(${DUSK_TARGET_NAME}
|
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||||
PRIVATE
|
PUBLIC
|
||||||
inventory.c
|
engine.c
|
||||||
)
|
)
|
||||||
@@ -0,0 +1,75 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "engine.h"
|
||||||
|
#include "util/memory.h"
|
||||||
|
#include "perf/perf.h"
|
||||||
|
#include "time/time.h"
|
||||||
|
#include "display/display.h"
|
||||||
|
#include "game/game.h"
|
||||||
|
#include "resource/resourcemanager.h"
|
||||||
|
#include "asset/asset.h"
|
||||||
|
#include "assert/assert.h"
|
||||||
|
#include "console/console.h"
|
||||||
|
|
||||||
|
engine_t ENGINE;
|
||||||
|
|
||||||
|
errorret_t engineInit(const int32_t argc, const char_t **argv) {
|
||||||
|
assertInit();
|
||||||
|
memoryZero(&ENGINE, sizeof(engine_t));
|
||||||
|
ENGINE.running = true;
|
||||||
|
ENGINE.argc = argc;
|
||||||
|
ENGINE.argv = argv;
|
||||||
|
ENGINE.version = DUSK_VERSION;
|
||||||
|
|
||||||
|
// Init systems. Order is important.
|
||||||
|
perfInit();
|
||||||
|
timeInit();
|
||||||
|
consoleInit();
|
||||||
|
errorChain(assetInit());
|
||||||
|
errorChain(resourceManagerInit());
|
||||||
|
errorChain(displayInit());
|
||||||
|
errorChain(gameInit());
|
||||||
|
|
||||||
|
consolePrint("Engine initialized");
|
||||||
|
|
||||||
|
#ifdef DUSK_ASSERTIONS_FAKED
|
||||||
|
consolePrint("Assertions faked");
|
||||||
|
#else
|
||||||
|
consolePrint("Assertions real");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t engineUpdate(void) {
|
||||||
|
// Order here is important.
|
||||||
|
timeUpdate();
|
||||||
|
consoleUpdate();
|
||||||
|
errorChain(resourceManagerUpdate());
|
||||||
|
errorChain(gameUpdate());
|
||||||
|
errorChain(displayUpdate());
|
||||||
|
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
|
|
||||||
|
void engineExit(void) {
|
||||||
|
ENGINE.running = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
errorret_t engineDispose(void) {
|
||||||
|
errorChain(gameDispose());
|
||||||
|
errorChain(displayDispose());
|
||||||
|
errorChain(resourceManagerDispose());
|
||||||
|
errorChain(assetDispose());
|
||||||
|
consoleDispose();
|
||||||
|
perfDispose();
|
||||||
|
|
||||||
|
memoryCheckUnfreed();
|
||||||
|
|
||||||
|
errorOk();
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "dusk.h"
|
||||||
|
#include "error/error.h"
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
bool_t running;
|
||||||
|
int32_t argc;
|
||||||
|
const char_t **argv;
|
||||||
|
const char_t *version;
|
||||||
|
} engine_t;
|
||||||
|
|
||||||
|
extern engine_t ENGINE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the engine.
|
||||||
|
*
|
||||||
|
* @param argc The argument count from main().
|
||||||
|
* @param argv The argument vector from main().
|
||||||
|
*/
|
||||||
|
errorret_t engineInit(const int32_t argc, const char_t **argv);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the engine.
|
||||||
|
*/
|
||||||
|
errorret_t engineUpdate(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shuts down the engine.
|
||||||
|
*/
|
||||||
|
errorret_t engineDispose(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests that the engine stops running.
|
||||||
|
*/
|
||||||
|
void engineExit(void);
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
# Sources
|
|
||||||
target_sources(${DUSK_TARGET_NAME}
|
|
||||||
PRIVATE
|
|
||||||
entity.c
|
|
||||||
player.c
|
|
||||||
npc.c
|
|
||||||
)
|
|
||||||
@@ -1,132 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "entity.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
#include "util/memory.h"
|
|
||||||
#include "world/world.h"
|
|
||||||
#include "world/tiledata.h"
|
|
||||||
#include "physics/physics.h"
|
|
||||||
|
|
||||||
entity_t ENTITIES[ENTITY_COUNT_MAX] = {0};
|
|
||||||
|
|
||||||
entitycallback_t ENTITY_CALLBACKS[ENTITY_TYPE_COUNT] = {
|
|
||||||
{NULL}, // ENTITY_TYPE_NULL
|
|
||||||
{
|
|
||||||
.load = playerEntityLoad,
|
|
||||||
.update = playerEntityUpdate,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
.load = npcLoad,
|
|
||||||
.update = npcUpdate,
|
|
||||||
.interact = npcInteract,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
void entityLoad(entity_t *entity, const entity_t *source) {
|
|
||||||
assertNotNull(entity, "Entity pointer cannot be NULL");
|
|
||||||
assertNotNull(source, "Source entity pointer cannot be NULL");
|
|
||||||
assertTrue(source->type != ENTITY_TYPE_NULL, "Source entity type NULL");
|
|
||||||
assertTrue(source->type < ENTITY_TYPE_COUNT, "Source entity type bad");
|
|
||||||
assertNotNull(
|
|
||||||
ENTITY_CALLBACKS[source->type].load,
|
|
||||||
"Entity type has no i nit callback"
|
|
||||||
);
|
|
||||||
|
|
||||||
memoryZero(entity, sizeof(entity_t));
|
|
||||||
|
|
||||||
entity->type = source->type;
|
|
||||||
entity->x = source->x;
|
|
||||||
entity->y = source->y;
|
|
||||||
entity->vx = source->vx;
|
|
||||||
entity->vy = source->vy;
|
|
||||||
entity->dir = source->dir;
|
|
||||||
entity->id = source->id;
|
|
||||||
|
|
||||||
ENTITY_CALLBACKS[entity->type].load(entity, source);
|
|
||||||
}
|
|
||||||
|
|
||||||
void entityUpdate(entity_t *entity) {
|
|
||||||
assertNotNull(entity, "Entity pointer cannot be NULL");
|
|
||||||
assertTrue(entity->type != ENTITY_TYPE_NULL, "Entity type NULL");
|
|
||||||
assertTrue(entity->type < ENTITY_TYPE_COUNT, "Entity type out of bounds");
|
|
||||||
assertNotNull(
|
|
||||||
ENTITY_CALLBACKS[entity->type].update,
|
|
||||||
"Entity type has no update callback"
|
|
||||||
);
|
|
||||||
|
|
||||||
ENTITY_CALLBACKS[entity->type].update(entity);
|
|
||||||
|
|
||||||
if(entity->vx == 0.0f && entity->vy == 0.0f) return;
|
|
||||||
|
|
||||||
float_t newX = entity->x + entity->vx;
|
|
||||||
float_t newY = entity->y + entity->vy;
|
|
||||||
float_t halfTileWH = TILE_WIDTH_HEIGHT / 2.0f;
|
|
||||||
|
|
||||||
// Because all hit detection is done assuming the entity is a circle, with
|
|
||||||
// its position centered, we need to precalc these;
|
|
||||||
float_t selfCircX = newX + halfTileWH;
|
|
||||||
float_t selfCircY = newY + halfTileWH;
|
|
||||||
float_t selfCircR = halfTileWH;
|
|
||||||
|
|
||||||
// Check for collisions with tiles
|
|
||||||
float_t tileStartX = floorf((newX - halfTileWH) / TILE_WIDTH_HEIGHT);
|
|
||||||
float_t tileStartY = floorf((newY - halfTileWH) / TILE_WIDTH_HEIGHT);
|
|
||||||
float_t tileEndX = ceilf((newX + halfTileWH) / TILE_WIDTH_HEIGHT);
|
|
||||||
float_t tileEndY = ceilf((newY + halfTileWH) / TILE_WIDTH_HEIGHT);
|
|
||||||
|
|
||||||
// For each tile
|
|
||||||
for(float_t y = tileStartY; y <= tileEndY; y += 1) {
|
|
||||||
for(float_t x = tileStartX; x <= tileEndX; x += 1) {
|
|
||||||
uint16_t tileX = (uint16_t)x;
|
|
||||||
uint16_t tileY = (uint16_t)y;
|
|
||||||
uint16_t chunkX = tileX / CHUNK_WIDTH;
|
|
||||||
uint16_t chunkY = tileY / CHUNK_HEIGHT;
|
|
||||||
chunk_t *chunk = chunkGetChunkAt(chunkX, chunkY);
|
|
||||||
if(chunk == NULL) continue;
|
|
||||||
|
|
||||||
uint8_t chunkTileX = tileX % CHUNK_WIDTH;
|
|
||||||
uint8_t chunkTileY = tileY % CHUNK_HEIGHT;
|
|
||||||
tile_t tile = chunk->tilesBase[chunkTileY * CHUNK_WIDTH + chunkTileX];
|
|
||||||
|
|
||||||
collisionresult_t collision = physicsCheckCircleTile(
|
|
||||||
selfCircX, selfCircY, selfCircR, x, y, tile
|
|
||||||
);
|
|
||||||
if(collision.hit && collision.depth > 0.01f) {
|
|
||||||
float_t slideX = collision.normalX * collision.depth;
|
|
||||||
float_t slideY = collision.normalY * collision.depth;
|
|
||||||
newX -= slideX;
|
|
||||||
newY -= slideY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check for collisions with other entities
|
|
||||||
entity_t *otherEntity = ENTITIES;
|
|
||||||
do {
|
|
||||||
// Skip self and null entities
|
|
||||||
if(otherEntity == entity || otherEntity->type == ENTITY_TYPE_NULL) continue;
|
|
||||||
|
|
||||||
float_t otherCircR = halfTileWH;
|
|
||||||
|
|
||||||
// We DONT use selfCircX/Y here because the other entity is ALSO a circle.
|
|
||||||
collisionresult_t collision = physicsCheckCircleCircle(
|
|
||||||
newX, newY, selfCircR,
|
|
||||||
otherEntity->x, otherEntity->y, otherCircR
|
|
||||||
);
|
|
||||||
if(!collision.hit) continue;
|
|
||||||
|
|
||||||
// Collision with entity detected. Slide out of collision.
|
|
||||||
float_t slideX = collision.normalX * collision.depth;
|
|
||||||
float_t slideY = collision.normalY * collision.depth;
|
|
||||||
newX -= slideX;
|
|
||||||
newY -= slideY;
|
|
||||||
} while(++otherEntity < ENTITIES + ENTITY_COUNT_MAX);
|
|
||||||
|
|
||||||
entity->x = newX;
|
|
||||||
entity->y = newY;
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "player.h"
|
|
||||||
#include "npc.h"
|
|
||||||
|
|
||||||
#define ENTITY_COUNT_MAX 32
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ENTITY_DIR_SOUTH = 0,
|
|
||||||
ENTITY_DIR_EAST = 1,
|
|
||||||
ENTITY_DIR_WEST = 2,
|
|
||||||
ENTITY_DIR_NORTH = 3,
|
|
||||||
|
|
||||||
ENTITY_DIR_UP = ENTITY_DIR_NORTH,
|
|
||||||
ENTITY_DIR_DOWN = ENTITY_DIR_SOUTH,
|
|
||||||
ENTITY_DIR_LEFT = ENTITY_DIR_WEST,
|
|
||||||
ENTITY_DIR_RIGHT = ENTITY_DIR_EAST,
|
|
||||||
} entitydir_t;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ENTITY_TYPE_NULL = 0,
|
|
||||||
ENTITY_TYPE_PLAYER = 1,
|
|
||||||
ENTITY_TYPE_NPC = 2,
|
|
||||||
} entitytype_t;
|
|
||||||
#define ENTITY_TYPE_COUNT 3
|
|
||||||
|
|
||||||
typedef struct _entity_t {
|
|
||||||
uint32_t id;// Completely unique ID for this entity.
|
|
||||||
float_t x, y;
|
|
||||||
float_t vx, vy;
|
|
||||||
entitytype_t type;
|
|
||||||
entitydir_t dir;
|
|
||||||
|
|
||||||
union {
|
|
||||||
npc_t npc;
|
|
||||||
playerentity_t player;
|
|
||||||
};
|
|
||||||
} entity_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
void (*load) (entity_t *entity, const entity_t *source);
|
|
||||||
void (*update) (entity_t *entity);
|
|
||||||
void (*interact)(entity_t *player, entity_t *self);
|
|
||||||
} entitycallback_t;
|
|
||||||
|
|
||||||
extern entity_t ENTITIES[ENTITY_COUNT_MAX];
|
|
||||||
extern entitycallback_t ENTITY_CALLBACKS[ENTITY_TYPE_COUNT];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads an entity from the generated entity data.
|
|
||||||
*
|
|
||||||
* @param entity Pointer to the entity to initialize.
|
|
||||||
* @param source Pointer to the source entity data.
|
|
||||||
*/
|
|
||||||
void entityLoad(entity_t *entity, const entity_t *source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the entity's state.
|
|
||||||
*
|
|
||||||
* @param entity Pointer to the entity to update.
|
|
||||||
*/
|
|
||||||
void entityUpdate(entity_t *entity);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Converts an entity direction to an angle in float_t format.
|
|
||||||
*
|
|
||||||
* @param dir The entity direction to convert.
|
|
||||||
* @return The angle corresponding to the entity direction.
|
|
||||||
*/
|
|
||||||
float_t entityDirToAngle(const entitydir_t dir);
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "entity.h"
|
|
||||||
#include "ui/uitextbox.h"
|
|
||||||
#include "locale/language.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
|
|
||||||
void npcLoad(entity_t *entity, const entity_t *source) {
|
|
||||||
assertNotNull(entity, "Entity pointer cannot be NULL");
|
|
||||||
assertNotNull(source, "Source entity pointer cannot be NULL");
|
|
||||||
assertTrue(source->type == ENTITY_TYPE_NPC, "Source entity type must be NPC");
|
|
||||||
|
|
||||||
entity->npc = source->npc;
|
|
||||||
}
|
|
||||||
|
|
||||||
void npcUpdate(entity_t *entity) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void npcInteract(entity_t *player, entity_t *self) {
|
|
||||||
assertTrue(self->type == ENTITY_TYPE_NPC, "Entity must be of type NPC");
|
|
||||||
|
|
||||||
switch(self->npc.interactType) {
|
|
||||||
case NPC_INTERACT_TYPE_NONE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NPC_INTERACT_TYPE_TEXT:
|
|
||||||
uiTextboxSetText(languageGet(self->npc.text));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NPC_INTERACT_TYPE_CONVO:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NPC_INTERACT_TYPE_EVENT:
|
|
||||||
eventSetActive(self->npc.eventData);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
assertUnreachable("Unknown NPC interaction type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
|
|
||||||
#pragma once
|
|
||||||
#include "event/eventlist.h"
|
|
||||||
|
|
||||||
typedef struct _entity_t entity_t;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
NPC_INTERACT_TYPE_NONE = 0,
|
|
||||||
NPC_INTERACT_TYPE_TEXT = 1,
|
|
||||||
NPC_INTERACT_TYPE_CONVO = 2,
|
|
||||||
NPC_INTERACT_TYPE_EVENT = 3,
|
|
||||||
} npcinteracttype_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
npcinteracttype_t interactType;
|
|
||||||
|
|
||||||
union {
|
|
||||||
const char_t* text;
|
|
||||||
const eventdata_t *eventData;
|
|
||||||
};
|
|
||||||
} npc_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the NPC entity.
|
|
||||||
*
|
|
||||||
* @param entity The entity to initialize.
|
|
||||||
* @param source The source entity to copy data from.
|
|
||||||
*/
|
|
||||||
void npcLoad(entity_t *entity, const entity_t *source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the NPC entity.
|
|
||||||
*
|
|
||||||
* @param entity The entity to update.
|
|
||||||
*/
|
|
||||||
void npcUpdate(entity_t *entity);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Handles interaction between the player and the NPC.
|
|
||||||
*
|
|
||||||
* @param player The player entity interacting with the NPC.
|
|
||||||
* @param self The NPC entity being interacted with.
|
|
||||||
*/
|
|
||||||
void npcInteract(entity_t *player, entity_t *self);
|
|
||||||
@@ -1,157 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "entity.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
#include "input.h"
|
|
||||||
#include "display/render.h"
|
|
||||||
#include "world/world.h"
|
|
||||||
#include "physics/physics.h"
|
|
||||||
|
|
||||||
#include "ui/uitextbox.h"
|
|
||||||
|
|
||||||
inventory_t PLAYER_INVENTORY;
|
|
||||||
|
|
||||||
void playerInit() {
|
|
||||||
entity_t *ent = &ENTITIES[0];
|
|
||||||
|
|
||||||
entity_t playerEntityData = {
|
|
||||||
.id = PLAYER_ENTITY_ID,
|
|
||||||
.type = ENTITY_TYPE_PLAYER,
|
|
||||||
.x = WORLD_PLAYER_SPAWN_X,
|
|
||||||
.y = WORLD_PLAYER_SPAWN_Y,
|
|
||||||
};
|
|
||||||
|
|
||||||
entityLoad(ent, &playerEntityData);
|
|
||||||
inventoryInit(&PLAYER_INVENTORY, INVENTORY_SIZE_MAX);
|
|
||||||
}
|
|
||||||
|
|
||||||
void playerEntityLoad(entity_t *entity, const entity_t *source) {
|
|
||||||
assertNotNull(entity, "Entity pointer cannot be NULL");
|
|
||||||
assertNotNull(source, "Source entity pointer cannot be NULL");
|
|
||||||
assertTrue(entity->type == ENTITY_TYPE_PLAYER, "Entity type must be PLAYER");
|
|
||||||
assertTrue(source->type == entity->type, "Source/Entity type mismatch");
|
|
||||||
}
|
|
||||||
|
|
||||||
void playerEntityUpdate(entity_t *entity) {
|
|
||||||
assertNotNull(entity, "Entity pointer cannot be NULL");
|
|
||||||
assertTrue(entity->type == ENTITY_TYPE_PLAYER, "Entity type must be PLAYER");
|
|
||||||
|
|
||||||
if(UI_TEXTBOX.visible) {
|
|
||||||
entity->vx = entity->vy = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(inputIsDown(INPUT_BIND_UP)) {
|
|
||||||
if(inputIsDown(INPUT_BIND_LEFT)) {
|
|
||||||
entity->vx = -PLAYER_MOVE_SPEED_XY;
|
|
||||||
entity->vy = -PLAYER_MOVE_SPEED_XY;
|
|
||||||
|
|
||||||
if(entity->dir != ENTITY_DIR_NORTH && entity->dir != ENTITY_DIR_WEST) {
|
|
||||||
entity->dir = ENTITY_DIR_NORTH;
|
|
||||||
}
|
|
||||||
} else if(inputIsDown(INPUT_BIND_RIGHT)) {
|
|
||||||
entity->vx = PLAYER_MOVE_SPEED_XY;
|
|
||||||
entity->vy = -PLAYER_MOVE_SPEED_XY;
|
|
||||||
|
|
||||||
if(entity->dir != ENTITY_DIR_NORTH && entity->dir != ENTITY_DIR_EAST) {
|
|
||||||
entity->dir = ENTITY_DIR_NORTH;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
entity->vy = -PLAYER_MOVE_SPEED;
|
|
||||||
entity->vx = 0;
|
|
||||||
entity->dir = ENTITY_DIR_NORTH;
|
|
||||||
}
|
|
||||||
} else if(inputIsDown(INPUT_BIND_DOWN)) {
|
|
||||||
if(inputIsDown(INPUT_BIND_LEFT)) {
|
|
||||||
entity->vx = -PLAYER_MOVE_SPEED_XY;
|
|
||||||
entity->vy = PLAYER_MOVE_SPEED_XY;
|
|
||||||
|
|
||||||
if(entity->dir != ENTITY_DIR_SOUTH && entity->dir != ENTITY_DIR_WEST) {
|
|
||||||
entity->dir = ENTITY_DIR_SOUTH;
|
|
||||||
}
|
|
||||||
} else if(inputIsDown(INPUT_BIND_RIGHT)) {
|
|
||||||
entity->vx = PLAYER_MOVE_SPEED_XY;
|
|
||||||
entity->vy = PLAYER_MOVE_SPEED_XY;
|
|
||||||
|
|
||||||
if(entity->dir != ENTITY_DIR_SOUTH && entity->dir != ENTITY_DIR_EAST) {
|
|
||||||
entity->dir = ENTITY_DIR_SOUTH;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
entity->vy = PLAYER_MOVE_SPEED;
|
|
||||||
entity->vx = 0;
|
|
||||||
entity->dir = ENTITY_DIR_SOUTH;
|
|
||||||
}
|
|
||||||
} else if(inputIsDown(INPUT_BIND_LEFT)) {
|
|
||||||
entity->vx = -PLAYER_MOVE_SPEED;
|
|
||||||
entity->vy = 0;
|
|
||||||
entity->dir = ENTITY_DIR_WEST;
|
|
||||||
} else if(inputIsDown(INPUT_BIND_RIGHT)) {
|
|
||||||
entity->vx = PLAYER_MOVE_SPEED;
|
|
||||||
entity->vy = 0;
|
|
||||||
entity->dir = ENTITY_DIR_EAST;
|
|
||||||
} else {
|
|
||||||
entity->vx = 0;
|
|
||||||
entity->vy = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Interact
|
|
||||||
if(inputPressed(INPUT_BIND_ACTION)) {
|
|
||||||
entity_t *other = ENTITIES;
|
|
||||||
do {
|
|
||||||
if(other == entity || other->type == ENTITY_TYPE_NULL) {
|
|
||||||
other++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Is the other entity interactable?
|
|
||||||
if(ENTITY_CALLBACKS[other->type].interact == NULL) {
|
|
||||||
other++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t distanceX = other->x - entity->x;
|
|
||||||
float_t distanceY = other->y - entity->y;
|
|
||||||
float_t distance = sqrtf(distanceX * distanceX + distanceY * distanceY);
|
|
||||||
|
|
||||||
if(distance > PLAYER_INTERACT_RANGE) {
|
|
||||||
other++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get angle
|
|
||||||
float_t angle = atan2f(distanceY, distanceX);
|
|
||||||
while(angle < 0) angle += M_PI;
|
|
||||||
float_t selfAngle = entityDirToAngle(entity->dir);
|
|
||||||
while(selfAngle < 0) selfAngle += M_PI;
|
|
||||||
|
|
||||||
// Check if angle is within range
|
|
||||||
float_t angleDiff = angle - selfAngle;
|
|
||||||
if(angleDiff > (M_PI_2)) angleDiff -= M_PI;
|
|
||||||
if(angleDiff < -M_PI_2) angleDiff += M_PI;
|
|
||||||
if(fabsf(angleDiff) > PLAYER_INTERACT_ANGLE) {
|
|
||||||
other++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
ENTITY_CALLBACKS[other->type].interact(entity, other);
|
|
||||||
entity->vx = 0;
|
|
||||||
entity->vy = 0;
|
|
||||||
other++;
|
|
||||||
} while(other != ENTITIES + ENTITY_COUNT_MAX);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
float_t entityDirToAngle(const entitydir_t dir) {
|
|
||||||
switch(dir) {
|
|
||||||
case ENTITY_DIR_NORTH: return (M_PI_2);
|
|
||||||
case ENTITY_DIR_SOUTH: return -(M_PI_2);
|
|
||||||
case ENTITY_DIR_EAST: return 0;
|
|
||||||
case ENTITY_DIR_WEST: return (M_PI);
|
|
||||||
default: return 0; // Should never happen
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "dusk.h"
|
|
||||||
#include "item/inventory.h"
|
|
||||||
|
|
||||||
typedef struct _entity_t entity_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint32_t nothing;
|
|
||||||
} playerentity_t;
|
|
||||||
|
|
||||||
#define PLAYER_ENTITY_ID (UINT32_MAX-1)
|
|
||||||
#define PLAYER_MOVE_SPEED 1.0f
|
|
||||||
#define PLAYER_MOVE_SPEED_XY 0.7f
|
|
||||||
#define PLAYER_INTERACT_RANGE (TILE_WIDTH_HEIGHT + (TILE_WIDTH_HEIGHT / 3))
|
|
||||||
#define PLAYER_INTERACT_ANGLE 0.68359375f
|
|
||||||
|
|
||||||
extern inventory_t PLAYER_INVENTORY;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the player and all player-related entities.
|
|
||||||
*/
|
|
||||||
void playerInit(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Loads the player entity.
|
|
||||||
*
|
|
||||||
* @param entity The entity to initialize.
|
|
||||||
* @param source The source entity to copy data from.
|
|
||||||
*/
|
|
||||||
void playerEntityLoad(entity_t *entity, const entity_t *source);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the player entity.
|
|
||||||
*
|
|
||||||
* @param entity The entity to update.
|
|
||||||
*/
|
|
||||||
void playerEntityUpdate(entity_t *entity);
|
|
||||||
@@ -4,7 +4,7 @@
|
|||||||
# https://opensource.org/licenses/MIT
|
# https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
# Sources
|
# Sources
|
||||||
target_sources(${DUSK_TARGET_NAME}
|
target_sources(${DUSK_LIBRARY_TARGET_NAME}
|
||||||
PRIVATE
|
PUBLIC
|
||||||
error.c
|
error.c
|
||||||
)
|
)
|
||||||
+21
-8
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2025 Dominic Masters
|
* Copyright (c) 2026 Dominic Masters
|
||||||
*
|
*
|
||||||
* This software is released under the MIT License.
|
* This software is released under the MIT License.
|
||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
@@ -9,6 +9,9 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "util/memory.h"
|
#include "util/memory.h"
|
||||||
#include "util/string.h"
|
#include "util/string.h"
|
||||||
|
#include "log/log.h"
|
||||||
|
|
||||||
|
THREAD_LOCAL errorstate_t ERROR_STATE = { 0 };
|
||||||
|
|
||||||
errorret_t errorThrowImpl(
|
errorret_t errorThrowImpl(
|
||||||
errorstate_t *state,
|
errorstate_t *state,
|
||||||
@@ -57,6 +60,11 @@ errorret_t errorThrowImpl(
|
|||||||
}
|
}
|
||||||
|
|
||||||
errorret_t errorOkImpl() {
|
errorret_t errorOkImpl() {
|
||||||
|
assertTrue(
|
||||||
|
ERROR_STATE.code == ERROR_OK,
|
||||||
|
"Global error state is not OK (Likely missing errorCatch)"
|
||||||
|
);
|
||||||
|
|
||||||
return (errorret_t) {
|
return (errorret_t) {
|
||||||
.code = ERROR_OK,
|
.code = ERROR_OK,
|
||||||
.state = NULL
|
.state = NULL
|
||||||
@@ -69,13 +77,15 @@ errorret_t errorChainImpl(
|
|||||||
const char_t *function,
|
const char_t *function,
|
||||||
const int32_t line
|
const int32_t line
|
||||||
) {
|
) {
|
||||||
if (retval.code == ERROR_OK) return retval;
|
if(errorIsOk(retval)) return retval;
|
||||||
|
|
||||||
assertNotNull(retval.state, "Error state cannot be NULL");
|
assertNotNull(retval.state, "Error state NULL (Likely missing errorOk)");
|
||||||
assertNotNull(retval.state->message, "Message cannot be NULL");
|
assertNotNull(retval.state->message, "Message cannot be NULL");
|
||||||
|
|
||||||
// Create a new line string.
|
// Create a new line string.
|
||||||
int32_t newLineLen = snprintf(NULL, 0, ERROR_LINE_FORMAT, file, line, function);
|
int32_t newLineLen = snprintf(
|
||||||
|
NULL, 0, ERROR_LINE_FORMAT, file, line, function
|
||||||
|
);
|
||||||
assertTrue(newLineLen >= 0, "Line formatting failed");
|
assertTrue(newLineLen >= 0, "Line formatting failed");
|
||||||
char_t *newLine = (char_t *)memoryAllocate(newLineLen + 1);
|
char_t *newLine = (char_t *)memoryAllocate(newLineLen + 1);
|
||||||
snprintf(newLine, newLineLen + 1, ERROR_LINE_FORMAT, file, line, function);
|
snprintf(newLine, newLineLen + 1, ERROR_LINE_FORMAT, file, line, function);
|
||||||
@@ -100,22 +110,25 @@ errorret_t errorChainImpl(
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void errorCatch(const errorret_t retval) {
|
void errorCatch(errorret_t retval) {
|
||||||
if (retval.code == ERROR_OK) return;
|
if(errorIsOk(retval)) return;
|
||||||
|
|
||||||
assertNotNull(retval.state, "Error state cannot be NULL");
|
assertNotNull(retval.state, "Error state cannot be NULL");
|
||||||
assertNotNull(retval.state->message, "Message cannot be NULL");
|
assertNotNull(retval.state->message, "Message cannot be NULL");
|
||||||
|
|
||||||
|
// Clear the error state
|
||||||
memoryFree((void*)retval.state->message);
|
memoryFree((void*)retval.state->message);
|
||||||
|
memoryFree((void*)retval.state->lines);
|
||||||
|
retval.state->code = ERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
errorret_t errorPrint(const errorret_t retval) {
|
errorret_t errorPrint(const errorret_t retval) {
|
||||||
if (retval.code == ERROR_OK) return retval;
|
if(errorIsOk(retval)) return retval;
|
||||||
|
|
||||||
assertNotNull(retval.state, "Error state cannot be NULL");
|
assertNotNull(retval.state, "Error state cannot be NULL");
|
||||||
assertNotNull(retval.state->message, "Message cannot be NULL");
|
assertNotNull(retval.state->message, "Message cannot be NULL");
|
||||||
|
|
||||||
printf(
|
logError(
|
||||||
ERROR_PRINT_FORMAT,
|
ERROR_PRINT_FORMAT,
|
||||||
retval.state->code,
|
retval.state->code,
|
||||||
retval.state->message,
|
retval.state->message,
|
||||||
|
|||||||
+28
-12
@@ -1,5 +1,5 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (c) 2025 Dominic Masters
|
* Copyright (c) 2026 Dominic Masters
|
||||||
*
|
*
|
||||||
* This software is released under the MIT License.
|
* This software is released under the MIT License.
|
||||||
* https://opensource.org/licenses/MIT
|
* https://opensource.org/licenses/MIT
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "dusk.h"
|
#include "dusk.h"
|
||||||
|
#include "thread/threadlocal.h"
|
||||||
|
|
||||||
typedef uint8_t errorcode_t;
|
typedef uint8_t errorcode_t;
|
||||||
|
|
||||||
@@ -23,13 +24,10 @@ typedef struct {
|
|||||||
|
|
||||||
static const errorcode_t ERROR_OK = 0;
|
static const errorcode_t ERROR_OK = 0;
|
||||||
static const errorcode_t ERROR_NOT_OK = 1;
|
static const errorcode_t ERROR_NOT_OK = 1;
|
||||||
|
|
||||||
static const char_t *ERROR_PRINT_FORMAT = "Error (%d): %s\n%s";
|
static const char_t *ERROR_PRINT_FORMAT = "Error (%d): %s\n%s";
|
||||||
static const char_t *ERROR_LINE_FORMAT = " at %s:%d in function %s\n";
|
static const char_t *ERROR_LINE_FORMAT = " at %s:%d in function %s\n";
|
||||||
static errorstate_t ERROR_STATE = {
|
extern THREAD_LOCAL errorstate_t ERROR_STATE;
|
||||||
.code = ERROR_OK,
|
|
||||||
.message = NULL,
|
|
||||||
.lines = NULL
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the error state with the provided code and message.
|
* Sets the error state with the provided code and message.
|
||||||
@@ -81,7 +79,7 @@ errorret_t errorChainImpl(
|
|||||||
*
|
*
|
||||||
* @param retval The return value containing the error state.
|
* @param retval The return value containing the error state.
|
||||||
*/
|
*/
|
||||||
void errorCatch(const errorret_t retval);
|
void errorCatch(errorret_t retval);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints the error state to the console.
|
* Prints the error state to the console.
|
||||||
@@ -115,7 +113,7 @@ errorret_t errorPrint(const errorret_t retval);
|
|||||||
#define errorThrow(message, ...) \
|
#define errorThrow(message, ...) \
|
||||||
return errorThrowImpl(\
|
return errorThrowImpl(\
|
||||||
&ERROR_STATE, ERROR_NOT_OK, __FILE__, __func__, __LINE__, (message), \
|
&ERROR_STATE, ERROR_NOT_OK, __FILE__, __func__, __LINE__, (message), \
|
||||||
__VA_ARGS__ \
|
##__VA_ARGS__ \
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -123,15 +121,33 @@ errorret_t errorPrint(const errorret_t retval);
|
|||||||
* @param retval The return value containing the error state.
|
* @param retval The return value containing the error state.
|
||||||
* @return The error code if an error occurred, otherwise continues execution.
|
* @return The error code if an error occurred, otherwise continues execution.
|
||||||
*/
|
*/
|
||||||
#define errorChain(retval) \
|
#define errorChain(retval) { \
|
||||||
if ((retval).code != ERROR_OK) { \
|
errorret_t errorChainRetval = (retval); \
|
||||||
return errorChainImpl(retval, __FILE__, __func__, __LINE__); \
|
if(errorChainRetval.code != ERROR_OK) { \
|
||||||
}
|
return errorChainImpl(errorChainRetval, __FILE__, __func__, __LINE__); \
|
||||||
|
} \
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns without an error.
|
* Returns without an error.
|
||||||
|
*
|
||||||
|
* @return An error state with code ERROR_OK.
|
||||||
*/
|
*/
|
||||||
#define errorOk() \
|
#define errorOk() \
|
||||||
return errorOkImpl()
|
return errorOkImpl()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns non-zero if retval indicates success.
|
||||||
|
*
|
||||||
|
* @param retval errorret_t to test.
|
||||||
|
*/
|
||||||
|
#define errorIsOk(retval) ((retval).code == ERROR_OK)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns non-zero if retval indicates failure.
|
||||||
|
*
|
||||||
|
* @param retval errorret_t to test.
|
||||||
|
*/
|
||||||
|
#define errorIsNotOk(retval) ((retval).code != ERROR_OK)
|
||||||
|
|
||||||
// EOF
|
// EOF
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
# Copyright (c) 2025 Dominic Masters
|
|
||||||
#
|
|
||||||
# This software is released under the MIT License.
|
|
||||||
# https://opensource.org/licenses/MIT
|
|
||||||
|
|
||||||
# Sources
|
|
||||||
target_sources(${DUSK_TARGET_NAME}
|
|
||||||
PRIVATE
|
|
||||||
event.c
|
|
||||||
eventtext.c
|
|
||||||
)
|
|
||||||
@@ -1,73 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "event.h"
|
|
||||||
#include "util/memory.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
|
|
||||||
eventcallback_t EVENT_CALLBACKS[] = {
|
|
||||||
[EVENT_TYPE_NULL] = { NULL, NULL },
|
|
||||||
[EVENT_TYPE_TEXT] = { eventTextStart, eventTextUpdate },
|
|
||||||
};
|
|
||||||
|
|
||||||
event_t EVENT;
|
|
||||||
|
|
||||||
void eventInit() {
|
|
||||||
memoryZero(&EVENT, sizeof(event_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
void eventUpdate() {
|
|
||||||
if(EVENT.active == NULL) {
|
|
||||||
return; // No active event to update
|
|
||||||
}
|
|
||||||
|
|
||||||
const eventitem_t *item = &EVENT.active->items[EVENT.item];
|
|
||||||
assertNotNull(
|
|
||||||
EVENT_CALLBACKS[item->type].update,
|
|
||||||
"Event type does not have an update callback"
|
|
||||||
);
|
|
||||||
|
|
||||||
EVENT_CALLBACKS[item->type].update(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
void eventSetActive(const eventdata_t *event) {
|
|
||||||
assertNotNull(event, "Event data cannot be NULL");
|
|
||||||
assertTrue(
|
|
||||||
event->itemCount <= EVENT_ITEM_COUNT_MAX,
|
|
||||||
"Event count too high"
|
|
||||||
);
|
|
||||||
assertTrue(event->itemCount > 0, "Event must have at least one item");
|
|
||||||
|
|
||||||
EVENT.active = event;
|
|
||||||
EVENT.item = 0;
|
|
||||||
|
|
||||||
const eventitem_t *firstItem = &EVENT.active->items[EVENT.item];
|
|
||||||
|
|
||||||
assertNotNull(
|
|
||||||
EVENT_CALLBACKS[firstItem->type].start,
|
|
||||||
"Event type does not have a start callback"
|
|
||||||
);
|
|
||||||
EVENT_CALLBACKS[firstItem->type].start(firstItem);
|
|
||||||
}
|
|
||||||
|
|
||||||
void eventNext() {
|
|
||||||
assertNotNull(EVENT.active, "No active event to proceed with");
|
|
||||||
assertTrue(EVENT.item < EVENT.active->itemCount, "No more items in the event");
|
|
||||||
|
|
||||||
EVENT.item++;
|
|
||||||
if (EVENT.item >= EVENT.active->itemCount) {
|
|
||||||
EVENT.active = NULL;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const eventitem_t *nextItem = &EVENT.active->items[EVENT.item];
|
|
||||||
assertNotNull(
|
|
||||||
EVENT_CALLBACKS[nextItem->type].start,
|
|
||||||
"Event type does not have a start callback"
|
|
||||||
);
|
|
||||||
EVENT_CALLBACKS[nextItem->type].start(nextItem);
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "eventdata.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
eventdata_t data;
|
|
||||||
const eventdata_t *active;
|
|
||||||
uint8_t item;
|
|
||||||
} event_t;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
void (*start)(const eventitem_t *item);
|
|
||||||
void (*update)(const eventitem_t *item);
|
|
||||||
} eventcallback_t;
|
|
||||||
|
|
||||||
extern eventcallback_t EVENT_CALLBACKS[EVENT_TYPE_COUNT];
|
|
||||||
extern event_t EVENT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the event system.
|
|
||||||
*/
|
|
||||||
void eventInit();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the active event.
|
|
||||||
*/
|
|
||||||
void eventUpdate();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the active event.
|
|
||||||
*
|
|
||||||
* @param event The event to set as active.
|
|
||||||
*/
|
|
||||||
void eventSetActive(const eventdata_t *eventData);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Goes to the next item in the active event. Only meant to be called by
|
|
||||||
* event items.
|
|
||||||
*/
|
|
||||||
void eventNext();
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "eventitem.h"
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t itemCount;
|
|
||||||
eventitem_t items[EVENT_ITEM_COUNT_MAX];
|
|
||||||
} eventdata_t;
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma ocne
|
|
||||||
#include "eventtext.h"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
EVENT_TYPE_NULL = 0,
|
|
||||||
EVENT_TYPE_TEXT,
|
|
||||||
} eventtype_t;
|
|
||||||
|
|
||||||
#define EVENT_TYPE_COUNT 2
|
|
||||||
|
|
||||||
typedef struct _eventitem_t {
|
|
||||||
eventtype_t type;
|
|
||||||
|
|
||||||
union {
|
|
||||||
eventtext_t text;
|
|
||||||
};
|
|
||||||
} eventitem_t;
|
|
||||||
|
|
||||||
#define EVENT_ITEM_COUNT_MAX 32
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "event.h"
|
|
||||||
#include "ui/uitextbox.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
|
|
||||||
void eventTextStart(const eventitem_t *item) {
|
|
||||||
assertNotNull(item, "Event item cannot be NULL");
|
|
||||||
assertTrue(item->type == EVENT_TYPE_TEXT, "Event item must be of type TEXT");
|
|
||||||
assertNotNull(item->text, "Event item must have at least one text");
|
|
||||||
uiTextboxSetText(item->text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void eventTextUpdate(const eventitem_t *item) {
|
|
||||||
assertNotNull(item, "Event item cannot be NULL");
|
|
||||||
assertTrue(item->type == EVENT_TYPE_TEXT, "Event item must be of type TEXT");
|
|
||||||
|
|
||||||
if(!UI_TEXTBOX.visible) {
|
|
||||||
eventNext();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "dusk.h"
|
|
||||||
|
|
||||||
typedef struct _eventitem_t eventitem_t;
|
|
||||||
|
|
||||||
#define EVENT_TEXT_STRING_COUNT_MAX 8
|
|
||||||
|
|
||||||
typedef const char_t* eventtext_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Starts the text event for the given item.
|
|
||||||
*
|
|
||||||
* @param item The event item to start.
|
|
||||||
*/
|
|
||||||
void eventTextStart(const eventitem_t *item);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the text event for the given item.
|
|
||||||
*
|
|
||||||
* @param item The event item to update.
|
|
||||||
*/
|
|
||||||
void eventTextUpdate(const eventitem_t *item);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Query whether the text event is done or not.
|
|
||||||
*
|
|
||||||
* @param item The event item to check.
|
|
||||||
*/
|
|
||||||
bool_t eventTextIsDone(const eventitem_t *item);
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "game.h"
|
|
||||||
#include "util/memory.h"
|
|
||||||
#include "world/chunk.h"
|
|
||||||
#include "display/scene.h"
|
|
||||||
#include "world/overworld.h"
|
|
||||||
#include "input.h"
|
|
||||||
#include "event/event.h"
|
|
||||||
#include "ui/uitextbox.h"
|
|
||||||
#include "console/console.h"
|
|
||||||
|
|
||||||
void gameInit(void) {
|
|
||||||
consoleInit();
|
|
||||||
inputInit();
|
|
||||||
eventInit();
|
|
||||||
uiTextboxInit();
|
|
||||||
overworldInit();
|
|
||||||
|
|
||||||
SCENE_CURRENT = SCENE_OVERWORLD;
|
|
||||||
}
|
|
||||||
|
|
||||||
void gameUpdate(void) {
|
|
||||||
overworldUpdate();
|
|
||||||
uiTextboxUpdate();
|
|
||||||
eventUpdate();
|
|
||||||
|
|
||||||
consoleUpdate();
|
|
||||||
inputUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
void gameDispose(void) {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "dusk.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes the game, this should be called before any other game functions.
|
|
||||||
* This should be called by the parent platform at a time that it deems
|
|
||||||
* appropriate. Any game systems cannot be used until this function has
|
|
||||||
* been called.
|
|
||||||
*
|
|
||||||
* By the point this is called, we expect;
|
|
||||||
* - Rendering has initialized and is ready to draw.
|
|
||||||
* - Input has been initialized and is ready to be read.
|
|
||||||
* - If your system handles time dynamically, it should be ready to be used.
|
|
||||||
*
|
|
||||||
* The systems called (in order) are;
|
|
||||||
* - Console.
|
|
||||||
* - Input system (Not the platforms input, but the game's input system).
|
|
||||||
* - Time system (if applicable).
|
|
||||||
* - Event System
|
|
||||||
* - UI Systems.
|
|
||||||
* - Gameplay systems.
|
|
||||||
*/
|
|
||||||
void gameInit(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Asks the game to update, this will not do any drawing and should be called
|
|
||||||
* in the main loop of the system, ideally either after or before the rendering
|
|
||||||
* has occured.
|
|
||||||
*/
|
|
||||||
void gameUpdate(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Cleans up resources used by the game, rendering really should still be
|
|
||||||
* available at this point because we want to cleanup nicely.
|
|
||||||
*/
|
|
||||||
void gameDispose(void);
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2026 Dominic Masters
|
||||||
|
*
|
||||||
|
* This software is released under the MIT License.
|
||||||
|
* https://opensource.org/licenses/MIT
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "error/error.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the game. Implemented by the game project being built (e.g.
|
||||||
|
* duskexample), not by the engine.
|
||||||
|
*
|
||||||
|
* @return An errorret_t indicating success or failure.
|
||||||
|
*/
|
||||||
|
errorret_t gameInit(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates the game, called once per frame.
|
||||||
|
*
|
||||||
|
* @return An errorret_t indicating success or failure.
|
||||||
|
*/
|
||||||
|
errorret_t gameUpdate(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disposes of the game.
|
||||||
|
*
|
||||||
|
* @return An errorret_t indicating success or failure.
|
||||||
|
*/
|
||||||
|
errorret_t gameDispose(void);
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "input.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
#include "util/memory.h"
|
|
||||||
|
|
||||||
input_t INPUT;
|
|
||||||
|
|
||||||
void inputInit(void) {
|
|
||||||
memoryZero(&INPUT, sizeof(input_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
void inputUpdate(void) {
|
|
||||||
INPUT.previous = INPUT.current;
|
|
||||||
INPUT.current = inputStateGet();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool_t inputIsDown(const uint8_t bind) {
|
|
||||||
assertTrue(bind < INPUT_BIND_COUNT, "Input bind out of bounds");
|
|
||||||
return (INPUT.current & bind) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool_t inputWasDown(const uint8_t bind) {
|
|
||||||
assertTrue(bind < INPUT_BIND_COUNT, "Input bind out of bounds");
|
|
||||||
return (INPUT.previous & bind) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool_t inputPressed(const uint8_t bind) {
|
|
||||||
return inputIsDown(bind) && !inputWasDown(bind);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool_t inputReleased(const uint8_t bind) {
|
|
||||||
return !inputIsDown(bind) && inputWasDown(bind);
|
|
||||||
}
|
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "dusk.h"
|
|
||||||
|
|
||||||
#define INPUT_BIND_UP (1 << 0)
|
|
||||||
#define INPUT_BIND_DOWN (1 << 1)
|
|
||||||
#define INPUT_BIND_LEFT (1 << 2)
|
|
||||||
#define INPUT_BIND_RIGHT (1 << 3)
|
|
||||||
#define INPUT_BIND_ACTION (1 << 4)
|
|
||||||
#define INPUT_BIND_CANCEL (1 << 5)
|
|
||||||
#define INPUT_BIND_COUNT (INPUT_BIND_CANCEL + 1)
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t current;
|
|
||||||
uint8_t previous;
|
|
||||||
} input_t;
|
|
||||||
|
|
||||||
extern input_t INPUT;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the input system.
|
|
||||||
*/
|
|
||||||
void inputInit(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Updates the input state.
|
|
||||||
*/
|
|
||||||
void inputUpdate(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current input state as a bitmask.
|
|
||||||
*
|
|
||||||
* @return The current input state as a bitmask.
|
|
||||||
*/
|
|
||||||
uint8_t inputStateGet(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a specific input bind is currently pressed.
|
|
||||||
*
|
|
||||||
* @param bind The input bind to check.
|
|
||||||
* @return true if the bind is currently pressed, false otherwise.
|
|
||||||
*/
|
|
||||||
bool_t inputIsDown(const uint8_t bind);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a specific input bind was pressed in the last update.
|
|
||||||
*
|
|
||||||
* @param bind The input bind to check.
|
|
||||||
* @return true if the bind was pressed in the last update, false otherwise.
|
|
||||||
*/
|
|
||||||
bool_t inputWasDown(const uint8_t bind);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a specific input bind was down this frame but not in the the
|
|
||||||
* previous frame.
|
|
||||||
*
|
|
||||||
* @param bind The input bind to check.
|
|
||||||
* @return true if the bind is currently pressed, false otherwise.
|
|
||||||
*/
|
|
||||||
bool_t inputPressed(const uint8_t bind);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a specific input bind was released this frame.
|
|
||||||
*
|
|
||||||
* @param bind The input bind to check.
|
|
||||||
* @return true if the bind was released this frame, false otherwise.
|
|
||||||
*/
|
|
||||||
bool_t inputReleased(const uint8_t bind);
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "inventory.h"
|
|
||||||
#include "util/memory.h"
|
|
||||||
#include "assert/assert.h"
|
|
||||||
|
|
||||||
void inventoryInit(inventory_t *inventory, const uint8_t size) {
|
|
||||||
assertNotNull(inventory, "inventory must not be NULL");
|
|
||||||
assertTrue(size <= INVENTORY_SIZE_MAX, "size exceeding INVENTORY_SIZE_MAX");
|
|
||||||
assertTrue(size > 0, "size must be greater than 0");
|
|
||||||
|
|
||||||
memoryZero(inventory, sizeof(inventory_t));
|
|
||||||
inventory->size = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t inventoryItemIndexByType(
|
|
||||||
const inventory_t *inventory,
|
|
||||||
const itemtype_t type
|
|
||||||
) {
|
|
||||||
assertNotNull(inventory, "inventory must not be NULL");
|
|
||||||
assertTrue(type > ITEM_TYPE_NULL, "type must be greater than ITEM_TYPE_NULL");
|
|
||||||
|
|
||||||
uint8_t item = inventory->itemCount;
|
|
||||||
while(item--) {
|
|
||||||
if(inventory->items[item].type == type) return item;
|
|
||||||
}
|
|
||||||
return INVENTORY_SIZE_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint8_t inventoryItemCount(
|
|
||||||
const inventory_t *inventory,
|
|
||||||
const itemtype_t type
|
|
||||||
) {
|
|
||||||
assertNotNull(inventory, "inventory must not be NULL");
|
|
||||||
assertTrue(type > ITEM_TYPE_NULL, "type must be greater than ITEM_TYPE_NULL");
|
|
||||||
|
|
||||||
const uint8_t index = inventoryItemIndexByType(inventory, type);
|
|
||||||
if(index == INVENTORY_SIZE_MAX) return 0;
|
|
||||||
return inventory->items[index].count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void inventoryItemSet(
|
|
||||||
inventory_t *inventory,
|
|
||||||
const itemtype_t type,
|
|
||||||
const uint8_t count
|
|
||||||
) {
|
|
||||||
assertNotNull(inventory, "inventory must not be NULL");
|
|
||||||
assertTrue(type > ITEM_TYPE_NULL, "type must be greater than ITEM_TYPE_NULL");
|
|
||||||
assertTrue(count > 0, "count must be greater than 0");
|
|
||||||
|
|
||||||
const uint8_t index = inventoryItemIndexByType(inventory, type);
|
|
||||||
|
|
||||||
if(index == INVENTORY_SIZE_MAX) {
|
|
||||||
// Item does not exist, add it
|
|
||||||
assertTrue(inventory->itemCount < inventory->size, "inventory is full");
|
|
||||||
inventory->items[inventory->itemCount].type = type;
|
|
||||||
inventory->items[inventory->itemCount].count = count;
|
|
||||||
inventory->itemCount++;
|
|
||||||
} else {
|
|
||||||
// Item exists, update the count
|
|
||||||
inventory->items[index].count = count;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright (c) 2025 Dominic Masters
|
|
||||||
*
|
|
||||||
* This software is released under the MIT License.
|
|
||||||
* https://opensource.org/licenses/MIT
|
|
||||||
*/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
#include "itemstack.h"
|
|
||||||
|
|
||||||
#define INVENTORY_SIZE_MAX UINT8_MAX
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
itemstack_t items[INVENTORY_SIZE_MAX];
|
|
||||||
uint8_t itemCount;
|
|
||||||
uint8_t size;
|
|
||||||
} inventory_t;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initializes an inventory with a specified size.
|
|
||||||
*
|
|
||||||
* @param inventory Pointer to the inventory to initialize.
|
|
||||||
* @param size The size of the inventory (maximum is INVENTORY_SIZE_MAX).
|
|
||||||
*/
|
|
||||||
void inventoryInit(inventory_t *inventory, const uint8_t size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Finds the index of the item of a specified type in the inventory.
|
|
||||||
*
|
|
||||||
* @param inventory Pointer to the inventory to search.
|
|
||||||
* @param type The type of item to find.
|
|
||||||
* @return The index of the item, or INVENTORY_SIZE_MAX if not found.
|
|
||||||
*/
|
|
||||||
uint8_t inventoryItemIndexByType(
|
|
||||||
const inventory_t *inventory,
|
|
||||||
const itemtype_t type
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the count of items of a specified type in the inventory.
|
|
||||||
*
|
|
||||||
* @param inventory Pointer to the inventory to check.
|
|
||||||
* @param type The type of item to count.
|
|
||||||
* @return The count of items of the specified type.
|
|
||||||
*/
|
|
||||||
uint8_t inventoryItemCount(
|
|
||||||
const inventory_t *inventory,
|
|
||||||
const itemtype_t type
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the count of items of a specified type in the inventory.
|
|
||||||
* If the item does not exist, it will be added.
|
|
||||||
*
|
|
||||||
* @param inventory Pointer to the inventory to modify.
|
|
||||||
* @param type The type of item to set.
|
|
||||||
* @param count The count of items to set.
|
|
||||||
*/
|
|
||||||
void inventoryItemSet(
|
|
||||||
inventory_t *inventory,
|
|
||||||
const itemtype_t type,
|
|
||||||
const uint8_t count
|
|
||||||
);
|
|
||||||
Loaded 100 of 242 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user