diff --git a/.envrc b/.envrc index 3550a30..1d953f4 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use flake +use nix diff --git a/Cargo.lock b/Cargo.lock index b68b5aa..a397605 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -47,7 +47,7 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a64c907d4e79225ac72e2a354c9ce84d50ebb4586dee56c82b3ee73004f537f5" dependencies = [ - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -57,7 +57,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61a38449feb7068f52bb06c12759005cf459ee52bb4adc1d5a7c4322d716fb19" dependencies = [ "anstyle", - "windows-sys", + "windows-sys 0.52.0", ] [[package]] @@ -68,21 +68,9 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "bitflags" -version = "2.9.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" - -[[package]] -name = "bitvec" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1bc2832c24239b0141d5674bb9174f9d68a8b5b3f2753311927c172ca46f7e9c" -dependencies = [ - "funty", - "radium", - "tap", - "wyz", -] +checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1" [[package]] name = "cfg-if" @@ -136,28 +124,17 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0b6a852b24ab71dffc585bcb46eaf7959d175cb865a7152e35b348d1b2960422" -[[package]] -name = "convert_case" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb402b8d4c85569410425650ce3eddc7d698ed96d39a73f941b08fb63082f1e7" -dependencies = [ - "unicode-segmentation", -] - [[package]] name = "crossterm" -version = "0.29.0" +version = "0.27.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8b9f2e4c67f833b660cdb0a3523065869fb35570177239812ed4c905aeff87b" +checksum = "f476fe445d41c9e991fd07515a6f463074b782242ccf4a5b7b1d1012e70824df" dependencies = [ "bitflags", "crossterm_winapi", - "derive_more", - "document-features", + "libc", "mio", "parking_lot", - "rustix", "signal-hook", "signal-hook-mio", "winapi", @@ -172,36 +149,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "derive_more" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "093242cf7570c207c83073cf82f79706fe7b8317e98620a47d5be7c3d8497678" -dependencies = [ - "derive_more-impl", -] - -[[package]] -name = "derive_more-impl" -version = "2.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bda628edc44c4bb645fbe0f758797143e4e07926f7ebf4e9bdfbd3d2ce621df3" -dependencies = [ - "convert_case", - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "document-features" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95249b50c6c185bee49034bcb378a49dc2b5dff0be90ff6616d31d64febab05d" -dependencies = [ - "litrs", -] - [[package]] name = "env_filter" version = "0.1.0" @@ -225,22 +172,6 @@ dependencies = [ "log", ] -[[package]] -name = "errno" -version = "0.3.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "976dd42dc7e85965fe702eb8164f21f450704bdde31faefd6471dba214cb594e" -dependencies = [ - "libc", - "windows-sys", -] - -[[package]] -name = "funty" -version = "2.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6d5a32815ae3f33302d95fdcb2ce17862f8c65363dcfd29360480ba1001fc9c" - [[package]] name = "getrandom" version = "0.2.15" @@ -272,21 +203,9 @@ checksum = "f8478577c03552c21db0e2724ffb8986a5ce7af88107e6be5d2ee6e158c12800" [[package]] name = "libc" -version = "0.2.172" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d750af042f7ef4f724306de029d18836c26c1765a54a6a3f094cbd23a7267ffa" - -[[package]] -name = "linux-raw-sys" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" - -[[package]] -name = "litrs" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4ce301924b7887e9d637144fdade93f9dfff9b60981d4ac161db09720d39aa5" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "lock_api" @@ -312,22 +231,16 @@ checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "mio" -version = "1.0.3" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", "wasi", - "windows-sys", + "windows-sys 0.48.0", ] -[[package]] -name = "once_cell" -version = "1.21.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" - [[package]] name = "parking_lot" version = "0.12.2" @@ -348,15 +261,9 @@ dependencies = [ "libc", "redox_syscall", "smallvec", - "windows-targets", + "windows-targets 0.52.5", ] -[[package]] -name = "pkg-config" -version = "0.3.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" - [[package]] name = "ppv-lite86" version = "0.2.17" @@ -365,9 +272,9 @@ checksum = "5b40af805b3121feab8a3c29f04d8ad262fa8e0561883e7653e024ae4479e6de" [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "8ad3d49ab951a01fbaafe34f2ec74122942fe18a3f9814c3268f1bb72042131b" dependencies = [ "unicode-ident", ] @@ -381,28 +288,22 @@ dependencies = [ "proc-macro2", ] -[[package]] -name = "radium" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc33ff2d4973d518d823d61aa239014831e521c75da58e3df4840d3f47749d09" - [[package]] name = "rand" -version = "0.8.5" +version = "0.9.0-alpha.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +checksum = "8d31e63ea85be51c423e52ba8f2e68a3efd53eed30203ee029dd09947333693e" dependencies = [ - "libc", "rand_chacha", "rand_core", + "zerocopy", ] [[package]] name = "rand_chacha" -version = "0.3.1" +version = "0.9.0-alpha.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +checksum = "78674ef918c19451dbd250f8201f8619b494f64c9aa6f3adb28fd8a0f1f6da46" dependencies = [ "ppv-lite86", "rand_core", @@ -410,11 +311,12 @@ dependencies = [ [[package]] name = "rand_core" -version = "0.6.4" +version = "0.9.0-alpha.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +checksum = "cc89dffba8377c5ec847d12bb41492bda235dba31a25e8b695cd0fe6589eb8c9" dependencies = [ "getrandom", + "zerocopy", ] [[package]] @@ -455,58 +357,31 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "adad44e29e4c806119491a7f06f03de4d1af22c3a680dd47f1e6e179439d1f56" -[[package]] -name = "rust-lzma" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d62915608f6cee1d7f2fc00f28b4f058ff79d6e4ec3c2fe0006b09b52437c84" -dependencies = [ - "pkg-config", - "vcpkg", -] - -[[package]] -name = "rustix" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c71e83d6afe7ff64890ec6b71d6a69bb8a610ab78ce364b3352876bb4c801266" -dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", -] - [[package]] name = "scopeguard" version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" -[[package]] -name = "servicepoint" -version = "0.14.0" -source = "git+https://git.berlin.ccc.de/servicepoint/servicepoint/?branch=next#8ddbaeaaa64a4abb8ffb8b08a3a84cc1135e312f" -dependencies = [ - "bitvec", - "log", - "once_cell", - "rand", - "rust-lzma", - "thiserror", -] - [[package]] name = "servicepoint-life" -version = "0.2.0" +version = "0.1.0" dependencies = [ "clap", "crossterm", "env_logger", "log", "rand", - "servicepoint", + "servicepoint2", +] + +[[package]] +name = "servicepoint2" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94d9aecc4d31a71578481de6c6d64383d374126c38469c9689067579c1d910fd" +dependencies = [ + "log", ] [[package]] @@ -521,9 +396,9 @@ dependencies = [ [[package]] name = "signal-hook-mio" -version = "0.2.4" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "34db1a06d485c9142248b7a054f034b349b212551f3dfd19c94d45a754a217cd" +checksum = "29ad2e15f37ec9a6cc544097b78a1ec90001e9f71b81338ca39f430adaca99af" dependencies = [ "libc", "mio", @@ -553,65 +428,27 @@ checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" [[package]] name = "syn" -version = "2.0.101" +version = "2.0.64" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "7ad3dee41f36859875573074334c200d1add8e4a87bb37113ebd31d926b7b11f" dependencies = [ "proc-macro2", "quote", "unicode-ident", ] -[[package]] -name = "tap" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369" - -[[package]] -name = "thiserror" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "2.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-segmentation" -version = "1.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" - [[package]] name = "utf8parse" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a" -[[package]] -name = "vcpkg" -version = "0.2.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" - [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -640,13 +477,37 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.5", +] + [[package]] name = "windows-sys" version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" dependencies = [ - "windows-targets", + "windows-targets 0.52.5", +] + +[[package]] +name = "windows-targets" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c" +dependencies = [ + "windows_aarch64_gnullvm 0.48.5", + "windows_aarch64_msvc 0.48.5", + "windows_i686_gnu 0.48.5", + "windows_i686_msvc 0.48.5", + "windows_x86_64_gnu 0.48.5", + "windows_x86_64_gnullvm 0.48.5", + "windows_x86_64_msvc 0.48.5", ] [[package]] @@ -655,28 +516,46 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6f0713a46559409d202e70e28227288446bf7841d3211583a4b53e3f6d96e7eb" dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", + "windows_aarch64_gnullvm 0.52.5", + "windows_aarch64_msvc 0.52.5", + "windows_i686_gnu 0.52.5", "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", + "windows_i686_msvc 0.52.5", + "windows_x86_64_gnu 0.52.5", + "windows_x86_64_gnullvm 0.52.5", + "windows_x86_64_msvc 0.52.5", ] +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8" + [[package]] name = "windows_aarch64_gnullvm" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263" +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc" + [[package]] name = "windows_aarch64_msvc" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6" +[[package]] +name = "windows_i686_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e" + [[package]] name = "windows_i686_gnu" version = "0.52.5" @@ -689,24 +568,48 @@ version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9" +[[package]] +name = "windows_i686_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406" + [[package]] name = "windows_i686_msvc" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf" +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e" + [[package]] name = "windows_x86_64_gnu" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4e4246f76bdeff09eb48875a0fd3e2af6aada79d409d33011886d3e1581517d9" +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc" + [[package]] name = "windows_x86_64_gnullvm" version = "0.52.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596" +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538" + [[package]] name = "windows_x86_64_msvc" version = "0.52.5" @@ -714,10 +617,21 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] -name = "wyz" -version = "0.5.1" +name = "zerocopy" +version = "0.8.0-alpha.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "05f360fc0b24296329c78fda852a1e9ae82de9cf7b27dae4b7f62f118f77b9ed" +checksum = "db678a6ee512bd06adf35c35be471cae2f9c82a5aed2b5d15e03628c98bddd57" dependencies = [ - "tap", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.0-alpha.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "201585ea96d37ee69f2ac769925ca57160cef31acb137c16f38b02b76f4c1e62" +dependencies = [ + "proc-macro2", + "quote", + "syn", ] diff --git a/Cargo.toml b/Cargo.toml index 9b1cb68..9b88435 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,35 +1,12 @@ [package] name = "servicepoint-life" -version = "0.2.0" +version = "0.1.0" edition = "2021" -license = "GPL-3.0-or-later" -description = "Small terminal app that generates conways game of life rules and simulates them on the servicepoint display." -repository = "https://git.berlin.ccc.de/vinzenz/servicepoint-life" -readme = "README.md" -keywords = ["cccb", "cccb-servicepoint", "conway", "game-of-life", "simulation"] -rust-version = "1.70.0" [dependencies] -clap = { version = "4.5", features = ["derive"] } -rand = "0.8" -env_logger = "0.11" -crossterm = "0.29" -log = "0.4" - -[dependencies.servicepoint] -package = "servicepoint" -version = "0.14.0" -features = ["rand"] -git = "https://git.berlin.ccc.de/servicepoint/servicepoint/" -branch = "next" - -[lints.clippy] -incompatible_msrv = "forbid" - -[profile.size-optimized] -inherits = "release" -opt-level = 'z' # Optimize for size -lto = true # Enable link-time optimization -codegen-units = 1 # Reduce number of codegen units to increase optimizations -panic = 'abort' # Abort on panic -strip = true # Strip symbols from binary +clap = { version = "4.5.4", features = ["derive"] } +rand = "0.9.0-alpha.1" +env_logger = "0.11.3" +servicepoint2 = { version = "0.4.2", default-features = false } +crossterm = "0.27.0" +log = "0.4.21" diff --git a/README.md b/README.md index c262679..8fada83 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,5 @@ # servicepoint-life -This is a small terminal app that generates conways game of life rules and simulates them on the servicepoint display. +More fully featured game of life for the servicepoint display based on the example in the repo. -It uses the [servicepoint](https://git.berlin.ccc.de/servicepoint/servicepoint/) library for the display commands. -## Running - -With Nix flakes, you can just `nix run git+https://git.berlin.ccc.de/vinzenz/servicepoint-life`. - -Otherwise, you can `cargo install --git https://git.berlin.ccc.de/vinzenz/servicepoint-life` and then run `servicepoint-life`. - -If you want to poke at the code you can always check out the repo and `cargo run` it. diff --git a/flake.lock b/flake.lock deleted file mode 100644 index 8c4b6bb..0000000 --- a/flake.lock +++ /dev/null @@ -1,64 +0,0 @@ -{ - "nodes": { - "naersk": { - "inputs": { - "nixpkgs": [ - "nixpkgs" - ] - }, - "locked": { - "lastModified": 1745925850, - "narHash": "sha256-cyAAMal0aPrlb1NgzMxZqeN1mAJ2pJseDhm2m6Um8T0=", - "owner": "nix-community", - "repo": "naersk", - "rev": "38bc60bbc157ae266d4a0c96671c6c742ee17a5f", - "type": "github" - }, - "original": { - "owner": "nix-community", - "repo": "naersk", - "type": "github" - } - }, - "nix-filter": { - "locked": { - "lastModified": 1731533336, - "narHash": "sha256-oRam5PS1vcrr5UPgALW0eo1m/5/pls27Z/pabHNy2Ms=", - "owner": "numtide", - "repo": "nix-filter", - "rev": "f7653272fd234696ae94229839a99b73c9ab7de0", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "nix-filter", - "type": "github" - } - }, - "nixpkgs": { - "locked": { - "lastModified": 1746055187, - "narHash": "sha256-3dqArYSMP9hM7Qpy5YWhnSjiqniSaT2uc5h2Po7tmg0=", - "owner": "nixos", - "repo": "nixpkgs", - "rev": "3e362ce63e16b9572d8c2297c04f7c19ab6725a5", - "type": "github" - }, - "original": { - "owner": "nixos", - "ref": "nixos-24.11", - "repo": "nixpkgs", - "type": "github" - } - }, - "root": { - "inputs": { - "naersk": "naersk", - "nix-filter": "nix-filter", - "nixpkgs": "nixpkgs" - } - } - }, - "root": "root", - "version": 7 -} diff --git a/flake.nix b/flake.nix deleted file mode 100644 index ed140f1..0000000 --- a/flake.nix +++ /dev/null @@ -1,103 +0,0 @@ -{ - description = "Flake for servicepoint-life"; - - inputs = { - nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11"; - nix-filter.url = "github:numtide/nix-filter"; - naersk = { - url = "github:nix-community/naersk"; - inputs.nixpkgs.follows = "nixpkgs"; - }; - }; - - outputs = - inputs@{ - self, - nixpkgs, - naersk, - nix-filter, - }: - let - lib = nixpkgs.lib; - supported-systems = [ - "x86_64-linux" - "aarch64-linux" - "aarch64-darwin" - "x86_64-darwin" - ]; - forAllSystems = - f: - lib.genAttrs supported-systems ( - system: - f rec { - pkgs = nixpkgs.legacyPackages.${system}; - naersk' = pkgs.callPackage naersk { }; - selfPkgs = self.packages."${system}"; - inherit system; - } - ); - in - rec { - packages = forAllSystems ( - { pkgs, naersk', ... }: - rec { - servicepoint-life = naersk'.buildPackage rec { - strictDeps = true; - nativeBuildInputs = with pkgs; [ pkg-config ]; - buildInputs = with pkgs; [ - xe - xz - ]; - src = nix-filter.lib.filter { - root = ./.; - include = [ - ./Cargo.toml - ./Cargo.lock - ./src - ./README.md - ./LICENSE - ]; - }; - }; - - default = servicepoint-life; - } - ); - - legacyPackages = packages; - - apps = forAllSystems ( - { selfPkgs, ... }: - rec { - servicepoint-life = { - type = "app"; - program = "${selfPkgs.servicepoint-life}/bin/servicepoint-life"; - }; - default = servicepoint-life; - } - ); - - devShells = forAllSystems ( - { pkgs, selfPkgs, ... }: - { - default = pkgs.mkShell rec { - inputsFrom = [ selfPkgs.default ]; - packages = [ - pkgs.gdb - (pkgs.symlinkJoin { - name = "rust-toolchain"; - paths = with pkgs; [ - rustc - cargo - rustfmt - clippy - ]; - }) - ]; - }; - } - ); - - formatter = forAllSystems ({ pkgs, ... }: pkgs.nixfmt-rfc-style); - }; -} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..0bf2bcc --- /dev/null +++ b/shell.nix @@ -0,0 +1,4 @@ +{ pkgs ? import {} }: + pkgs.mkShell { + nativeBuildInputs = with pkgs.buildPackages; [ rustup cargo pkg-config xe lzma ]; +} diff --git a/src/game.rs b/src/game.rs index 9caa85b..308440d 100644 --- a/src/game.rs +++ b/src/game.rs @@ -1,25 +1,29 @@ -use servicepoint::{Grid, Value, ValueGrid}; +use servicepoint2::Grid; use crate::rules::Rules; -pub(crate) struct Game +pub(crate) struct Game where - TState: Value + PartialEq, - TKernel: Value, + TGrid: Grid, + TState: Copy + PartialEq, + TKernel: Copy, { - pub field: ValueGrid, + pub field: TGrid, pub rules: Rules, } -impl - Game +impl Game +where + TGrid: Grid, + TState: Copy + PartialEq, + TKernel: Copy, { pub fn step(&mut self) { self.field = self.field_iteration(); } - fn field_iteration(&self) -> ValueGrid { - let mut next = ValueGrid::new(self.field.width(), self.field.height()); + fn field_iteration(&self) -> TGrid { + let mut next = TGrid::new(self.field.width(), self.field.height()); for x in 0..self.field.width() { for y in 0..self.field.height() { let old_state = self.field.get(x, y); diff --git a/src/main.rs b/src/main.rs index 0679ef0..02e8bda 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,35 +1,26 @@ -use std::{ - io::stdout, - net::UdpSocket, - num::Wrapping, - thread, - time::{Duration, Instant}, -}; -use crate::{ - game::Game, - print::{println_debug, println_info, println_warning}, - rules::{generate_bb3, generate_u8b3}, -}; +use std::io::stdout; +use std::num::Wrapping; +use std::thread; +use std::time::{Duration, Instant}; + use clap::Parser; -use crossterm::{ - event, - event::{Event, KeyCode, KeyEventKind}, - execute, - terminal::{ - disable_raw_mode, enable_raw_mode, EnableLineWrap, EnterAlternateScreen, - LeaveAlternateScreen, - }, +use crossterm::{event, execute}; +use crossterm::event::{Event, KeyCode, KeyEventKind}; +use crossterm::terminal::{ + disable_raw_mode, enable_raw_mode, EnableLineWrap, EnterAlternateScreen, LeaveAlternateScreen, }; use log::LevelFilter; -use rand::{ - distributions::{Distribution, Standard}, - Rng, -}; -use servicepoint::{ - Bitmap, BitmapCommand, Brightness, BrightnessGrid, BrightnessGridCommand, ByteGrid, Grid, - SendCommandExt, UdpSocketExt, ValueGrid, FRAME_PACING, PIXEL_HEIGHT, PIXEL_WIDTH, TILE_HEIGHT, +use rand::distributions::{Distribution, Standard}; +use rand::Rng; +use servicepoint2::{ + ByteGrid, CompressionCode, Connection, FRAME_PACING, Grid, Origin, PixelGrid, TILE_HEIGHT, TILE_WIDTH, }; +use servicepoint2::Command::{BitmapLinearWin, CharBrightness}; + +use crate::game::Game; +use crate::print::{println_debug, println_info, println_warning}; +use crate::rules::{generate_bb3, generate_u8b3}; mod game; mod print; @@ -46,11 +37,11 @@ fn main() { let mut left_pixels = Game { rules: generate_bb3(), - field: ValueGrid::new(PIXEL_WIDTH, PIXEL_HEIGHT), + field: PixelGrid::max_sized(), }; let mut right_pixels = Game { rules: generate_bb3(), - field: ValueGrid::new(PIXEL_WIDTH, PIXEL_HEIGHT), + field: PixelGrid::max_sized(), }; let mut left_luma = Game { rules: generate_u8b3(), @@ -66,8 +57,8 @@ fn main() { randomize(&mut right_luma.field); randomize(&mut right_pixels.field); - let mut pixels = Bitmap::max_sized(); - let mut luma = BrightnessGrid::new(TILE_WIDTH, TILE_HEIGHT); + let mut pixels = PixelGrid::max_sized(); + let mut luma = ByteGrid::new(TILE_WIDTH, TILE_HEIGHT); let mut split_pixel = 0; let mut split_speed: i32 = 1; @@ -162,17 +153,11 @@ fn main() { } Ok(AppEvent::SimulationSpeedUp) => { target_duration = target_duration.saturating_sub(Duration::from_millis(1)); - println_info(format!( - "increased simulation speed to {} ups", - 1f64 / target_duration.as_secs_f64() - )); + println_info(format!("increased simulation speed to {} ups", 1f64 / target_duration.as_secs_f64())); } Ok(AppEvent::SimulationSpeedDown) => { target_duration = target_duration.saturating_add(Duration::from_millis(1)); - println_info(format!( - "decreased simulation speed to {} ups", - 1f64 / target_duration.as_secs_f64() - )); + println_info(format!("decreased simulation speed to {} ups", 1f64 / target_duration.as_secs_f64())); } } } @@ -237,12 +222,7 @@ impl TryFrom for AppEvent { } } -fn draw_pixels( - pixels: &mut Bitmap, - left: &ValueGrid, - right: &ValueGrid, - split_index: usize, -) { +fn draw_pixels(pixels: &mut PixelGrid, left: &PixelGrid, right: &PixelGrid, split_index: usize) { for x in 0..pixels.width() { let left_or_right = if x < split_index { left } else { right }; for y in 0..pixels.height() { @@ -252,28 +232,34 @@ fn draw_pixels( } } -fn draw_luma(luma: &mut BrightnessGrid, left: &ByteGrid, right: &ByteGrid, split_tile: usize) { +fn draw_luma(luma: &mut ByteGrid, left: &ByteGrid, right: &ByteGrid, split_tile: usize) { for x in 0..luma.width() { let left_or_right = if x < split_tile { left } else { right }; for y in 0..luma.height() { - let set: u8 = left_or_right.get(x, y) / u8::MAX * u8::from(Brightness::MAX); - let set = Brightness::try_from(set).unwrap(); - luma.set(x, y, set); + let set = u8::max(48, left_or_right.get(x, y)); + + let set = set as f32 / u8::MAX as f32 * 12f32; + + luma.set(x, y, set as u8); } } } -fn send_to_screen(connection: &UdpSocket, pixels: &Bitmap, luma: &BrightnessGrid) { - let cmd: BitmapCommand = pixels.clone().into(); - connection.send_command(cmd).unwrap(); - let cmd: BrightnessGridCommand = luma.clone().into(); - connection.send_command(cmd).unwrap(); +fn send_to_screen(connection: &Connection, pixels: &PixelGrid, luma: &ByteGrid) { + let pixel_cmd = BitmapLinearWin(Origin(0, 0), pixels.clone(), CompressionCode::Uncompressed); + connection + .send(pixel_cmd.into()) + .expect("could not send pixels"); + + connection + .send(CharBrightness(Origin(0, 0), luma.clone()).into()) + .expect("could not send brightness"); } fn randomize(field: &mut TGrid) -where - TGrid: Grid, - Standard: Distribution, + where + TGrid: Grid, + Standard: Distribution, { let mut rng = rand::thread_rng(); @@ -284,7 +270,7 @@ where } } -fn init() -> UdpSocket { +fn init() -> Connection { env_logger::builder() .filter_level(LevelFilter::Info) .parse_default_env() @@ -294,7 +280,7 @@ fn init() -> UdpSocket { .expect("could not enter alternate screen"); enable_raw_mode().expect("could not enable raw terminal mode"); - UdpSocket::bind_connect(Cli::parse().destination) + Connection::open(Cli::parse().destination) .expect("Could not connect. Did you forget `--destination`?") } diff --git a/src/rules.rs b/src/rules.rs index bd06cdd..6156a5d 100644 --- a/src/rules.rs +++ b/src/rules.rs @@ -3,6 +3,8 @@ use rand::{thread_rng, Rng}; use crate::print::println_info; +const MAX_BRIGHTNESS: u8 = 12; + pub struct Rules where TState: Copy + PartialEq, @@ -86,7 +88,7 @@ pub fn generate_u8b3() -> Rules { _ => panic!(), }; - let alive_threshold = u8::max(1, rng.gen()); + let alive_threshold = rng.gen(); let birth = generate_neighbor_counts(rng.gen_range(1..=9), &mut rng, &[0]); let survive = generate_neighbor_counts(