Compare commits
8
Commits
riir
...
8f62ec1c52
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8f62ec1c52 | ||
|
|
eef8f834d6 | ||
|
|
c23fc6e9df | ||
|
|
d306f19297 | ||
|
|
f22a74b036 | ||
|
|
e2c38cd03a | ||
|
|
544990c58f | ||
|
|
9fcf6b3dc5 |
Generated
+129
-159
@@ -42,9 +42,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "allocator-api2"
|
name = "allocator-api2"
|
||||||
version = "0.2.18"
|
version = "0.2.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f"
|
checksum = "45862d1c77f2228b9e10bc609d5bc203d86ebc9b87ad8d5d5167a6c9abf739d9"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "alsa"
|
name = "alsa"
|
||||||
@@ -106,9 +106,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstream"
|
name = "anstream"
|
||||||
version = "0.6.17"
|
version = "0.6.18"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "23a1e53f0f5d86382dafe1cf314783b2044280f406e7e1506368220ad11b1338"
|
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstyle",
|
"anstyle",
|
||||||
"anstyle-parse",
|
"anstyle-parse",
|
||||||
@@ -155,9 +155,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.92"
|
version = "1.0.93"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "74f37166d7d48a0284b99dd824694c26119c700b53bf0d1540cdb147dbdaaf13"
|
checksum = "4c95c10ba0b00a02636238b814946408b1322d5ac4760326e6fb8ec956d85775"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "arrayref"
|
name = "arrayref"
|
||||||
@@ -219,23 +219,23 @@ dependencies = [
|
|||||||
"regex",
|
"regex",
|
||||||
"rustc-hash",
|
"rustc-hash",
|
||||||
"shlex",
|
"shlex",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit-set"
|
name = "bit-set"
|
||||||
version = "0.6.0"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f0481a0e032742109b1133a095184ee93d88f3dc9e0d28a5d033dc77a073f44f"
|
checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bit-vec",
|
"bit-vec",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bit-vec"
|
name = "bit-vec"
|
||||||
version = "0.7.0"
|
version = "0.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d2c54ff287cfc0a34f38a6b832ea1bd8e448a330b3e40a50859e6488bee07f22"
|
checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
@@ -287,7 +287,7 @@ checksum = "bcfcc3cd946cb52f0bbfdbbcfa2f4e24f75ebb6c0e1002f7c25904fada18b9ec"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -324,9 +324,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cc"
|
name = "cc"
|
||||||
version = "1.1.34"
|
version = "1.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "67b9470d453346108f93a59222a9a1a5724db32d0a4727b7ab7ace4b4d822dc9"
|
checksum = "fd9de9f2205d5ef3fd67e685b0df337994ddd4495e2a28d185500d0e1edfea47"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"jobserver",
|
"jobserver",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -385,9 +385,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "4.5.20"
|
version = "4.5.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b97f376d85a664d5837dbae44bf546e6477a679ff6610010f17276f686d867e8"
|
checksum = "fb3b4b9e5a7c7514dfa52869339ee98b3156b0bfb4e8a77c4ff4babb64b1604f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap_builder",
|
"clap_builder",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
@@ -395,9 +395,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_builder"
|
name = "clap_builder"
|
||||||
version = "4.5.20"
|
version = "4.5.21"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "19bc80abd44e4bed93ca373a0704ccbd1b710dc5749406201bb018272808dc54"
|
checksum = "b17a95aa67cc7b5ebd32aa5370189aa0d79069ef1c64ce893bd30fb24bff20ec"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anstream",
|
"anstream",
|
||||||
"anstyle",
|
"anstyle",
|
||||||
@@ -414,14 +414,14 @@ dependencies = [
|
|||||||
"heck",
|
"heck",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_lex"
|
name = "clap_lex"
|
||||||
version = "0.7.2"
|
version = "0.7.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1462739cb27611015575c0c11df5df7601141071f07518d56fcc1be504cbec97"
|
checksum = "afb84c814227b90d6895e01398aee0d8033c00e7466aca416fb6a8e0eb19d8a7"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cocoa"
|
name = "cocoa"
|
||||||
@@ -469,37 +469,6 @@ version = "1.0.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "com"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7e17887fd17353b65b1b2ef1c526c83e26cd72e74f598a8dc1bee13a48f3d9f6"
|
|
||||||
dependencies = [
|
|
||||||
"com_macros",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "com_macros"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "d375883580a668c7481ea6631fc1a8863e33cc335bf56bfad8d7e6d4b04b13a5"
|
|
||||||
dependencies = [
|
|
||||||
"com_macros_support",
|
|
||||||
"proc-macro2",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "com_macros_support"
|
|
||||||
version = "0.6.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ad899a1087a9296d5644792d7cb72b8e34c1bec8e7d4fbc002230169a6e8710c"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn 1.0.109",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "combine"
|
name = "combine"
|
||||||
version = "4.6.7"
|
version = "4.6.7"
|
||||||
@@ -614,17 +583,6 @@ version = "1.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
|
checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "d3d12"
|
|
||||||
version = "22.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bdbd1f579714e3c809ebd822c81ef148b1ceaeb3d535352afc73fd0c4c6a0017"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.6.0",
|
|
||||||
"libloading",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dasp_sample"
|
name = "dasp_sample"
|
||||||
version = "0.11.0"
|
version = "0.11.0"
|
||||||
@@ -728,7 +686,7 @@ checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -777,9 +735,9 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glow"
|
name = "glow"
|
||||||
version = "0.13.1"
|
version = "0.14.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bd348e04c43b32574f2de31c8bb397d96c9fcfa1371bd4ca6d8bdc464ab121b1"
|
checksum = "d51fa363f025f5c111e03f13eda21162faeacb6911fe8caa0c0349f9cf0c4483"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"slotmap",
|
"slotmap",
|
||||||
@@ -817,15 +775,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gpu-allocator"
|
name = "gpu-allocator"
|
||||||
version = "0.26.0"
|
version = "0.27.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "fdd4240fc91d3433d5e5b0fc5b67672d771850dc19bbee03c1381e19322803d7"
|
checksum = "c151a2a5ef800297b4e79efa4f4bec035c5f51d5ae587287c9b952bdf734cacd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"log",
|
"log",
|
||||||
"presser",
|
"presser",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"winapi",
|
"windows 0.58.0",
|
||||||
"windows 0.52.0",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -860,24 +817,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.15.0"
|
version = "0.15.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e087f84d4f86bf4b218b927129862374b72199ae7d8657835f1e89000eea4fb"
|
checksum = "3a9bfc1af68b1726ea47d3d5109de126281def866b33970e10fbab11b5dafab3"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "hassle-rs"
|
|
||||||
version = "0.11.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890"
|
|
||||||
dependencies = [
|
|
||||||
"bitflags 2.6.0",
|
|
||||||
"com",
|
|
||||||
"libc",
|
|
||||||
"libloading",
|
|
||||||
"thiserror",
|
|
||||||
"widestring",
|
|
||||||
"winapi",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "heck"
|
name = "heck"
|
||||||
@@ -934,7 +876,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "imgui-wgpu"
|
name = "imgui-wgpu"
|
||||||
version = "0.25.0"
|
version = "0.25.0"
|
||||||
source = "git+https://github.com/Yatekii/imgui-wgpu-rs?rev=2edd348#2edd348a0fc11e9e72f19060c34a6e45c760b116"
|
source = "git+https://github.com/SupernaviX/imgui-wgpu-rs?rev=5bb8673#5bb8673e256b6b5ad497a3baa2dc151545025f12"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bytemuck",
|
"bytemuck",
|
||||||
"imgui",
|
"imgui",
|
||||||
@@ -960,7 +902,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
|
checksum = "707907fe3c25f5424cce2cb7e1cbcafee6bdbe735ca90ef77c29e84591e5b9da"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown 0.15.0",
|
"hashbrown 0.15.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1046,9 +988,9 @@ checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.161"
|
version = "0.2.162"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e9489c2807c139ffd9c1794f4af0ebe86a828db53ecdc7fea2111d0fed085d1"
|
checksum = "18d287de67fe55fd7e1581fe933d965a5a9477b38e949cfa9f8574ef01506398"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libloading"
|
name = "libloading"
|
||||||
@@ -1161,9 +1103,9 @@ checksum = "e53debba6bda7a793e5f99b8dacf19e626084f525f7829104ba9898f367d85ff"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "naga"
|
name = "naga"
|
||||||
version = "22.1.0"
|
version = "23.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8bd5a652b6faf21496f2cfd88fc49989c8db0825d1f6746b1a71a6ede24a63ad"
|
checksum = "3d5941e45a15b53aad4375eedf02033adb7a28931eedc31117faffa52e6a857e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"bit-set",
|
"bit-set",
|
||||||
@@ -1283,7 +1225,7 @@ checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1322,7 +1264,7 @@ dependencies = [
|
|||||||
"proc-macro-crate",
|
"proc-macro-crate",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1656,7 +1598,7 @@ checksum = "3c0f5fad0874fc7abcd4d750e76917eaebbecaa2c20bde22e1dbeeba8beb758c"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1673,9 +1615,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "polling"
|
name = "polling"
|
||||||
version = "3.7.3"
|
version = "3.7.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cc2790cd301dec6cd3b7a025e4815cf825724a51c98dccfe6a3e55f05ffb6511"
|
checksum = "a604568c3202727d1507653cb121dbd627a58684eb09a820fd746bee38b4442f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"concurrent-queue",
|
"concurrent-queue",
|
||||||
@@ -1819,9 +1761,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-automata"
|
name = "regex-automata"
|
||||||
version = "0.4.8"
|
version = "0.4.9"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
|
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -1881,9 +1823,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "0.38.38"
|
version = "0.38.40"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a"
|
checksum = "99e4ea3e1cdc4b559b8e5650f9c8e5998e3e5c1343b4eaf034565f32318d63c0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"errno",
|
"errno",
|
||||||
@@ -1934,22 +1876,22 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.214"
|
version = "1.0.215"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f55c3193aca71c12ad7890f1785d2b73e1b9f63a0bbc353c08ef26fe03fc56b5"
|
checksum = "6513c1ad0b11a9376da888e3e0baa0077f1aed55c17f50e7b2397136129fb88f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.214"
|
version = "1.0.215"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "de523f781f095e28fa605cdce0f8307e451cc0fd14e2eb4cd2e98a355b147766"
|
checksum = "ad1e866f866923f252f05c889987993144fb74e722403468a4ebd70c3cd756c0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2074,17 +2016,6 @@ version = "0.11.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "syn"
|
|
||||||
version = "1.0.109"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"unicode-ident",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.87"
|
version = "2.0.87"
|
||||||
@@ -2107,22 +2038,22 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.66"
|
version = "1.0.69"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5d171f59dbaa811dbbb1aee1e73db92ec2b122911a48e1390dfe327a821ddede"
|
checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.66"
|
version = "1.0.69"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b08be0f17bd307950653ce45db00cd31200d82b624b36e181337d9c7d92765b5"
|
checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -2297,7 +2228,7 @@ dependencies = [
|
|||||||
"once_cell",
|
"once_cell",
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2331,7 +2262,7 @@ checksum = "26c6ab57572f7a24a4985830b120de1594465e5d500f24afe89e16b4e833ef68"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
"wasm-bindgen-backend",
|
"wasm-bindgen-backend",
|
||||||
"wasm-bindgen-shared",
|
"wasm-bindgen-shared",
|
||||||
]
|
]
|
||||||
@@ -2483,9 +2414,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu"
|
name = "wgpu"
|
||||||
version = "22.1.0"
|
version = "23.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e1d1c4ba43f80542cf63a0a6ed3134629ae73e8ab51e4b765a67f3aa062eb433"
|
checksum = "76ab52f2d3d18b70d5ab8dd270a1cff3ebe6dbe4a7d13c1cc2557138a9777fdc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"cfg_aliases 0.1.1",
|
"cfg_aliases 0.1.1",
|
||||||
@@ -2508,9 +2439,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-core"
|
name = "wgpu-core"
|
||||||
version = "22.1.0"
|
version = "23.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0348c840d1051b8e86c3bcd31206080c5e71e5933dabd79be1ce732b0b2f089a"
|
checksum = "0e0c68e7b6322a03ee5b83fcd92caeac5c2a932f6457818179f4652ad2a9c065"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
"bit-vec",
|
"bit-vec",
|
||||||
@@ -2533,9 +2464,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-hal"
|
name = "wgpu-hal"
|
||||||
version = "22.0.0"
|
version = "23.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f6bbf4b4de8b2a83c0401d9e5ae0080a2792055f25859a02bf9be97952bbed4f"
|
checksum = "de6e7266b869de56c7e3ed72a954899f71d14fec6cc81c102b7530b92947601b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"android_system_properties",
|
"android_system_properties",
|
||||||
"arrayvec",
|
"arrayvec",
|
||||||
@@ -2543,15 +2474,14 @@ dependencies = [
|
|||||||
"bit-set",
|
"bit-set",
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"block",
|
"block",
|
||||||
|
"bytemuck",
|
||||||
"cfg_aliases 0.1.1",
|
"cfg_aliases 0.1.1",
|
||||||
"core-graphics-types",
|
"core-graphics-types",
|
||||||
"d3d12",
|
|
||||||
"glow",
|
"glow",
|
||||||
"glutin_wgl_sys",
|
"glutin_wgl_sys",
|
||||||
"gpu-alloc",
|
"gpu-alloc",
|
||||||
"gpu-allocator",
|
"gpu-allocator",
|
||||||
"gpu-descriptor",
|
"gpu-descriptor",
|
||||||
"hassle-rs",
|
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"khronos-egl",
|
"khronos-egl",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -2573,14 +2503,15 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
"web-sys",
|
"web-sys",
|
||||||
"wgpu-types",
|
"wgpu-types",
|
||||||
"winapi",
|
"windows 0.58.0",
|
||||||
|
"windows-core 0.58.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wgpu-types"
|
name = "wgpu-types"
|
||||||
version = "22.0.0"
|
version = "23.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bc9d91f0e2c4b51434dfa6db77846f2793149d8e73f800fa2e41f52b8eac3c5d"
|
checksum = "610f6ff27778148c31093f3b03abc4840f9636d58d597ca2f5977433acfe0068"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags 2.6.0",
|
"bitflags 2.6.0",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
@@ -2599,12 +2530,6 @@ dependencies = [
|
|||||||
"rustix",
|
"rustix",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "widestring"
|
|
||||||
version = "1.1.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@@ -2636,16 +2561,6 @@ version = "0.4.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "windows"
|
|
||||||
version = "0.52.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be"
|
|
||||||
dependencies = [
|
|
||||||
"windows-core 0.52.0",
|
|
||||||
"windows-targets 0.52.6",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows"
|
name = "windows"
|
||||||
version = "0.54.0"
|
version = "0.54.0"
|
||||||
@@ -2657,11 +2572,12 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-core"
|
name = "windows"
|
||||||
version = "0.52.0"
|
version = "0.58.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9"
|
checksum = "dd04d41d93c4992d421894c18c8b43496aa748dd4c081bac0dc93eb0489272b6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"windows-core 0.58.0",
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -2671,10 +2587,45 @@ version = "0.54.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65"
|
checksum = "12661b9c89351d684a50a8a643ce5f608e20243b9fb84687800163429f161d65"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-result",
|
"windows-result 0.1.2",
|
||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-core"
|
||||||
|
version = "0.58.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6ba6d44ec8c2591c134257ce647b7ea6b20335bf6379a27dac5f1641fcf59f99"
|
||||||
|
dependencies = [
|
||||||
|
"windows-implement",
|
||||||
|
"windows-interface",
|
||||||
|
"windows-result 0.2.0",
|
||||||
|
"windows-strings",
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-implement"
|
||||||
|
version = "0.58.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2bbd5b46c938e506ecbce286b6628a02171d56153ba733b6c741fc627ec9579b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-interface"
|
||||||
|
version = "0.58.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "053c4c462dc91d3b1504c6fe5a726dd15e216ba718e84a0e46a88fbe5ded3515"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-result"
|
name = "windows-result"
|
||||||
version = "0.1.2"
|
version = "0.1.2"
|
||||||
@@ -2684,6 +2635,25 @@ dependencies = [
|
|||||||
"windows-targets 0.52.6",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-result"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
|
||||||
|
dependencies = [
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-strings"
|
||||||
|
version = "0.1.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
|
||||||
|
dependencies = [
|
||||||
|
"windows-result 0.2.0",
|
||||||
|
"windows-targets 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.45.0"
|
version = "0.45.0"
|
||||||
@@ -3009,9 +2979,9 @@ checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "xml-rs"
|
name = "xml-rs"
|
||||||
version = "0.8.22"
|
version = "0.8.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "af4e2e2f7cba5a093896c1e150fbfe177d1883e7448200efb81d40b9d339ef26"
|
checksum = "af310deaae937e48a26602b730250b4949e125f468f11e6990be3e5304ddd96f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
@@ -3030,5 +3000,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.87",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|||||||
+2
-2
@@ -10,7 +10,7 @@ bytemuck = { version = "1", features = ["derive"] }
|
|||||||
clap = { version = "4", features = ["derive"] }
|
clap = { version = "4", features = ["derive"] }
|
||||||
cpal = "0.15"
|
cpal = "0.15"
|
||||||
imgui = { version = "0.12", features = ["tables-api"] }
|
imgui = { version = "0.12", features = ["tables-api"] }
|
||||||
imgui-wgpu = { git = "https://github.com/Yatekii/imgui-wgpu-rs", rev = "2edd348" }
|
imgui-wgpu = { git = "https://github.com/SupernaviX/imgui-wgpu-rs", rev = "5bb8673" }
|
||||||
imgui-winit-support = "0.13"
|
imgui-winit-support = "0.13"
|
||||||
itertools = "0.13"
|
itertools = "0.13"
|
||||||
native-dialog = "0.7"
|
native-dialog = "0.7"
|
||||||
@@ -20,7 +20,7 @@ pollster = "0.4"
|
|||||||
rtrb = "0.3"
|
rtrb = "0.3"
|
||||||
rubato = "0.16"
|
rubato = "0.16"
|
||||||
thread-priority = "1"
|
thread-priority = "1"
|
||||||
wgpu = "22.1"
|
wgpu = "23.0"
|
||||||
winit = "0.30"
|
winit = "0.30"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|||||||
@@ -5,8 +5,10 @@ fn main() {
|
|||||||
cc::Build::new()
|
cc::Build::new()
|
||||||
.include(Path::new("shrooms-vb-core/core"))
|
.include(Path::new("shrooms-vb-core/core"))
|
||||||
.opt_level(2)
|
.opt_level(2)
|
||||||
.flag_if_supported("-flto")
|
|
||||||
.flag_if_supported("-fno-strict-aliasing")
|
.flag_if_supported("-fno-strict-aliasing")
|
||||||
|
.define("VB_LITTLE_ENDIAN", None)
|
||||||
|
.define("VB_SIGNED_PROPAGATE", None)
|
||||||
|
.define("VB_DIV_GENERIC", None)
|
||||||
.file(Path::new("shrooms-vb-core/core/vb.c"))
|
.file(Path::new("shrooms-vb-core/core/vb.c"))
|
||||||
.compile("vb");
|
.compile("vb");
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
Submodule shrooms-vb-core updated: ae22c95dbe...7e31fbd582
+34
-23
@@ -5,6 +5,7 @@ use std::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use game::GameWindow;
|
use game::GameWindow;
|
||||||
|
use input::InputWindow;
|
||||||
use winit::{
|
use winit::{
|
||||||
application::ApplicationHandler,
|
application::ApplicationHandler,
|
||||||
event::{Event, WindowEvent},
|
event::{Event, WindowEvent},
|
||||||
@@ -14,7 +15,7 @@ use winit::{
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
controller::ControllerState,
|
controller::ControllerState,
|
||||||
emulator::{EmulatorClient, EmulatorCommand},
|
emulator::{EmulatorClient, EmulatorCommand, SimId},
|
||||||
input::InputMapper,
|
input::InputMapper,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -28,6 +29,7 @@ pub struct App {
|
|||||||
input_mapper: Arc<RwLock<InputMapper>>,
|
input_mapper: Arc<RwLock<InputMapper>>,
|
||||||
controller: ControllerState,
|
controller: ControllerState,
|
||||||
proxy: EventLoopProxy<UserEvent>,
|
proxy: EventLoopProxy<UserEvent>,
|
||||||
|
player_2_window: Option<WindowId>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl App {
|
impl App {
|
||||||
@@ -40,19 +42,19 @@ impl App {
|
|||||||
input_mapper,
|
input_mapper,
|
||||||
controller,
|
controller,
|
||||||
proxy,
|
proxy,
|
||||||
|
player_2_window: None,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ApplicationHandler<UserEvent> for App {
|
impl ApplicationHandler<UserEvent> for App {
|
||||||
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
fn resumed(&mut self, event_loop: &ActiveEventLoop) {
|
||||||
let mut window = GameWindow::new(
|
let window = GameWindow::new(
|
||||||
event_loop,
|
event_loop,
|
||||||
|
SimId::Player1,
|
||||||
self.client.clone(),
|
self.client.clone(),
|
||||||
self.input_mapper.clone(),
|
|
||||||
self.proxy.clone(),
|
self.proxy.clone(),
|
||||||
);
|
);
|
||||||
window.init();
|
|
||||||
self.windows.insert(window.id(), Box::new(window));
|
self.windows.insert(window.id(), Box::new(window));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -63,9 +65,9 @@ impl ApplicationHandler<UserEvent> for App {
|
|||||||
event: WindowEvent,
|
event: WindowEvent,
|
||||||
) {
|
) {
|
||||||
if let WindowEvent::KeyboardInput { event, .. } = &event {
|
if let WindowEvent::KeyboardInput { event, .. } = &event {
|
||||||
if self.controller.key_event(event) {
|
if let Some((sim_id, pressed)) = self.controller.key_event(event) {
|
||||||
self.client
|
self.client
|
||||||
.send_command(EmulatorCommand::SetKeys(self.controller.pressed()));
|
.send_command(EmulatorCommand::SetKeys(sim_id, pressed));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let Some(window) = self.windows.get_mut(&window_id) else {
|
let Some(window) = self.windows.get_mut(&window_id) else {
|
||||||
@@ -74,13 +76,30 @@ impl ApplicationHandler<UserEvent> for App {
|
|||||||
window.handle_event(event_loop, &Event::WindowEvent { window_id, event });
|
window.handle_event(event_loop, &Event::WindowEvent { window_id, event });
|
||||||
}
|
}
|
||||||
|
|
||||||
fn user_event(&mut self, _event_loop: &ActiveEventLoop, event: UserEvent) {
|
fn user_event(&mut self, event_loop: &ActiveEventLoop, event: UserEvent) {
|
||||||
match event {
|
match event {
|
||||||
UserEvent::OpenWindow(mut window) => {
|
UserEvent::OpenInputWindow => {
|
||||||
window.init();
|
let window =
|
||||||
self.windows.insert(window.id(), window);
|
InputWindow::new(event_loop, self.input_mapper.clone(), self.proxy.clone());
|
||||||
|
self.windows.insert(window.id(), Box::new(window));
|
||||||
|
}
|
||||||
|
UserEvent::OpenPlayer2Window => {
|
||||||
|
if self.player_2_window.is_some() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let window = GameWindow::new(
|
||||||
|
event_loop,
|
||||||
|
SimId::Player2,
|
||||||
|
self.client.clone(),
|
||||||
|
self.proxy.clone(),
|
||||||
|
);
|
||||||
|
self.player_2_window = Some(window.id());
|
||||||
|
self.windows.insert(window.id(), Box::new(window));
|
||||||
|
}
|
||||||
|
UserEvent::Close(window_id) => {
|
||||||
|
if self.player_2_window == Some(window_id) {
|
||||||
|
self.player_2_window.take();
|
||||||
}
|
}
|
||||||
UserEvent::CloseWindow(window_id) => {
|
|
||||||
self.windows.remove(&window_id);
|
self.windows.remove(&window_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -112,20 +131,12 @@ impl ApplicationHandler<UserEvent> for App {
|
|||||||
|
|
||||||
pub trait AppWindow {
|
pub trait AppWindow {
|
||||||
fn id(&self) -> WindowId;
|
fn id(&self) -> WindowId;
|
||||||
fn init(&mut self);
|
|
||||||
fn handle_event(&mut self, event_loop: &ActiveEventLoop, event: &Event<UserEvent>);
|
fn handle_event(&mut self, event_loop: &ActiveEventLoop, event: &Event<UserEvent>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
pub enum UserEvent {
|
pub enum UserEvent {
|
||||||
OpenWindow(Box<dyn AppWindow>),
|
OpenInputWindow,
|
||||||
CloseWindow(WindowId),
|
OpenPlayer2Window,
|
||||||
}
|
Close(WindowId),
|
||||||
|
|
||||||
impl Debug for UserEvent {
|
|
||||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
|
||||||
match self {
|
|
||||||
Self::OpenWindow(window) => f.debug_tuple("OpenWindow").field(&window.id()).finish(),
|
|
||||||
Self::CloseWindow(window_id) => f.debug_tuple("CloseWindow").field(window_id).finish(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
+41
-42
@@ -1,7 +1,4 @@
|
|||||||
use std::{
|
use std::time::Instant;
|
||||||
sync::{Arc, RwLock},
|
|
||||||
time::Instant,
|
|
||||||
};
|
|
||||||
use wgpu::util::DeviceExt as _;
|
use wgpu::util::DeviceExt as _;
|
||||||
use winit::{
|
use winit::{
|
||||||
dpi::LogicalSize,
|
dpi::LogicalSize,
|
||||||
@@ -11,24 +8,22 @@ use winit::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
emulator::{EmulatorClient, EmulatorCommand},
|
emulator::{EmulatorClient, EmulatorCommand, SimId},
|
||||||
input::InputMapper,
|
graphics::TextureSink,
|
||||||
renderer::GameRenderer,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
common::{ImguiState, WindowState, WindowStateBuilder},
|
common::{ImguiState, WindowState, WindowStateBuilder},
|
||||||
input::InputWindow,
|
|
||||||
AppWindow, UserEvent,
|
AppWindow, UserEvent,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct GameWindow {
|
pub struct GameWindow {
|
||||||
window: WindowState,
|
window: WindowState,
|
||||||
imgui: Option<ImguiState>,
|
imgui: ImguiState,
|
||||||
pipeline: wgpu::RenderPipeline,
|
pipeline: wgpu::RenderPipeline,
|
||||||
bind_group: wgpu::BindGroup,
|
bind_group: wgpu::BindGroup,
|
||||||
|
sim_id: SimId,
|
||||||
client: EmulatorClient,
|
client: EmulatorClient,
|
||||||
input_mapper: Arc<RwLock<InputMapper>>,
|
|
||||||
proxy: EventLoopProxy<UserEvent>,
|
proxy: EventLoopProxy<UserEvent>,
|
||||||
paused_due_to_minimize: bool,
|
paused_due_to_minimize: bool,
|
||||||
}
|
}
|
||||||
@@ -36,22 +31,23 @@ pub struct GameWindow {
|
|||||||
impl GameWindow {
|
impl GameWindow {
|
||||||
pub fn new(
|
pub fn new(
|
||||||
event_loop: &ActiveEventLoop,
|
event_loop: &ActiveEventLoop,
|
||||||
|
sim_id: SimId,
|
||||||
client: EmulatorClient,
|
client: EmulatorClient,
|
||||||
input_mapper: Arc<RwLock<InputMapper>>,
|
|
||||||
proxy: EventLoopProxy<UserEvent>,
|
proxy: EventLoopProxy<UserEvent>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
let title = if sim_id == SimId::Player2 {
|
||||||
|
"Shrooms VB (Player 2)"
|
||||||
|
} else {
|
||||||
|
"Shrooms VB"
|
||||||
|
};
|
||||||
let window = WindowStateBuilder::new(event_loop)
|
let window = WindowStateBuilder::new(event_loop)
|
||||||
.with_title("Shrooms VB")
|
.with_title(title)
|
||||||
.with_inner_size(LogicalSize::new(384, 244))
|
.with_inner_size(LogicalSize::new(384, 244))
|
||||||
.build();
|
.build();
|
||||||
let device = &window.device;
|
let device = &window.device;
|
||||||
|
|
||||||
let eyes = Arc::new(GameRenderer::create_texture(device, "eye"));
|
let (sink, texture_view) = TextureSink::new(device, window.queue.clone());
|
||||||
client.send_command(EmulatorCommand::SetRenderer(GameRenderer {
|
client.send_command(EmulatorCommand::SetRenderer(sim_id, sink));
|
||||||
queue: window.queue.clone(),
|
|
||||||
eyes: eyes.clone(),
|
|
||||||
}));
|
|
||||||
let eyes = eyes.create_view(&wgpu::TextureViewDescriptor::default());
|
|
||||||
let sampler = device.create_sampler(&wgpu::SamplerDescriptor::default());
|
let sampler = device.create_sampler(&wgpu::SamplerDescriptor::default());
|
||||||
let colors = Colors {
|
let colors = Colors {
|
||||||
left: [1.0, 0.0, 0.0, 1.0],
|
left: [1.0, 0.0, 0.0, 1.0],
|
||||||
@@ -100,7 +96,7 @@ impl GameWindow {
|
|||||||
entries: &[
|
entries: &[
|
||||||
wgpu::BindGroupEntry {
|
wgpu::BindGroupEntry {
|
||||||
binding: 0,
|
binding: 0,
|
||||||
resource: wgpu::BindingResource::TextureView(&eyes),
|
resource: wgpu::BindingResource::TextureView(&texture_view),
|
||||||
},
|
},
|
||||||
wgpu::BindGroupEntry {
|
wgpu::BindGroupEntry {
|
||||||
binding: 1,
|
binding: 1,
|
||||||
@@ -125,13 +121,13 @@ impl GameWindow {
|
|||||||
layout: Some(&render_pipeline_layout),
|
layout: Some(&render_pipeline_layout),
|
||||||
vertex: wgpu::VertexState {
|
vertex: wgpu::VertexState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "vs_main",
|
entry_point: Some("vs_main"),
|
||||||
buffers: &[],
|
buffers: &[],
|
||||||
compilation_options: wgpu::PipelineCompilationOptions::default(),
|
compilation_options: wgpu::PipelineCompilationOptions::default(),
|
||||||
},
|
},
|
||||||
fragment: Some(wgpu::FragmentState {
|
fragment: Some(wgpu::FragmentState {
|
||||||
module: &shader,
|
module: &shader,
|
||||||
entry_point: "fs_main",
|
entry_point: Some("fs_main"),
|
||||||
targets: &[Some(wgpu::ColorTargetState {
|
targets: &[Some(wgpu::ColorTargetState {
|
||||||
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
format: wgpu::TextureFormat::Bgra8UnormSrgb,
|
||||||
blend: Some(wgpu::BlendState::REPLACE),
|
blend: Some(wgpu::BlendState::REPLACE),
|
||||||
@@ -158,13 +154,15 @@ impl GameWindow {
|
|||||||
cache: None,
|
cache: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
let imgui = ImguiState::new(&window);
|
||||||
|
|
||||||
Self {
|
Self {
|
||||||
window,
|
window,
|
||||||
imgui: None,
|
imgui,
|
||||||
pipeline: render_pipeline,
|
pipeline: render_pipeline,
|
||||||
bind_group,
|
bind_group,
|
||||||
|
sim_id,
|
||||||
client,
|
client,
|
||||||
input_mapper,
|
|
||||||
proxy,
|
proxy,
|
||||||
paused_due_to_minimize: false,
|
paused_due_to_minimize: false,
|
||||||
}
|
}
|
||||||
@@ -172,7 +170,7 @@ impl GameWindow {
|
|||||||
|
|
||||||
fn draw(&mut self, event_loop: &ActiveEventLoop) {
|
fn draw(&mut self, event_loop: &ActiveEventLoop) {
|
||||||
let window = &mut self.window;
|
let window = &mut self.window;
|
||||||
let imgui = self.imgui.as_mut().unwrap();
|
let imgui = &mut self.imgui;
|
||||||
let mut context = imgui.context.lock().unwrap();
|
let mut context = imgui.context.lock().unwrap();
|
||||||
let mut new_size = None;
|
let mut new_size = None;
|
||||||
|
|
||||||
@@ -204,7 +202,8 @@ impl GameWindow {
|
|||||||
.show_open_single_file()
|
.show_open_single_file()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
if let Some(path) = rom {
|
if let Some(path) = rom {
|
||||||
self.client.send_command(EmulatorCommand::LoadGame(path));
|
self.client
|
||||||
|
.send_command(EmulatorCommand::LoadGame(self.sim_id, path));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ui.menu_item("Quit") {
|
if ui.menu_item("Quit") {
|
||||||
@@ -240,14 +239,14 @@ impl GameWindow {
|
|||||||
});
|
});
|
||||||
ui.menu("Input", || {
|
ui.menu("Input", || {
|
||||||
if ui.menu_item("Bind Inputs") {
|
if ui.menu_item("Bind Inputs") {
|
||||||
let input_window = Box::new(InputWindow::new(
|
self.proxy.send_event(UserEvent::OpenInputWindow).unwrap();
|
||||||
event_loop,
|
}
|
||||||
self.input_mapper.clone(),
|
});
|
||||||
self.proxy.clone(),
|
ui.menu("Multiplayer", || {
|
||||||
));
|
if self.sim_id == SimId::Player1 && ui.menu_item("Open Player 2") {
|
||||||
self.proxy
|
self.client
|
||||||
.send_event(UserEvent::OpenWindow(input_window))
|
.send_command(EmulatorCommand::StartSecondSim(None));
|
||||||
.unwrap();
|
self.proxy.send_event(UserEvent::OpenPlayer2Window).unwrap();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -321,11 +320,6 @@ impl AppWindow for GameWindow {
|
|||||||
self.window.window.id()
|
self.window.window.id()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(&mut self) {
|
|
||||||
self.imgui = Some(ImguiState::new(&self.window));
|
|
||||||
self.window.window.request_redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_event(&mut self, event_loop: &ActiveEventLoop, event: &Event<UserEvent>) {
|
fn handle_event(&mut self, event_loop: &ActiveEventLoop, event: &Event<UserEvent>) {
|
||||||
match event {
|
match event {
|
||||||
Event::WindowEvent { event, .. } => match event {
|
Event::WindowEvent { event, .. } => match event {
|
||||||
@@ -341,7 +335,14 @@ impl AppWindow for GameWindow {
|
|||||||
self.paused_due_to_minimize = false;
|
self.paused_due_to_minimize = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WindowEvent::CloseRequested => event_loop.exit(),
|
WindowEvent::CloseRequested => {
|
||||||
|
if self.sim_id == SimId::Player2 {
|
||||||
|
self.client.send_command(EmulatorCommand::StopSecondSim);
|
||||||
|
self.proxy.send_event(UserEvent::Close(self.id())).unwrap();
|
||||||
|
} else {
|
||||||
|
event_loop.exit();
|
||||||
|
}
|
||||||
|
}
|
||||||
WindowEvent::RedrawRequested => self.draw(event_loop),
|
WindowEvent::RedrawRequested => self.draw(event_loop),
|
||||||
_ => (),
|
_ => (),
|
||||||
},
|
},
|
||||||
@@ -351,9 +352,7 @@ impl AppWindow for GameWindow {
|
|||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
let window = &self.window;
|
let window = &self.window;
|
||||||
let Some(imgui) = self.imgui.as_mut() else {
|
let imgui = &mut self.imgui;
|
||||||
return;
|
|
||||||
};
|
|
||||||
let mut context = imgui.context.lock().unwrap();
|
let mut context = imgui.context.lock().unwrap();
|
||||||
imgui
|
imgui
|
||||||
.platform
|
.platform
|
||||||
|
|||||||
+25
-26
@@ -7,10 +7,12 @@ use winit::{
|
|||||||
dpi::LogicalSize,
|
dpi::LogicalSize,
|
||||||
event::{Event, KeyEvent, WindowEvent},
|
event::{Event, KeyEvent, WindowEvent},
|
||||||
event_loop::{ActiveEventLoop, EventLoopProxy},
|
event_loop::{ActiveEventLoop, EventLoopProxy},
|
||||||
platform::modifier_supplement::KeyEventExtModifierSupplement,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{input::InputMapper, shrooms_vb_core::VBKey};
|
use crate::{
|
||||||
|
emulator::{SimId, VBKey},
|
||||||
|
input::InputMapper,
|
||||||
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
common::{ImguiState, UiExt, WindowState, WindowStateBuilder},
|
common::{ImguiState, UiExt, WindowState, WindowStateBuilder},
|
||||||
@@ -19,10 +21,10 @@ use super::{
|
|||||||
|
|
||||||
pub struct InputWindow {
|
pub struct InputWindow {
|
||||||
window: WindowState,
|
window: WindowState,
|
||||||
imgui: Option<ImguiState>,
|
imgui: ImguiState,
|
||||||
input_mapper: Arc<RwLock<InputMapper>>,
|
input_mapper: Arc<RwLock<InputMapper>>,
|
||||||
proxy: EventLoopProxy<UserEvent>,
|
proxy: EventLoopProxy<UserEvent>,
|
||||||
now_binding: Option<VBKey>,
|
now_binding: Option<(SimId, VBKey)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
const KEY_NAMES: [(VBKey, &str); 14] = [
|
const KEY_NAMES: [(VBKey, &str); 14] = [
|
||||||
@@ -52,9 +54,10 @@ impl InputWindow {
|
|||||||
.with_title("Bind Inputs")
|
.with_title("Bind Inputs")
|
||||||
.with_inner_size(LogicalSize::new(600, 400))
|
.with_inner_size(LogicalSize::new(600, 400))
|
||||||
.build();
|
.build();
|
||||||
|
let imgui = ImguiState::new(&window);
|
||||||
Self {
|
Self {
|
||||||
window,
|
window,
|
||||||
imgui: None,
|
imgui,
|
||||||
input_mapper,
|
input_mapper,
|
||||||
now_binding: None,
|
now_binding: None,
|
||||||
proxy,
|
proxy,
|
||||||
@@ -63,7 +66,7 @@ impl InputWindow {
|
|||||||
|
|
||||||
fn draw(&mut self) {
|
fn draw(&mut self) {
|
||||||
let window = &mut self.window;
|
let window = &mut self.window;
|
||||||
let imgui = self.imgui.as_mut().unwrap();
|
let imgui = &mut self.imgui;
|
||||||
let mut context = imgui.context.lock().unwrap();
|
let mut context = imgui.context.lock().unwrap();
|
||||||
|
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
@@ -85,11 +88,11 @@ impl InputWindow {
|
|||||||
.expect("Failed to prepare frame");
|
.expect("Failed to prepare frame");
|
||||||
let ui = context.new_frame();
|
let ui = context.new_frame();
|
||||||
|
|
||||||
let mut render_key_bindings = || {
|
let mut render_key_bindings = |sim_id: SimId| {
|
||||||
if let Some(table) = ui.begin_table("controls", 2) {
|
if let Some(table) = ui.begin_table("controls", 2) {
|
||||||
let binding_names = {
|
let binding_names = {
|
||||||
let mapper = self.input_mapper.read().unwrap();
|
let mapper = self.input_mapper.read().unwrap();
|
||||||
mapper.binding_names()
|
mapper.binding_names(&sim_id)
|
||||||
};
|
};
|
||||||
ui.table_next_row();
|
ui.table_next_row();
|
||||||
|
|
||||||
@@ -100,20 +103,20 @@ impl InputWindow {
|
|||||||
ui.group(|| {
|
ui.group(|| {
|
||||||
ui.right_align_text(name, space * 0.20);
|
ui.right_align_text(name, space * 0.20);
|
||||||
ui.same_line();
|
ui.same_line();
|
||||||
let label_text = if self.now_binding == Some(key) {
|
let label_text = if self.now_binding == Some((sim_id, key)) {
|
||||||
"Press any input"
|
"Press any input"
|
||||||
} else {
|
} else {
|
||||||
binding.unwrap_or("")
|
binding.unwrap_or("")
|
||||||
};
|
};
|
||||||
let label = format!("{}##{}", label_text, name);
|
let label = format!("{}##{}", label_text, name);
|
||||||
if ui.button_with_size(label, [space * 0.60, 0.0]) {
|
if ui.button_with_size(label, [space * 0.60, 0.0]) {
|
||||||
self.now_binding = Some(key);
|
self.now_binding = Some((sim_id, key));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
ui.same_line();
|
ui.same_line();
|
||||||
if ui.button(format!("Clear##{name}")) {
|
if ui.button(format!("Clear##{name}")) {
|
||||||
let mut mapper = self.input_mapper.write().unwrap();
|
let mut mapper = self.input_mapper.write().unwrap();
|
||||||
mapper.clear_binding(key);
|
mapper.clear_binding(sim_id, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -124,7 +127,11 @@ impl InputWindow {
|
|||||||
if let Some(window) = ui.fullscreen_window() {
|
if let Some(window) = ui.fullscreen_window() {
|
||||||
if let Some(tabs) = ui.tab_bar("tabs") {
|
if let Some(tabs) = ui.tab_bar("tabs") {
|
||||||
if let Some(tab) = ui.tab_item("Player 1") {
|
if let Some(tab) = ui.tab_item("Player 1") {
|
||||||
render_key_bindings();
|
render_key_bindings(SimId::Player1);
|
||||||
|
tab.end();
|
||||||
|
}
|
||||||
|
if let Some(tab) = ui.tab_item("Player 2") {
|
||||||
|
render_key_bindings(SimId::Player2);
|
||||||
tab.end();
|
tab.end();
|
||||||
}
|
}
|
||||||
tabs.end();
|
tabs.end();
|
||||||
@@ -175,11 +182,11 @@ impl InputWindow {
|
|||||||
if !event.state.is_pressed() {
|
if !event.state.is_pressed() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let Some(vb) = self.now_binding.take() else {
|
let Some((sim_id, vb)) = self.now_binding.take() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let mut mapper = self.input_mapper.write().unwrap();
|
let mut mapper = self.input_mapper.write().unwrap();
|
||||||
mapper.bind_key(vb, event.key_without_modifiers());
|
mapper.bind_key(sim_id, vb, event.physical_key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,19 +195,13 @@ impl AppWindow for InputWindow {
|
|||||||
self.window.window.id()
|
self.window.window.id()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn init(&mut self) {
|
|
||||||
self.imgui = Some(ImguiState::new(&self.window));
|
|
||||||
self.window.window.request_redraw();
|
|
||||||
}
|
|
||||||
|
|
||||||
fn handle_event(&mut self, _: &ActiveEventLoop, event: &Event<UserEvent>) {
|
fn handle_event(&mut self, _: &ActiveEventLoop, event: &Event<UserEvent>) {
|
||||||
match event {
|
match event {
|
||||||
Event::WindowEvent { event, .. } => match event {
|
Event::WindowEvent { event, .. } => match event {
|
||||||
WindowEvent::Resized(size) => self.window.handle_resize(size),
|
WindowEvent::Resized(size) => self.window.handle_resize(size),
|
||||||
WindowEvent::CloseRequested => self
|
WindowEvent::CloseRequested => {
|
||||||
.proxy
|
self.proxy.send_event(UserEvent::Close(self.id())).unwrap()
|
||||||
.send_event(UserEvent::CloseWindow(self.id()))
|
}
|
||||||
.unwrap(),
|
|
||||||
WindowEvent::KeyboardInput { event, .. } => self.try_bind_key(event),
|
WindowEvent::KeyboardInput { event, .. } => self.try_bind_key(event),
|
||||||
WindowEvent::RedrawRequested => self.draw(),
|
WindowEvent::RedrawRequested => self.draw(),
|
||||||
_ => (),
|
_ => (),
|
||||||
@@ -212,9 +213,7 @@ impl AppWindow for InputWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let window = &self.window;
|
let window = &self.window;
|
||||||
let Some(imgui) = self.imgui.as_mut() else {
|
let imgui = &mut self.imgui;
|
||||||
return;
|
|
||||||
};
|
|
||||||
let mut context = imgui.context.lock().unwrap();
|
let mut context = imgui.context.lock().unwrap();
|
||||||
imgui
|
imgui
|
||||||
.platform
|
.platform
|
||||||
|
|||||||
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
@@ -95,7 +97,7 @@ impl Audio {
|
|||||||
}
|
}
|
||||||
|
|
||||||
while self.sample_sink.slots() < self.sampler.output_frames_max() * 2 {
|
while self.sample_sink.slots() < self.sampler.output_frames_max() * 2 {
|
||||||
std::hint::spin_loop();
|
std::thread::sleep(Duration::from_micros(500));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+18
-20
@@ -2,48 +2,46 @@ use std::sync::{Arc, RwLock};
|
|||||||
|
|
||||||
use winit::event::{ElementState, KeyEvent};
|
use winit::event::{ElementState, KeyEvent};
|
||||||
|
|
||||||
use crate::{input::InputMapper, shrooms_vb_core::VBKey};
|
use crate::{
|
||||||
|
emulator::{SimId, VBKey},
|
||||||
|
input::InputMapper,
|
||||||
|
};
|
||||||
|
|
||||||
pub struct ControllerState {
|
pub struct ControllerState {
|
||||||
input_mapper: Arc<RwLock<InputMapper>>,
|
input_mapper: Arc<RwLock<InputMapper>>,
|
||||||
pressed: VBKey,
|
pressed: Vec<VBKey>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ControllerState {
|
impl ControllerState {
|
||||||
pub fn new(input_mapper: Arc<RwLock<InputMapper>>) -> Self {
|
pub fn new(input_mapper: Arc<RwLock<InputMapper>>) -> Self {
|
||||||
Self {
|
Self {
|
||||||
input_mapper,
|
input_mapper,
|
||||||
pressed: VBKey::SGN,
|
pressed: vec![VBKey::SGN; 2],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pressed(&self) -> VBKey {
|
pub fn key_event(&mut self, event: &KeyEvent) -> Option<(SimId, VBKey)> {
|
||||||
self.pressed
|
let (sim_id, input) = self.key_event_to_input(event)?;
|
||||||
}
|
let pressed = &mut self.pressed[sim_id.to_index()];
|
||||||
|
|
||||||
pub fn key_event(&mut self, event: &KeyEvent) -> bool {
|
|
||||||
let Some(input) = self.key_event_to_input(event) else {
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
match event.state {
|
match event.state {
|
||||||
ElementState::Pressed => {
|
ElementState::Pressed => {
|
||||||
if self.pressed.contains(input) {
|
if pressed.contains(input) {
|
||||||
return false;
|
return None;
|
||||||
}
|
}
|
||||||
self.pressed.insert(input);
|
pressed.insert(input);
|
||||||
true
|
Some((sim_id, *pressed))
|
||||||
}
|
}
|
||||||
ElementState::Released => {
|
ElementState::Released => {
|
||||||
if !self.pressed.contains(input) {
|
if !pressed.contains(input) {
|
||||||
return false;
|
return None;
|
||||||
}
|
}
|
||||||
self.pressed.remove(input);
|
pressed.remove(input);
|
||||||
true
|
Some((sim_id, *pressed))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn key_event_to_input(&self, event: &KeyEvent) -> Option<VBKey> {
|
fn key_event_to_input(&self, event: &KeyEvent) -> Option<(SimId, VBKey)> {
|
||||||
let mapper = self.input_mapper.read().unwrap();
|
let mapper = self.input_mapper.read().unwrap();
|
||||||
mapper.key_event(event)
|
mapper.key_event(event)
|
||||||
}
|
}
|
||||||
|
|||||||
+101
-28
@@ -1,4 +1,5 @@
|
|||||||
use std::{
|
use std::{
|
||||||
|
collections::HashMap,
|
||||||
fs,
|
fs,
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
sync::{
|
sync::{
|
||||||
@@ -10,11 +11,11 @@ use std::{
|
|||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
||||||
use crate::{
|
use crate::{audio::Audio, graphics::TextureSink};
|
||||||
audio::Audio,
|
use shrooms_vb_core::Sim;
|
||||||
renderer::GameRenderer,
|
pub use shrooms_vb_core::VBKey;
|
||||||
shrooms_vb_core::{CoreVB, VBKey},
|
|
||||||
};
|
mod shrooms_vb_core;
|
||||||
|
|
||||||
pub struct EmulatorBuilder {
|
pub struct EmulatorBuilder {
|
||||||
rom: Option<PathBuf>,
|
rom: Option<PathBuf>,
|
||||||
@@ -23,6 +24,23 @@ pub struct EmulatorBuilder {
|
|||||||
has_game: Arc<AtomicBool>,
|
has_game: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
||||||
|
pub enum SimId {
|
||||||
|
Player1,
|
||||||
|
Player2,
|
||||||
|
}
|
||||||
|
impl SimId {
|
||||||
|
pub const fn values() -> [Self; 2] {
|
||||||
|
[Self::Player1, Self::Player2]
|
||||||
|
}
|
||||||
|
pub const fn to_index(self) -> usize {
|
||||||
|
match self {
|
||||||
|
Self::Player1 => 0,
|
||||||
|
Self::Player2 => 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl EmulatorBuilder {
|
impl EmulatorBuilder {
|
||||||
pub fn new() -> (Self, EmulatorClient) {
|
pub fn new() -> (Self, EmulatorClient) {
|
||||||
let (queue, commands) = mpsc::channel();
|
let (queue, commands) = mpsc::channel();
|
||||||
@@ -50,17 +68,17 @@ impl EmulatorBuilder {
|
|||||||
pub fn build(self) -> Result<Emulator> {
|
pub fn build(self) -> Result<Emulator> {
|
||||||
let mut emulator = Emulator::new(self.commands, self.running, self.has_game)?;
|
let mut emulator = Emulator::new(self.commands, self.running, self.has_game)?;
|
||||||
if let Some(path) = self.rom {
|
if let Some(path) = self.rom {
|
||||||
emulator.load_rom(&path)?;
|
emulator.load_rom_from_file(SimId::Player1, &path)?;
|
||||||
}
|
}
|
||||||
Ok(emulator)
|
Ok(emulator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Emulator {
|
pub struct Emulator {
|
||||||
sim: CoreVB,
|
sims: Vec<Sim>,
|
||||||
audio: Audio,
|
audio: Audio,
|
||||||
commands: mpsc::Receiver<EmulatorCommand>,
|
commands: mpsc::Receiver<EmulatorCommand>,
|
||||||
renderer: Option<GameRenderer>,
|
renderers: HashMap<SimId, TextureSink>,
|
||||||
running: Arc<AtomicBool>,
|
running: Arc<AtomicBool>,
|
||||||
has_game: Arc<AtomicBool>,
|
has_game: Arc<AtomicBool>,
|
||||||
}
|
}
|
||||||
@@ -72,24 +90,52 @@ impl Emulator {
|
|||||||
has_game: Arc<AtomicBool>,
|
has_game: Arc<AtomicBool>,
|
||||||
) -> Result<Self> {
|
) -> Result<Self> {
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
sim: CoreVB::new(),
|
sims: vec![],
|
||||||
audio: Audio::init()?,
|
audio: Audio::init()?,
|
||||||
commands,
|
commands,
|
||||||
renderer: None,
|
renderers: HashMap::new(),
|
||||||
running,
|
running,
|
||||||
has_game,
|
has_game,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_rom(&mut self, path: &Path) -> Result<()> {
|
pub fn load_rom_from_file(&mut self, sim_id: SimId, path: &Path) -> Result<()> {
|
||||||
let bytes = fs::read(path)?;
|
let bytes = fs::read(path)?;
|
||||||
self.sim.reset();
|
self.load_rom(sim_id, bytes)?;
|
||||||
self.sim.load_rom(bytes)?;
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn start_second_sim(&mut self, rom: Option<PathBuf>) -> Result<()> {
|
||||||
|
let bytes = if let Some(path) = rom {
|
||||||
|
fs::read(path)?
|
||||||
|
} else if let Some(rom) = self.sims.first().and_then(|s| s.clone_rom()) {
|
||||||
|
rom
|
||||||
|
} else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
self.load_rom(SimId::Player2, bytes)?;
|
||||||
|
let (first, second) = self.sims.split_at_mut(1);
|
||||||
|
first[0].link(&mut second[0]);
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn load_rom(&mut self, sim_id: SimId, bytes: Vec<u8>) -> Result<()> {
|
||||||
|
while self.sims.len() <= sim_id.to_index() {
|
||||||
|
self.sims.push(Sim::new());
|
||||||
|
}
|
||||||
|
let sim = &mut self.sims[sim_id.to_index()];
|
||||||
|
sim.reset();
|
||||||
|
sim.load_rom(bytes)?;
|
||||||
self.has_game.store(true, Ordering::Release);
|
self.has_game.store(true, Ordering::Release);
|
||||||
self.running.store(true, Ordering::Release);
|
self.running.store(true, Ordering::Release);
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn stop_second_sim(&mut self) {
|
||||||
|
self.renderers.remove(&SimId::Player2);
|
||||||
|
self.sims.truncate(1);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn run(&mut self) {
|
pub fn run(&mut self) {
|
||||||
let mut eye_contents = vec![0u8; 384 * 224 * 2];
|
let mut eye_contents = vec![0u8; 384 * 224 * 2];
|
||||||
let mut audio_samples = vec![];
|
let mut audio_samples = vec![];
|
||||||
@@ -97,15 +143,26 @@ impl Emulator {
|
|||||||
let mut idle = true;
|
let mut idle = true;
|
||||||
if self.running.load(Ordering::Acquire) {
|
if self.running.load(Ordering::Acquire) {
|
||||||
idle = false;
|
idle = false;
|
||||||
self.sim.emulate_frame();
|
Sim::emulate_many(&mut self.sims);
|
||||||
}
|
}
|
||||||
if let Some(renderer) = &mut self.renderer {
|
for sim_id in SimId::values() {
|
||||||
if self.sim.read_pixels(&mut eye_contents) {
|
let Some(renderer) = self.renderers.get_mut(&sim_id) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
let Some(sim) = self.sims.get_mut(sim_id.to_index()) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
if sim.read_pixels(&mut eye_contents) {
|
||||||
idle = false;
|
idle = false;
|
||||||
renderer.render(&eye_contents);
|
if renderer.queue_render(&eye_contents).is_err() {
|
||||||
|
self.renderers.remove(&sim_id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.sim.read_samples(&mut audio_samples);
|
}
|
||||||
|
let weight = 1.0 / self.sims.len() as f32;
|
||||||
|
for sim in self.sims.iter_mut() {
|
||||||
|
sim.read_samples(&mut audio_samples, weight);
|
||||||
|
}
|
||||||
if !audio_samples.is_empty() {
|
if !audio_samples.is_empty() {
|
||||||
idle = false;
|
idle = false;
|
||||||
self.audio.update(&audio_samples);
|
self.audio.update(&audio_samples);
|
||||||
@@ -137,14 +194,22 @@ impl Emulator {
|
|||||||
|
|
||||||
fn handle_command(&mut self, command: EmulatorCommand) {
|
fn handle_command(&mut self, command: EmulatorCommand) {
|
||||||
match command {
|
match command {
|
||||||
EmulatorCommand::SetRenderer(renderer) => {
|
EmulatorCommand::SetRenderer(sim_id, renderer) => {
|
||||||
self.renderer = Some(renderer);
|
self.renderers.insert(sim_id, renderer);
|
||||||
}
|
}
|
||||||
EmulatorCommand::LoadGame(path) => {
|
EmulatorCommand::LoadGame(sim_id, path) => {
|
||||||
if let Err(error) = self.load_rom(&path) {
|
if let Err(error) = self.load_rom_from_file(sim_id, &path) {
|
||||||
eprintln!("error loading rom: {}", error);
|
eprintln!("error loading rom: {}", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
EmulatorCommand::StartSecondSim(path) => {
|
||||||
|
if let Err(error) = self.start_second_sim(path) {
|
||||||
|
eprintln!("error starting second sim: {}", error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EmulatorCommand::StopSecondSim => {
|
||||||
|
self.stop_second_sim();
|
||||||
|
}
|
||||||
EmulatorCommand::Pause => {
|
EmulatorCommand::Pause => {
|
||||||
self.running.store(false, Ordering::Release);
|
self.running.store(false, Ordering::Release);
|
||||||
}
|
}
|
||||||
@@ -154,11 +219,17 @@ impl Emulator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
EmulatorCommand::Reset => {
|
EmulatorCommand::Reset => {
|
||||||
self.sim.reset();
|
for sim in self.sims.iter_mut() {
|
||||||
|
sim.reset();
|
||||||
|
}
|
||||||
|
if !self.sims.is_empty() {
|
||||||
self.running.store(true, Ordering::Release);
|
self.running.store(true, Ordering::Release);
|
||||||
}
|
}
|
||||||
EmulatorCommand::SetKeys(keys) => {
|
}
|
||||||
self.sim.set_keys(keys);
|
EmulatorCommand::SetKeys(sim_id, keys) => {
|
||||||
|
if let Some(sim) = self.sims.get_mut(sim_id.to_index()) {
|
||||||
|
sim.set_keys(keys);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,12 +237,14 @@ impl Emulator {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum EmulatorCommand {
|
pub enum EmulatorCommand {
|
||||||
SetRenderer(GameRenderer),
|
SetRenderer(SimId, TextureSink),
|
||||||
LoadGame(PathBuf),
|
LoadGame(SimId, PathBuf),
|
||||||
|
StartSecondSim(Option<PathBuf>),
|
||||||
|
StopSecondSim,
|
||||||
Pause,
|
Pause,
|
||||||
Resume,
|
Resume,
|
||||||
Reset,
|
Reset,
|
||||||
SetKeys(VBKey),
|
SetKeys(SimId, VBKey),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ enum VBDataType {
|
|||||||
F32 = 5,
|
F32 = 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[repr(i32)]
|
||||||
|
#[derive(FromPrimitive, ToPrimitive)]
|
||||||
|
enum VBOption {
|
||||||
|
PseudoHalt = 0,
|
||||||
|
}
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||||
@@ -52,10 +58,12 @@ type OnFrame = extern "C" fn(sim: *mut VB) -> c_int;
|
|||||||
|
|
||||||
#[link(name = "vb")]
|
#[link(name = "vb")]
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#[link_name = "vbEmulate"]
|
#[link_name = "vbEmulateEx"]
|
||||||
fn vb_emulate(sim: *mut VB, cycles: *mut u32) -> c_int;
|
fn vb_emulate_ex(sims: *mut *mut VB, count: c_uint, cycles: *mut u32) -> c_int;
|
||||||
#[link_name = "vbGetCartROM"]
|
#[link_name = "vbGetCartROM"]
|
||||||
fn vb_get_cart_rom(sim: *mut VB, size: *mut u32) -> *mut c_void;
|
fn vb_get_cart_rom(sim: *mut VB, size: *mut u32) -> *mut c_void;
|
||||||
|
#[link_name = "vbGetPeer"]
|
||||||
|
fn vb_get_peer(sim: *mut VB) -> *mut VB;
|
||||||
#[link_name = "vbGetPixels"]
|
#[link_name = "vbGetPixels"]
|
||||||
fn vb_get_pixels(
|
fn vb_get_pixels(
|
||||||
sim: *mut VB,
|
sim: *mut VB,
|
||||||
@@ -81,10 +89,14 @@ extern "C" {
|
|||||||
fn vb_reset(sim: *mut VB);
|
fn vb_reset(sim: *mut VB);
|
||||||
#[link_name = "vbSetCartROM"]
|
#[link_name = "vbSetCartROM"]
|
||||||
fn vb_set_cart_rom(sim: *mut VB, rom: *mut c_void, size: u32) -> c_int;
|
fn vb_set_cart_rom(sim: *mut VB, rom: *mut c_void, size: u32) -> c_int;
|
||||||
#[link_name = "vbSetKeys"]
|
|
||||||
fn vb_set_keys(sim: *mut VB, keys: u16) -> u16;
|
|
||||||
#[link_name = "vbSetFrameCallback"]
|
#[link_name = "vbSetFrameCallback"]
|
||||||
fn vb_set_frame_callback(sim: *mut VB, on_frame: OnFrame);
|
fn vb_set_frame_callback(sim: *mut VB, on_frame: OnFrame);
|
||||||
|
#[link_name = "vbSetKeys"]
|
||||||
|
fn vb_set_keys(sim: *mut VB, keys: u16) -> u16;
|
||||||
|
#[link_name = "vbSetOption"]
|
||||||
|
fn vb_set_option(sim: *mut VB, key: VBOption, value: c_int);
|
||||||
|
#[link_name = "vbSetPeer"]
|
||||||
|
fn vb_set_peer(sim: *mut VB, peer: *mut VB);
|
||||||
#[link_name = "vbSetSamples"]
|
#[link_name = "vbSetSamples"]
|
||||||
fn vb_set_samples(
|
fn vb_set_samples(
|
||||||
sim: *mut VB,
|
sim: *mut VB,
|
||||||
@@ -113,14 +125,15 @@ struct VBState {
|
|||||||
frame_seen: bool,
|
frame_seen: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct CoreVB {
|
#[repr(transparent)]
|
||||||
|
pub struct Sim {
|
||||||
sim: *mut VB,
|
sim: *mut VB,
|
||||||
}
|
}
|
||||||
|
|
||||||
// SAFETY: the memory pointed to by sim is valid
|
// SAFETY: the memory pointed to by sim is valid
|
||||||
unsafe impl Send for CoreVB {}
|
unsafe impl Send for Sim {}
|
||||||
|
|
||||||
impl CoreVB {
|
impl Sim {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
// init the VB instance itself
|
// init the VB instance itself
|
||||||
let size = unsafe { vb_size_of() };
|
let size = unsafe { vb_size_of() };
|
||||||
@@ -128,6 +141,7 @@ impl CoreVB {
|
|||||||
let memory = vec![0u64; size.div_ceil(4)];
|
let memory = vec![0u64; size.div_ceil(4)];
|
||||||
let sim: *mut VB = Box::into_raw(memory.into_boxed_slice()).cast();
|
let sim: *mut VB = Box::into_raw(memory.into_boxed_slice()).cast();
|
||||||
unsafe { vb_init(sim) };
|
unsafe { vb_init(sim) };
|
||||||
|
unsafe { vb_set_option(sim, VBOption::PseudoHalt, 1) };
|
||||||
unsafe { vb_reset(sim) };
|
unsafe { vb_reset(sim) };
|
||||||
|
|
||||||
// set up userdata
|
// set up userdata
|
||||||
@@ -140,7 +154,7 @@ impl CoreVB {
|
|||||||
let samples: *mut c_void = Box::into_raw(audio_buffer.into_boxed_slice()).cast();
|
let samples: *mut c_void = Box::into_raw(audio_buffer.into_boxed_slice()).cast();
|
||||||
unsafe { vb_set_samples(sim, samples, VBDataType::F32, AUDIO_CAPACITY_SAMPLES as u32) };
|
unsafe { vb_set_samples(sim, samples, VBDataType::F32, AUDIO_CAPACITY_SAMPLES as u32) };
|
||||||
|
|
||||||
CoreVB { sim }
|
Sim { sim }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn reset(&mut self) {
|
pub fn reset(&mut self) {
|
||||||
@@ -162,6 +176,17 @@ impl CoreVB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn clone_rom(&self) -> Option<Vec<u8>> {
|
||||||
|
let mut size = 0;
|
||||||
|
let rom = unsafe { vb_get_cart_rom(self.sim, &mut size) };
|
||||||
|
if rom.is_null() {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
// SAFETY: rom definitely points to a valid array of `size` bytes
|
||||||
|
let slice: &[u8] = unsafe { slice::from_raw_parts(rom.cast(), size as usize) };
|
||||||
|
Some(slice.to_vec())
|
||||||
|
}
|
||||||
|
|
||||||
fn unload_rom(&mut self) -> Option<Vec<u8>> {
|
fn unload_rom(&mut self) -> Option<Vec<u8>> {
|
||||||
let mut size = 0;
|
let mut size = 0;
|
||||||
let rom = unsafe { vb_get_cart_rom(self.sim, &mut size) };
|
let rom = unsafe { vb_get_cart_rom(self.sim, &mut size) };
|
||||||
@@ -173,9 +198,15 @@ impl CoreVB {
|
|||||||
Some(vec)
|
Some(vec)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn emulate_frame(&mut self) {
|
pub fn link(&mut self, peer: &mut Sim) {
|
||||||
|
unsafe { vb_set_peer(self.sim, peer.sim) };
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn emulate_many(sims: &mut [Sim]) {
|
||||||
let mut cycles = 20_000_000;
|
let mut cycles = 20_000_000;
|
||||||
unsafe { vb_emulate(self.sim, &mut cycles) };
|
let count = sims.len() as c_uint;
|
||||||
|
let sims = sims.as_mut_ptr().cast();
|
||||||
|
unsafe { vb_emulate_ex(sims, count, &mut cycles) };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_pixels(&mut self, buffers: &mut [u8]) -> bool {
|
pub fn read_pixels(&mut self, buffers: &mut [u8]) -> bool {
|
||||||
@@ -203,14 +234,17 @@ impl CoreVB {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn read_samples(&mut self, samples: &mut Vec<f32>) {
|
pub fn read_samples(&mut self, samples: &mut Vec<f32>, weight: f32) {
|
||||||
let mut position = 0;
|
let mut position = 0;
|
||||||
let ptr =
|
let ptr =
|
||||||
unsafe { vb_get_samples(self.sim, ptr::null_mut(), ptr::null_mut(), &mut position) };
|
unsafe { vb_get_samples(self.sim, ptr::null_mut(), ptr::null_mut(), &mut position) };
|
||||||
// SAFETY: position is an offset in a buffer of (f32, f32). so, position * 2 is an offset in a buffer of f32.
|
// SAFETY: position is an offset in a buffer of (f32, f32). so, position * 2 is an offset in a buffer of f32.
|
||||||
let read_samples: &mut [f32] =
|
let read_samples: &[f32] =
|
||||||
unsafe { slice::from_raw_parts_mut(ptr.cast(), position as usize * 2) };
|
unsafe { slice::from_raw_parts(ptr.cast(), position as usize * 2) };
|
||||||
samples.extend_from_slice(read_samples);
|
samples.resize(read_samples.len(), 0.0);
|
||||||
|
for (index, sample) in read_samples.iter().enumerate() {
|
||||||
|
samples[index] += sample * weight;
|
||||||
|
}
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
vb_set_samples(
|
vb_set_samples(
|
||||||
@@ -227,7 +261,7 @@ impl CoreVB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Drop for CoreVB {
|
impl Drop for Sim {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let ptr =
|
let ptr =
|
||||||
unsafe { vb_get_samples(self.sim, ptr::null_mut(), ptr::null_mut(), ptr::null_mut()) };
|
unsafe { vb_get_samples(self.sim, ptr::null_mut(), ptr::null_mut(), ptr::null_mut()) };
|
||||||
@@ -243,6 +277,12 @@ impl Drop for CoreVB {
|
|||||||
// SAFETY: we made this pointer ourselves, we can for sure free it
|
// SAFETY: we made this pointer ourselves, we can for sure free it
|
||||||
unsafe { drop(Box::from_raw(ptr)) };
|
unsafe { drop(Box::from_raw(ptr)) };
|
||||||
|
|
||||||
|
// If we're linked to another sim, unlink them from ourselves.
|
||||||
|
let peer = unsafe { vb_get_peer(self.sim) };
|
||||||
|
if !peer.is_null() {
|
||||||
|
unsafe { vb_set_peer(peer, ptr::null_mut()) };
|
||||||
|
}
|
||||||
|
|
||||||
let len = unsafe { vb_size_of() }.div_ceil(4);
|
let len = unsafe { vb_size_of() }.div_ceil(4);
|
||||||
// SAFETY: the sim's memory originally came from a Vec<u64>
|
// SAFETY: the sim's memory originally came from a Vec<u64>
|
||||||
let bytes: Vec<u64> = unsafe { Vec::from_raw_parts(self.sim.cast(), len, len) };
|
let bytes: Vec<u64> = unsafe { Vec::from_raw_parts(self.sim.cast(), len, len) };
|
||||||
+143
@@ -0,0 +1,143 @@
|
|||||||
|
use std::{
|
||||||
|
sync::{
|
||||||
|
atomic::{AtomicU64, Ordering},
|
||||||
|
mpsc, Arc, Mutex, MutexGuard,
|
||||||
|
},
|
||||||
|
thread,
|
||||||
|
};
|
||||||
|
|
||||||
|
use anyhow::{bail, Result};
|
||||||
|
use itertools::Itertools as _;
|
||||||
|
use wgpu::{
|
||||||
|
Device, Extent3d, ImageCopyTexture, ImageDataLayout, Origin3d, Queue, Texture,
|
||||||
|
TextureDescriptor, TextureFormat, TextureUsages, TextureView, TextureViewDescriptor,
|
||||||
|
};
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct TextureSink {
|
||||||
|
buffers: Arc<BufferPool>,
|
||||||
|
sink: mpsc::Sender<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TextureSink {
|
||||||
|
pub fn new(device: &Device, queue: Arc<Queue>) -> (Self, TextureView) {
|
||||||
|
let texture = Self::create_texture(device);
|
||||||
|
let view = texture.create_view(&TextureViewDescriptor::default());
|
||||||
|
let buffers = Arc::new(BufferPool::new());
|
||||||
|
let (sink, source) = mpsc::channel();
|
||||||
|
let bufs = buffers.clone();
|
||||||
|
thread::spawn(move || {
|
||||||
|
let mut local_buf = vec![0; 384 * 224 * 2];
|
||||||
|
while let Ok(id) = source.recv() {
|
||||||
|
{
|
||||||
|
let Some(bytes) = bufs.read(id) else {
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
local_buf.copy_from_slice(bytes.as_slice());
|
||||||
|
}
|
||||||
|
Self::write_texture(&queue, &texture, local_buf.as_slice());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
let sink = Self { buffers, sink };
|
||||||
|
(sink, view)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn queue_render(&mut self, bytes: &[u8]) -> Result<()> {
|
||||||
|
let id = {
|
||||||
|
let (mut buf, id) = self.buffers.write()?;
|
||||||
|
buf.copy_from_slice(bytes);
|
||||||
|
id
|
||||||
|
};
|
||||||
|
self.sink.send(id)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn create_texture(device: &Device) -> Texture {
|
||||||
|
let desc = TextureDescriptor {
|
||||||
|
label: Some("eyes"),
|
||||||
|
size: Extent3d {
|
||||||
|
width: 384,
|
||||||
|
height: 224,
|
||||||
|
depth_or_array_layers: 1,
|
||||||
|
},
|
||||||
|
mip_level_count: 1,
|
||||||
|
sample_count: 1,
|
||||||
|
dimension: wgpu::TextureDimension::D2,
|
||||||
|
format: TextureFormat::Rg8Unorm,
|
||||||
|
usage: TextureUsages::COPY_SRC
|
||||||
|
| TextureUsages::COPY_DST
|
||||||
|
| TextureUsages::TEXTURE_BINDING,
|
||||||
|
view_formats: &[TextureFormat::Rg8Unorm],
|
||||||
|
};
|
||||||
|
device.create_texture(&desc)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write_texture(queue: &Queue, texture: &Texture, bytes: &[u8]) {
|
||||||
|
let texture = ImageCopyTexture {
|
||||||
|
texture,
|
||||||
|
mip_level: 0,
|
||||||
|
origin: Origin3d::ZERO,
|
||||||
|
aspect: wgpu::TextureAspect::All,
|
||||||
|
};
|
||||||
|
let size = Extent3d {
|
||||||
|
width: 384,
|
||||||
|
height: 224,
|
||||||
|
depth_or_array_layers: 1,
|
||||||
|
};
|
||||||
|
let data_layout = ImageDataLayout {
|
||||||
|
offset: 0,
|
||||||
|
bytes_per_row: Some(384 * 2),
|
||||||
|
rows_per_image: Some(224),
|
||||||
|
};
|
||||||
|
queue.write_texture(texture, bytes, data_layout, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct BufferPool {
|
||||||
|
buffers: [Buffer; 3],
|
||||||
|
}
|
||||||
|
impl BufferPool {
|
||||||
|
fn new() -> Self {
|
||||||
|
Self {
|
||||||
|
buffers: std::array::from_fn(|i| Buffer::new(i as u64)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn read(&self, id: u64) -> Option<MutexGuard<'_, Vec<u8>>> {
|
||||||
|
let buf = self
|
||||||
|
.buffers
|
||||||
|
.iter()
|
||||||
|
.find(|buf| buf.id.load(Ordering::Acquire) == id)?;
|
||||||
|
buf.data.lock().ok()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn write(&self) -> Result<(MutexGuard<'_, Vec<u8>>, u64)> {
|
||||||
|
let (min, max) = self
|
||||||
|
.buffers
|
||||||
|
.iter()
|
||||||
|
.minmax_by_key(|buf| buf.id.load(Ordering::Acquire))
|
||||||
|
.into_option()
|
||||||
|
.unwrap();
|
||||||
|
let Ok(lock) = min.data.lock() else {
|
||||||
|
bail!("lock was poisoned")
|
||||||
|
};
|
||||||
|
let id = max.id.load(Ordering::Acquire) + 1;
|
||||||
|
min.id.store(id, Ordering::Release);
|
||||||
|
Ok((lock, id))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug)]
|
||||||
|
struct Buffer {
|
||||||
|
data: Mutex<Vec<u8>>,
|
||||||
|
id: AtomicU64,
|
||||||
|
}
|
||||||
|
impl Buffer {
|
||||||
|
fn new(id: u64) -> Self {
|
||||||
|
Self {
|
||||||
|
data: Mutex::new(vec![0; 384 * 224 * 2]),
|
||||||
|
id: AtomicU64::new(id),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
-32
@@ -2,15 +2,14 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use winit::{
|
use winit::{
|
||||||
event::KeyEvent,
|
event::KeyEvent,
|
||||||
keyboard::{Key, NamedKey},
|
keyboard::{KeyCode, PhysicalKey},
|
||||||
platform::modifier_supplement::KeyEventExtModifierSupplement,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::shrooms_vb_core::VBKey;
|
use crate::emulator::{SimId, VBKey};
|
||||||
|
|
||||||
pub struct InputMapper {
|
pub struct InputMapper {
|
||||||
vb_bindings: HashMap<VBKey, Key>,
|
vb_bindings: HashMap<SimId, HashMap<VBKey, PhysicalKey>>,
|
||||||
key_bindings: HashMap<Key, VBKey>,
|
key_bindings: HashMap<PhysicalKey, (SimId, VBKey)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl InputMapper {
|
impl InputMapper {
|
||||||
@@ -19,30 +18,48 @@ impl InputMapper {
|
|||||||
vb_bindings: HashMap::new(),
|
vb_bindings: HashMap::new(),
|
||||||
key_bindings: HashMap::new(),
|
key_bindings: HashMap::new(),
|
||||||
};
|
};
|
||||||
mapper.bind_key(VBKey::SEL, Key::Character("a".into()));
|
mapper.bind_key(SimId::Player1, VBKey::SEL, PhysicalKey::Code(KeyCode::KeyA));
|
||||||
mapper.bind_key(VBKey::STA, Key::Character("s".into()));
|
mapper.bind_key(SimId::Player1, VBKey::STA, PhysicalKey::Code(KeyCode::KeyS));
|
||||||
mapper.bind_key(VBKey::B, Key::Character("d".into()));
|
mapper.bind_key(SimId::Player1, VBKey::B, PhysicalKey::Code(KeyCode::KeyD));
|
||||||
mapper.bind_key(VBKey::A, Key::Character("f".into()));
|
mapper.bind_key(SimId::Player1, VBKey::A, PhysicalKey::Code(KeyCode::KeyF));
|
||||||
mapper.bind_key(VBKey::LT, Key::Character("e".into()));
|
mapper.bind_key(SimId::Player1, VBKey::LT, PhysicalKey::Code(KeyCode::KeyE));
|
||||||
mapper.bind_key(VBKey::RT, Key::Character("r".into()));
|
mapper.bind_key(SimId::Player1, VBKey::RT, PhysicalKey::Code(KeyCode::KeyR));
|
||||||
mapper.bind_key(VBKey::RU, Key::Character("i".into()));
|
mapper.bind_key(SimId::Player1, VBKey::RU, PhysicalKey::Code(KeyCode::KeyI));
|
||||||
mapper.bind_key(VBKey::RL, Key::Character("j".into()));
|
mapper.bind_key(SimId::Player1, VBKey::RL, PhysicalKey::Code(KeyCode::KeyJ));
|
||||||
mapper.bind_key(VBKey::RD, Key::Character("k".into()));
|
mapper.bind_key(SimId::Player1, VBKey::RD, PhysicalKey::Code(KeyCode::KeyK));
|
||||||
mapper.bind_key(VBKey::RR, Key::Character("l".into()));
|
mapper.bind_key(SimId::Player1, VBKey::RR, PhysicalKey::Code(KeyCode::KeyL));
|
||||||
mapper.bind_key(VBKey::LU, Key::Named(NamedKey::ArrowUp));
|
mapper.bind_key(
|
||||||
mapper.bind_key(VBKey::LL, Key::Named(NamedKey::ArrowLeft));
|
SimId::Player1,
|
||||||
mapper.bind_key(VBKey::LD, Key::Named(NamedKey::ArrowDown));
|
VBKey::LU,
|
||||||
mapper.bind_key(VBKey::LR, Key::Named(NamedKey::ArrowRight));
|
PhysicalKey::Code(KeyCode::ArrowUp),
|
||||||
|
);
|
||||||
|
mapper.bind_key(
|
||||||
|
SimId::Player1,
|
||||||
|
VBKey::LL,
|
||||||
|
PhysicalKey::Code(KeyCode::ArrowLeft),
|
||||||
|
);
|
||||||
|
mapper.bind_key(
|
||||||
|
SimId::Player1,
|
||||||
|
VBKey::LD,
|
||||||
|
PhysicalKey::Code(KeyCode::ArrowDown),
|
||||||
|
);
|
||||||
|
mapper.bind_key(
|
||||||
|
SimId::Player1,
|
||||||
|
VBKey::LR,
|
||||||
|
PhysicalKey::Code(KeyCode::ArrowRight),
|
||||||
|
);
|
||||||
mapper
|
mapper
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn binding_names(&self) -> HashMap<VBKey, String> {
|
pub fn binding_names(&self, sim_id: &SimId) -> HashMap<VBKey, String> {
|
||||||
self.vb_bindings
|
let Some(bindings) = self.vb_bindings.get(sim_id) else {
|
||||||
|
return HashMap::new();
|
||||||
|
};
|
||||||
|
bindings
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(k, v)| {
|
.map(|(k, v)| {
|
||||||
let name = match v {
|
let name = match v {
|
||||||
Key::Character(char) => char.to_string(),
|
PhysicalKey::Code(code) => format!("{code:?}"),
|
||||||
Key::Named(key) => format!("{:?}", key),
|
|
||||||
k => format!("{:?}", k),
|
k => format!("{:?}", k),
|
||||||
};
|
};
|
||||||
(*k, name)
|
(*k, name)
|
||||||
@@ -50,22 +67,22 @@ impl InputMapper {
|
|||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn bind_key(&mut self, vb: VBKey, key: Key) {
|
pub fn bind_key(&mut self, sim_id: SimId, vb: VBKey, key: PhysicalKey) {
|
||||||
if let Some(old) = self.vb_bindings.insert(vb, key.clone()) {
|
let vb_bindings = self.vb_bindings.entry(sim_id).or_default();
|
||||||
|
if let Some(old) = vb_bindings.insert(vb, key) {
|
||||||
self.key_bindings.remove(&old);
|
self.key_bindings.remove(&old);
|
||||||
}
|
}
|
||||||
self.key_bindings.insert(key, vb);
|
self.key_bindings.insert(key, (sim_id, vb));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn clear_binding(&mut self, vb: VBKey) {
|
pub fn clear_binding(&mut self, sim_id: SimId, vb: VBKey) {
|
||||||
if let Some(old) = self.vb_bindings.remove(&vb) {
|
let vb_bindings = self.vb_bindings.entry(sim_id).or_default();
|
||||||
|
if let Some(old) = vb_bindings.remove(&vb) {
|
||||||
self.key_bindings.remove(&old);
|
self.key_bindings.remove(&old);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn key_event(&self, event: &KeyEvent) -> Option<VBKey> {
|
pub fn key_event(&self, event: &KeyEvent) -> Option<(SimId, VBKey)> {
|
||||||
self.key_bindings
|
self.key_bindings.get(&event.physical_key).copied()
|
||||||
.get(&event.key_without_modifiers())
|
|
||||||
.cloned()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -11,9 +11,8 @@ mod app;
|
|||||||
mod audio;
|
mod audio;
|
||||||
mod controller;
|
mod controller;
|
||||||
mod emulator;
|
mod emulator;
|
||||||
|
mod graphics;
|
||||||
mod input;
|
mod input;
|
||||||
mod renderer;
|
|
||||||
mod shrooms_vb_core;
|
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
struct Args {
|
struct Args {
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
use std::sync::Arc;
|
|
||||||
|
|
||||||
use wgpu::{
|
|
||||||
Extent3d, ImageCopyTexture, ImageDataLayout, Origin3d, Queue, Texture, TextureDescriptor,
|
|
||||||
TextureFormat, TextureUsages,
|
|
||||||
};
|
|
||||||
|
|
||||||
#[derive(Debug)]
|
|
||||||
pub struct GameRenderer {
|
|
||||||
pub queue: Arc<Queue>,
|
|
||||||
pub eyes: Arc<Texture>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GameRenderer {
|
|
||||||
pub fn render(&self, buffer: &[u8]) {
|
|
||||||
let texture = ImageCopyTexture {
|
|
||||||
texture: &self.eyes,
|
|
||||||
mip_level: 0,
|
|
||||||
origin: Origin3d::ZERO,
|
|
||||||
aspect: wgpu::TextureAspect::All,
|
|
||||||
};
|
|
||||||
let size = Extent3d {
|
|
||||||
width: 384,
|
|
||||||
height: 224,
|
|
||||||
depth_or_array_layers: 1,
|
|
||||||
};
|
|
||||||
let data_layout = ImageDataLayout {
|
|
||||||
offset: 0,
|
|
||||||
bytes_per_row: Some(384 * 2),
|
|
||||||
rows_per_image: Some(224),
|
|
||||||
};
|
|
||||||
self.queue.write_texture(texture, buffer, data_layout, size);
|
|
||||||
}
|
|
||||||
pub fn create_texture(device: &wgpu::Device, name: &str) -> Texture {
|
|
||||||
let desc = TextureDescriptor {
|
|
||||||
label: Some(name),
|
|
||||||
size: Extent3d {
|
|
||||||
width: 384,
|
|
||||||
height: 224,
|
|
||||||
depth_or_array_layers: 1,
|
|
||||||
},
|
|
||||||
mip_level_count: 1,
|
|
||||||
sample_count: 1,
|
|
||||||
dimension: wgpu::TextureDimension::D2,
|
|
||||||
format: TextureFormat::Rg8Unorm,
|
|
||||||
usage: TextureUsages::COPY_SRC
|
|
||||||
| TextureUsages::COPY_DST
|
|
||||||
| TextureUsages::TEXTURE_BINDING,
|
|
||||||
view_formats: &[TextureFormat::Rg8Unorm],
|
|
||||||
};
|
|
||||||
device.create_texture(&desc)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user