From e9770053dda314049602b488926b6ff7975c99f8 Mon Sep 17 00:00:00 2001 From: Rekai Musuka Date: Mon, 29 Mar 2021 19:25:46 -0500 Subject: [PATCH] chore: limpopo update --- .gitignore | 6 + 2020-09-26/fizz_buzz/.gitignore | 1 - 2020-11-02/pw313/Cargo.lock | 1571 +++++++++++++++++++++ 2020-11-02/pw313/Cargo.toml | 14 + 2020-11-02/pw313/src/main.rs | 172 +++ 2020-11-02/pw313/src/old.rs | 185 +++ 2021-03-04/password.py | 36 + 2021-03-04/url_validate.py | 17 + 2021-03-10/zig-hello/build.zig | 27 + 2021-03-10/zig-hello/src/main.zig | 6 + 2021-03-11/nichol-assignment/img/.gitkeep | 0 2021-03-11/nichol-assignment/index.css | 90 ++ 2021-03-11/nichol-assignment/index.html | 197 +++ 2021-03-16/zig8/build.zig | 29 + 2021-03-16/zig8/src/cpu.zig | 203 +++ 2021-03-16/zig8/src/display.zig | 56 + 2021-03-16/zig8/src/instructions.zig | 12 + 2021-03-16/zig8/src/main.zig | 107 ++ 18 files changed, 2728 insertions(+), 1 deletion(-) create mode 100644 .gitignore delete mode 100644 2020-09-26/fizz_buzz/.gitignore create mode 100644 2020-11-02/pw313/Cargo.lock create mode 100644 2020-11-02/pw313/Cargo.toml create mode 100644 2020-11-02/pw313/src/main.rs create mode 100644 2020-11-02/pw313/src/old.rs create mode 100644 2021-03-04/password.py create mode 100644 2021-03-04/url_validate.py create mode 100644 2021-03-10/zig-hello/build.zig create mode 100644 2021-03-10/zig-hello/src/main.zig create mode 100644 2021-03-11/nichol-assignment/img/.gitkeep create mode 100644 2021-03-11/nichol-assignment/index.css create mode 100644 2021-03-11/nichol-assignment/index.html create mode 100644 2021-03-16/zig8/build.zig create mode 100644 2021-03-16/zig8/src/cpu.zig create mode 100644 2021-03-16/zig8/src/display.zig create mode 100644 2021-03-16/zig8/src/instructions.zig create mode 100644 2021-03-16/zig8/src/main.zig diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2e244f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,6 @@ +**/target +**/zig-cache +**/.vscode +**/bin +**/rom +**/.gitignore \ No newline at end of file diff --git a/2020-09-26/fizz_buzz/.gitignore b/2020-09-26/fizz_buzz/.gitignore deleted file mode 100644 index ea8c4bf..0000000 --- a/2020-09-26/fizz_buzz/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/2020-11-02/pw313/Cargo.lock b/2020-11-02/pw313/Cargo.lock new file mode 100644 index 0000000..ab152e6 --- /dev/null +++ b/2020-11-02/pw313/Cargo.lock @@ -0,0 +1,1571 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9fe5e32de01730eb1f6b7f5b51c17e03e2325bf40a74f754f04f130043affff" + +[[package]] +name = "adler" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee2a4ec343196209d6594e19543ae87a39f96d5534d7174822a3ad825dd6ed7e" + +[[package]] +name = "adler32" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aae1277d39aeec15cb388266ecc24b11c80469deae6067e17a1a7aa9e5c1f234" + +[[package]] +name = "aho-corasick" +version = "0.7.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b476ce7103678b0c6d3d395dbbae31d48ff910bd28be979ba5d48c6351131d0d" +dependencies = [ + "memchr", +] + +[[package]] +name = "andrew" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c4afb09dd642feec8408e33f92f3ffc4052946f6b20f32fb99c1f58cd4fa7cf" +dependencies = [ + "bitflags", + "rusttype", + "walkdir", + "xdg", + "xml-rs", +] + +[[package]] +name = "ansi_term" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "anyhow" +version = "1.0.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bf8dcb5b4bbaa28653b647d8c77bd4ed40183b48882e130c1f1ffb73de069fd7" + +[[package]] +name = "atty" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" +dependencies = [ + "hermit-abi", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "bindgen" +version = "0.54.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66c0bb6167449588ff70803f4127f0684f9063097eca5016f37eb52b92c2cf36" +dependencies = [ + "bitflags", + "cexpr", + "cfg-if 0.1.10", + "clang-sys", + "clap", + "env_logger", + "lazy_static", + "lazycell", + "log", + "peeking_take_while", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "which", +] + +[[package]] +name = "bitflags" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693" + +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + +[[package]] +name = "bytemuck" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41aa2ec95ca3b5c54cf73c91acf06d24f4495d5f1b1c12506ae3483d646177ac" + +[[package]] +name = "byteorder" +version = "1.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de" + +[[package]] +name = "calloop" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b036167e76041694579972c28cf4877b4f92da222560ddb49008937b6a6727c" +dependencies = [ + "log", + "nix", +] + +[[package]] +name = "cc" +version = "1.0.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed67cbde08356238e75fc4656be4749481eeffb09e19f320a25237d5221c985d" + +[[package]] +name = "cexpr" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4aedb84272dbe89af497cf81375129abda4fc0a9e7c5d317498c15cc30c0d27" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "0.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "clang-sys" +version = "0.29.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe6837df1d5cba2397b835c8530f51723267e16abbf83892e9e5af4f0e5dd10a" +dependencies = [ + "glob", + "libc", + "libloading 0.5.2", +] + +[[package]] +name = "clap" +version = "2.33.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37e58ac78573c40708d45522f0d80fa2f01cc4f9b4e2bf749807255454312002" +dependencies = [ + "ansi_term", + "atty", + "bitflags", + "strsim 0.8.0", + "textwrap", + "unicode-width", + "vec_map", +] + +[[package]] +name = "cloudabi" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4344512281c643ae7638bbabc3af17a11307803ec8f0fcad9fae512a8bf36467" +dependencies = [ + "bitflags", +] + +[[package]] +name = "cocoa" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c54201c07dcf3a5ca33fececb8042aed767ee4bfd5a0235a8ceabcda956044b2" +dependencies = [ + "bitflags", + "block", + "cocoa-foundation", + "core-foundation 0.9.1", + "core-graphics 0.22.1", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "cocoa-foundation" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ade49b65d560ca58c403a479bb396592b155c0185eada742ee323d1d68d6318" +dependencies = [ + "bitflags", + "block", + "core-foundation 0.9.1", + "core-graphics-types", + "foreign-types", + "libc", + "objc", +] + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + +[[package]] +name = "const_fn" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab" + +[[package]] +name = "core-foundation" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57d24c7a13c43e870e37c1556b74555437870a04514f7685f5b354e090567171" +dependencies = [ + "core-foundation-sys 0.7.0", + "libc", +] + +[[package]] +name = "core-foundation" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a89e2ae426ea83155dccf10c0fa6b1463ef6d5fcb44cee0b224a408fa640a62" +dependencies = [ + "core-foundation-sys 0.8.2", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3a71ab494c0b5b860bdc8407ae08978052417070c2ced38573a9157ad75b8ac" + +[[package]] +name = "core-foundation-sys" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea221b5284a47e40033bf9b66f35f984ec0ea2931eb03505246cd27a963f981b" + +[[package]] +name = "core-graphics" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b3889374e6ea6ab25dba90bb5d96202f61108058361f6dc72e8b03e6f8bbe923" +dependencies = [ + "bitflags", + "core-foundation 0.7.0", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc239bba52bab96649441699533a68de294a101533b0270b2d65aa402b29a7f9" +dependencies = [ + "bitflags", + "core-foundation 0.9.1", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a68b68b3446082644c91ac778bf50cd4104bfb002b5a6a7c44cca5a2c70788b" +dependencies = [ + "bitflags", + "core-foundation 0.9.1", + "foreign-types", + "libc", +] + +[[package]] +name = "core-video-sys" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34ecad23610ad9757664d644e369246edde1803fcb43ed72876565098a5d3828" +dependencies = [ + "cfg-if 0.1.10", + "core-foundation-sys 0.7.0", + "core-graphics 0.19.2", + "libc", + "objc", +] + +[[package]] +name = "crc32fast" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "81156fece84ab6a9f2afdb109ce3ae577e42b1228441eded99bd77f627953b1a" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "crossbeam-channel" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dca26ee1f8d361640700bde38b2c37d8c22b3ce2d360e1fc1c74ea4b0aa7d775" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-deque" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94af6efb46fef72616855b036a624cf27ba656ffc9be1b9a3c931cfc7749a9a9" +dependencies = [ + "cfg-if 1.0.0", + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0f606a85340376eef0d6d8fec399e6d4a544d648386c6645eb6d0653b27d9f" +dependencies = [ + "cfg-if 1.0.0", + "const_fn", + "crossbeam-utils", + "lazy_static", + "memoffset", + "scopeguard", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec91540d98355f690a86367e566ecad2e9e579f230230eb7c21398372be73ea5" +dependencies = [ + "autocfg", + "cfg-if 1.0.0", + "const_fn", + "lazy_static", +] + +[[package]] +name = "darling" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d706e75d87e35569db781a9b5e2416cff1236a47ed380831f959382ccd5f858" +dependencies = [ + "darling_core", + "darling_macro", +] + +[[package]] +name = "darling_core" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0c960ae2da4de88a91b2d920c2a7233b400bc33cb28453a2987822d8392519b" +dependencies = [ + "fnv", + "ident_case", + "proc-macro2", + "quote", + "strsim 0.9.3", + "syn", +] + +[[package]] +name = "darling_macro" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9b5a2f4ac4969822c62224815d069952656cadc7084fdca9751e6d959189b72" +dependencies = [ + "darling_core", + "quote", + "syn", +] + +[[package]] +name = "deflate" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73770f8e1fe7d64df17ca66ad28994a0a623ea497fa69486e14984e715c5d174" +dependencies = [ + "adler32", + "byteorder", +] + +[[package]] +name = "derivative" +version = "2.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb582b60359da160a9477ee80f15c8d784c477e69c217ef2cdd4169c24ea380f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dlib" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b11f15d1e3268f140f68d390637d5e76d849782d971ae7063e0da69fe9709a76" +dependencies = [ + "libloading 0.6.5", +] + +[[package]] +name = "downcast-rs" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ea835d29036a4087793836fa931b08837ad5e957da9e23886b29586fb9b6650" + +[[package]] +name = "either" +version = "1.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" + +[[package]] +name = "env_logger" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" +dependencies = [ + "atty", + "humantime", + "log", + "regex", + "termcolor", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "fuchsia-zircon" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" +dependencies = [ + "bitflags", + "fuchsia-zircon-sys", +] + +[[package]] +name = "fuchsia-zircon-sys" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" + +[[package]] +name = "gif" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02efba560f227847cb41463a7395c514d127d4f74fff12ef0137fff1b84b96c4" +dependencies = [ + "color_quant", + "weezl", +] + +[[package]] +name = "glob" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" + +[[package]] +name = "hermit-abi" +version = "0.1.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5aca5565f760fb5b220e499d72710ed156fdb74e631659e99377d9ebfbd13ae8" +dependencies = [ + "libc", +] + +[[package]] +name = "humantime" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" +dependencies = [ + "quick-error", +] + +[[package]] +name = "ident_case" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9e0384b61958566e926dc50660321d12159025e767c18e043daf26b70104c39" + +[[package]] +name = "image" +version = "0.23.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4f0a8345b33b082aedec2f4d7d4a926b845cee184cbe78b703413066564431b" +dependencies = [ + "bytemuck", + "byteorder", + "color_quant", + "gif", + "jpeg-decoder", + "num-iter", + "num-rational", + "num-traits", + "png", + "scoped_threadpool", + "tiff", +] + +[[package]] +name = "instant" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb1fc4429a33e1f80d41dc9fea4d108a88bec1de8053878898ae448a0b52f613" +dependencies = [ + "cfg-if 1.0.0", +] + +[[package]] +name = "iovec" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" +dependencies = [ + "libc", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "jpeg-decoder" +version = "0.1.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc797adac5f083b8ff0ca6f6294a999393d76e197c36488e2ef732c4715f6fa3" +dependencies = [ + "byteorder", + "rayon", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.80" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614" + +[[package]] +name = "libloading" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2b111a074963af1d37a139918ac6d49ad1d0d5e47f72fd55388619691a7d753" +dependencies = [ + "cc", + "winapi 0.3.9", +] + +[[package]] +name = "libloading" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1090080fe06ec2648d0da3881d9453d97e71a45f00eb179af7fdd7e3f686fdb0" +dependencies = [ + "cfg-if 1.0.0", + "winapi 0.3.9", +] + +[[package]] +name = "lock_api" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28247cc5a5be2f05fbcd76dd0cf2c7d3b5400cb978a28042abcd4fa0b3f8261c" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fabed175da42fed1fa0746b0ea71f412aa9d35e76e95e59b192c64b9dc2bf8b" +dependencies = [ + "cfg-if 0.1.10", +] + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + +[[package]] +name = "maybe-uninit" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60302e4db3a61da70c0cb7991976248362f30319e88850c487b9b95bbf059e00" + +[[package]] +name = "memchr" +version = "2.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" + +[[package]] +name = "memmap" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6585fd95e7bb50d6cc31e20d4cf9afb4e2ba16c5846fc76793f11218da9c475b" +dependencies = [ + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "memoffset" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" +dependencies = [ + "autocfg", +] + +[[package]] +name = "miniz_oxide" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791daaae1ed6889560f8c4359194f56648355540573244a5448a83ba1ecc7435" +dependencies = [ + "adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2d26ec3309788e423cfbf68ad1800f061638098d76a83681af979dc4eda19d" +dependencies = [ + "adler", + "autocfg", +] + +[[package]] +name = "mio" +version = "0.6.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fce347092656428bc8eaf6201042cb551b8d67855af7374542a92a0fbfcac430" +dependencies = [ + "cfg-if 0.1.10", + "fuchsia-zircon", + "fuchsia-zircon-sys", + "iovec", + "kernel32-sys", + "libc", + "log", + "miow", + "net2", + "slab", + "winapi 0.2.8", +] + +[[package]] +name = "mio-extras" +version = "2.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "52403fe290012ce777c4626790c8951324a2b9e3316b3143779c72b029742f19" +dependencies = [ + "lazycell", + "log", + "mio", + "slab", +] + +[[package]] +name = "miow" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c1f2f3b1cf331de6896aabf6e9d55dca90356cc9960cca7eaaf408a355ae919" +dependencies = [ + "kernel32-sys", + "net2", + "winapi 0.2.8", + "ws2_32-sys", +] + +[[package]] +name = "ndk" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5eb167c1febed0a496639034d0c76b3b74263636045db5489eee52143c246e73" +dependencies = [ + "jni-sys", + "ndk-sys", + "num_enum", + "thiserror", +] + +[[package]] +name = "ndk-glue" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdf399b8b7a39c6fb153c4ec32c72fd5fe789df24a647f229c239aa7adb15241" +dependencies = [ + "lazy_static", + "libc", + "log", + "ndk", + "ndk-macro", + "ndk-sys", +] + +[[package]] +name = "ndk-macro" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05d1c6307dc424d0f65b9b06e94f88248e6305726b14729fd67a5e47b2dc481d" +dependencies = [ + "darling", + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "ndk-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c44922cb3dbb1c70b5e5f443d63b64363a898564d739ba5198e3a9138442868d" + +[[package]] +name = "net2" +version = "0.2.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ebc3ec692ed7c9a255596c67808dee269f64655d8baf7b4f0638e51ba1d6853" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "nix" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83450fe6a6142ddd95fb064b746083fc4ef1705fe81f64a64e1d4b39f54a1055" +dependencies = [ + "bitflags", + "cc", + "cfg-if 0.1.10", + "libc", +] + +[[package]] +name = "nom" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffb4262d26ed83a1c0a33a38fe2bb15797329c85770da05e6b828ddb782627af" +dependencies = [ + "memchr", + "version_check", +] + +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-iter" +version = "0.1.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2021c8337a54d21aca0d59a92577a029af9431cb59b909b03252b9c164fad59" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fa6d5f418879385b213d905f7cf5bf4aa553d4c380f0152d1d4f2749186fa9" +dependencies = [ + "autocfg", + "num-integer", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + +[[package]] +name = "num_cpus" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05499f3756671c15885fee9034446956fff3f243d6077b91e5767df161f766b3" +dependencies = [ + "hermit-abi", + "libc", +] + +[[package]] +name = "num_enum" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca565a7df06f3d4b485494f25ba05da1435950f4dc263440eda7a6fa9b8e36e4" +dependencies = [ + "derivative", + "num_enum_derive", +] + +[[package]] +name = "num_enum_derive" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffa5a33ddddfee04c0283a7653987d634e880347e96b5b2ed64de07efb59db9d" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", +] + +[[package]] +name = "once_cell" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "260e51e7efe62b592207e9e13a68e43692a7a279171d6ba57abd208bf23645ad" + +[[package]] +name = "owned_ttf_parser" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f923fb806c46266c02ab4a5b239735c144bdeda724a50ed058e5226f594cde3" +dependencies = [ + "ttf-parser", +] + +[[package]] +name = "parking_lot" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4893845fa2ca272e647da5d0e46660a314ead9c2fdd9a883aabc32e481a8733" +dependencies = [ + "instant", + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c361aa727dd08437f2f1447be8b59a33b0edd15e0fcee698f935613d9efbca9b" +dependencies = [ + "cfg-if 0.1.10", + "cloudabi", + "instant", + "libc", + "redox_syscall", + "smallvec", + "winapi 0.3.9", +] + +[[package]] +name = "peeking_take_while" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099" + +[[package]] +name = "percent-encoding" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" + +[[package]] +name = "pkg-config" +version = "0.3.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" + +[[package]] +name = "png" +version = "0.16.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfe7f9f1c730833200b134370e1d5098964231af8450bce9b78ee3ab5278b970" +dependencies = [ + "bitflags", + "crc32fast", + "deflate", + "miniz_oxide 0.3.7", +] + +[[package]] +name = "proc-macro-crate" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d6ea3c4595b96363c13943497db34af4460fb474a95c43f4446ad341b8c9785" +dependencies = [ + "toml", +] + +[[package]] +name = "proc-macro2" +version = "1.0.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0704ee1a7e00d7bb417d0770ea303c1bccbabf0ef1667dae92b5967f5f8a71" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "pw313" +version = "0.1.0" +dependencies = [ + "anyhow", + "image", + "sdl2", + "uvc", + "winit", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "raw-window-handle" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a441a7a6c80ad6473bd4b74ec1c9a4c951794285bf941c2126f607c72e48211" +dependencies = [ + "libc", +] + +[[package]] +name = "rayon" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b0d8e0819fadc20c74ea8373106ead0600e3a67ef1fe8da56e39b9ae7275674" +dependencies = [ + "autocfg", + "crossbeam-deque", + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9ab346ac5921dc62ffa9f89b7a773907511cdfa5490c572ae9be1be33e8afa4a" +dependencies = [ + "crossbeam-channel", + "crossbeam-deque", + "crossbeam-utils", + "lazy_static", + "num_cpus", +] + +[[package]] +name = "redox_syscall" +version = "0.1.57" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41cc0f7e4d5d4544e8861606a285bb08d3e70712ccc7d2b84d7c0ccfaf4b05ce" + +[[package]] +name = "regex" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38cf2c13ed4745de91a5eb834e11c00bcc3709e773173b2ce4c56c9fbde04b9c" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", + "thread_local", +] + +[[package]] +name = "regex-syntax" +version = "0.6.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b181ba2dcf07aaccad5448e8ead58db5b742cf85dfe035e2227f137a539a189" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rusttype" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc7c727aded0be18c5b80c1640eae0ac8e396abf6fa8477d96cb37d18ee5ec59" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scoped-tls" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2" + +[[package]] +name = "scoped_threadpool" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d51f5df5af43ab3f1360b429fa5e0152ac5ce8c0bd6485cae490332e96846a8" + +[[package]] +name = "scopeguard" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" + +[[package]] +name = "sdl2" +version = "0.34.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcbb85f4211627a7291c83434d6bbfa723e28dcaa53c7606087e3c61929e4b9c" +dependencies = [ + "bitflags", + "lazy_static", + "libc", + "sdl2-sys", +] + +[[package]] +name = "sdl2-sys" +version = "0.34.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d81feded049b9c14eceb4a4f6d596a98cebbd59abdba949c5552a015466d33" +dependencies = [ + "cfg-if 0.1.10", + "libc", + "version-compare", +] + +[[package]] +name = "serde" +version = "1.0.117" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" + +[[package]] +name = "shlex" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fdf1b9db47230893d76faad238fd6097fd6d6a9245cd7a4d90dbd639536bbd2" + +[[package]] +name = "slab" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8" + +[[package]] +name = "smallvec" +version = "1.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbee7696b84bbf3d89a1c2eccff0850e3047ed46bfcd2e92c29a2d074d57e252" + +[[package]] +name = "smithay-client-toolkit" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ec5c077def8af49f9b5aeeb5fcf8079c638c6615c3a8f9305e2dea601de57f7" +dependencies = [ + "andrew", + "bitflags", + "byteorder", + "calloop", + "dlib", + "lazy_static", + "log", + "memmap", + "nix", + "wayland-client", + "wayland-cursor", + "wayland-protocols", +] + +[[package]] +name = "strsim" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" + +[[package]] +name = "strsim" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c" + +[[package]] +name = "syn" +version = "1.0.48" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc371affeffc477f42a221a1e4297aedcea33d47d19b61455588bd9d8f6b19ac" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "termcolor" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb6bfa289a4d7c5766392812c0a1f4c1ba45afa1ad47803c11e1f407d846d75f" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "textwrap" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "thiserror" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "318234ffa22e0920fe9a40d7b8369b5f649d490980cf7aadcf1eb91594869b42" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cae2447b6282786c3493999f40a9be2a6ad20cb8bd268b0a0dbf5a065535c0ab" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "thread_local" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d40c6d1b69745a6ec6fb1ca717914848da4b44ae29d9b3080cbee91d72a69b14" +dependencies = [ + "lazy_static", +] + +[[package]] +name = "tiff" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abeb4e3f32a8973722c0254189e6890358e72b1bf11becb287ee0b23c595a41d" +dependencies = [ + "jpeg-decoder", + "miniz_oxide 0.4.3", + "weezl", +] + +[[package]] +name = "toml" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75cf45bb0bef80604d001caaec0d09da99611b3c0fd39d3080468875cdb65645" +dependencies = [ + "serde", +] + +[[package]] +name = "ttf-parser" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e5d7cd7ab3e47dda6e56542f4bbf3824c15234958c6e1bd6aaa347e93499fdc" + +[[package]] +name = "unicode-width" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9337591893a19b88d8d87f2cec1e73fad5cdfd10e5a6f349f498ad6ea2ffb1e3" + +[[package]] +name = "unicode-xid" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564" + +[[package]] +name = "uvc" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8aed1a5233f532c7a507ab42d7c2e1ab95c5c19c54c145723ae0681d95860d7" +dependencies = [ + "uvc-sys", +] + +[[package]] +name = "uvc-sys" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcf8389230f9ccf09c9917b18ff8061033784e5467f145353730fc4e0d067c1a" +dependencies = [ + "bindgen", +] + +[[package]] +name = "vec_map" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191" + +[[package]] +name = "version-compare" +version = "0.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d63556a25bae6ea31b52e640d7c41d1ab27faba4ccb600013837a3d0b3994ca1" + +[[package]] +name = "version_check" +version = "0.9.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" + +[[package]] +name = "walkdir" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "777182bc735b6424e1a57516d35ed72cb8019d85c8c9bf536dccb3445c1a2f7d" +dependencies = [ + "same-file", + "winapi 0.3.9", + "winapi-util", +] + +[[package]] +name = "wayland-client" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80c54f9b90b2c044784f91fe22c5619a8a9c681db38492f2fd78ff968cf3f184" +dependencies = [ + "bitflags", + "downcast-rs", + "libc", + "nix", + "scoped-tls", + "wayland-commons", + "wayland-scanner", + "wayland-sys", +] + +[[package]] +name = "wayland-commons" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7602d75560fe6f02cac723609cce658042fe60541b5107999818d29d4dab7cfa" +dependencies = [ + "nix", + "once_cell", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-cursor" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0446b959c5b5b4b2c11f63112fc7cbeb50ecd9f2c340d2b0ea632875685baf04" +dependencies = [ + "nix", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-protocols" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d419585bbdb150fb541579cff205c6095a86cd874530e41838d1f18a9569a08" +dependencies = [ + "bitflags", + "wayland-client", + "wayland-commons", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cc091af4b05a435312f7cefe3a26824d2017966a58362ca913f72c3d68e5e2" +dependencies = [ + "proc-macro2", + "quote", + "xml-rs", +] + +[[package]] +name = "wayland-sys" +version = "0.28.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5640f53d1fe6eaaa2e77b9ff015fe9a556173ce8388607f941aecfd9b05c73e" +dependencies = [ + "dlib", + "lazy_static", + "pkg-config", +] + +[[package]] +name = "weezl" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8795d6e0e17485803cc10ef126bb8c0d59b7c61b219d66cfe0b3216dd0e8580a" + +[[package]] +name = "which" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d011071ae14a2f6671d0b74080ae0cd8ebf3a6f8c9589a2cd45f23126fe29724" +dependencies = [ + "libc", +] + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" +dependencies = [ + "winapi 0.3.9", +] + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "winit" +version = "0.23.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5bc559da567d8aa671bbcd08304d49e982c7bf2cb91e10288b9188931c1b772" +dependencies = [ + "bitflags", + "cocoa", + "core-foundation 0.9.1", + "core-graphics 0.22.1", + "core-video-sys", + "dispatch", + "instant", + "lazy_static", + "libc", + "log", + "mio", + "mio-extras", + "ndk", + "ndk-glue", + "ndk-sys", + "objc", + "parking_lot", + "percent-encoding", + "raw-window-handle", + "smithay-client-toolkit", + "wayland-client", + "winapi 0.3.9", + "x11-dl", +] + +[[package]] +name = "ws2_32-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" +dependencies = [ + "winapi 0.2.8", + "winapi-build", +] + +[[package]] +name = "x11-dl" +version = "2.18.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf981e3a5b3301209754218f962052d4d9ee97e478f4d26d4a6eced34c1fef8" +dependencies = [ + "lazy_static", + "libc", + "maybe-uninit", + "pkg-config", +] + +[[package]] +name = "xcursor" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3a481cfdefd35e1c50073ae33a8000d695c98039544659f5dc5dd71311b0d01" +dependencies = [ + "nom", +] + +[[package]] +name = "xdg" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d089681aa106a86fade1b0128fb5daf07d5867a509ab036d99988dec80429a57" + +[[package]] +name = "xml-rs" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b07db065a5cf61a7e4ba64f29e67db906fb1787316516c4e6e5ff0fea1efcd8a" diff --git a/2020-11-02/pw313/Cargo.toml b/2020-11-02/pw313/Cargo.toml new file mode 100644 index 0000000..a6c274f --- /dev/null +++ b/2020-11-02/pw313/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "pw313" +version = "0.1.0" +authors = ["Rekai Musuka "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +uvc = "0.1" +winit = "0.23" +sdl2 = { version = "0.34" } +anyhow = "1.0" +image = "0.23" diff --git a/2020-11-02/pw313/src/main.rs b/2020-11-02/pw313/src/main.rs new file mode 100644 index 0000000..6100765 --- /dev/null +++ b/2020-11-02/pw313/src/main.rs @@ -0,0 +1,172 @@ +use anyhow::Result; +use sdl2::{ + event::Event, + keyboard::Keycode, + pixels::PixelFormatEnum, + render::{Texture, TextureCreator}, + surface::Surface, + video::WindowContext, +}; +use std::sync::{ + atomic::{AtomicUsize, Ordering}, + Arc, Mutex, +}; +use uvc::{Context, Device, DeviceHandle}; + +fn log_found_device(device: &Device) -> Result<()> { + let info = device.description()?; + + println!( + "Found device: Bus {:03} Device {:03} : ID {:04x}:{:04x} {} ({})", + device.bus_number(), + device.device_address(), + info.vendor_id, + info.product_id, + info.product.unwrap_or_else(|| "Unknown".to_string()), + info.manufacturer.unwrap_or_else(|| "Unknown".to_string()), + ); + + Ok(()) +} + +fn log_device_settings(device: &DeviceHandle) { + println!( + "Scanning mode: {:?}\nAuto-exposure mode: {:?}\nAuto-exposure priority: {:?}\nAbsolute exposure: {:?}\nRelative exposure: {:?}\nAboslute focus: {:?}\nRelative focus: {:?}", + device.scanning_mode(), + device.ae_mode(), + device.ae_priority(), + device.exposure_abs(), + device.exposure_rel(), + device.focus_abs(), + device.focus_rel(), + ); +} + +fn main() { + let uvc_ctx = Context::new().expect("Could not create context"); + let device = uvc_ctx + .find_device(Some(0x07ca), Some(0x313a), None) + .expect("Unable to find the AVerMedia PW313"); + + log_found_device(&device).unwrap(); + + let device = device.open().expect("Unable to open webcam."); + let format = device + .get_preferred_format(|x, y| { + if x.fps >= y.fps && x.width * x.height >= y.width * y.height { + x + } else { + y + } + }) + .unwrap(); + + println!("Chosen format: {:?}", format); + + let mut stream = device.get_stream_handle_with_format(format).unwrap(); + log_device_settings(&device); + + let frame_guard = Arc::new(Mutex::new(MyFrame::default())); + let frame_cpy = frame_guard.clone(); + + let counter = Arc::new(AtomicUsize::new(0)); + let stream = stream + .start_stream( + move |frame_ref, count| { + let mut frame = frame_cpy.lock().unwrap(); + + *frame = MyFrame { + data: frame_ref.to_rgb().unwrap().to_bytes().to_owned(), + width: frame_ref.width(), + height: frame_ref.height(), + }; + + count.fetch_add(1, Ordering::SeqCst); + }, + counter.clone(), + ) + .expect("Could not start stream."); + + let sdl_ctx = sdl2::init().unwrap(); + let video_subsystem = sdl_ctx.video().unwrap(); + + let window = video_subsystem + .window("AVerMedia PW313 Web Camera", format.width, format.height) + .position_centered() + .build() + .unwrap(); + + let mut canvas = window + .into_canvas() + .present_vsync() + .accelerated() + .build() + .unwrap(); + let texture_creator = canvas.texture_creator(); + + 'main: loop { + for event in sdl_ctx.event_pump().unwrap().poll_iter() { + match event { + Event::Quit { .. } + | Event::KeyDown { + keycode: Some(Keycode::Escape), + .. + } => break 'main, + _ => {} + } + } + + let texture = do_thing(&frame_guard, &texture_creator); + match texture { + Some(thing) => { + canvas.copy(&thing, None, None).unwrap(); + canvas.present(); + } + None => {} + } + } +} + +fn do_thing<'a>( + guard: &'a Arc>, + creator: &'a TextureCreator, +) -> Option> { + let mut frame = guard.lock().ok()?; + let width = frame.width; + let height = frame.height; + + if !frame.data.is_empty() { + // Flip Image + let surface = Surface::from_data( + frame.data.as_mut_slice(), + width, + height, + width * (24 / 8), + PixelFormatEnum::RGB24, + ) + .unwrap(); + + Some(Texture::from_surface(&surface, creator).ok()?) + } else { + None + } + + // let surface = Surface::new(600, 800, PixelFormatEnum::RGB24).unwrap(); +} + +#[derive(Debug, Clone)] +struct MyFrame { + data: Vec, + width: u32, + height: u32, +} + +impl Default for MyFrame { + fn default() -> Self { + Self { + data: vec![], + width: 600, + height: 800, + } + } +} diff --git a/2020-11-02/pw313/src/old.rs b/2020-11-02/pw313/src/old.rs new file mode 100644 index 0000000..471aa33 --- /dev/null +++ b/2020-11-02/pw313/src/old.rs @@ -0,0 +1,185 @@ +use glium::{implement_vertex, uniform}; + +use std::error::Error; +use std::sync::{Arc, Mutex}; + +use glium::Surface; +use uvc::{Context, Frame}; + +fn frame_to_raw_image( + frame: &Frame, +) -> Result, Box> { + let new_frame = frame.to_rgb()?; + let data = new_frame.to_bytes(); + + let image = glium::texture::RawImage2d::from_raw_rgb( + data.to_vec(), + (new_frame.width(), new_frame.height()), + ); + + Ok(image) +} + +fn callback_frame_to_image( + frame: &Frame, + data: &mut Arc>>>, +) { + let image = frame_to_raw_image(frame); + match image { + Err(x) => println!("{:#?}", x), + Ok(x) => { + let mut data = Mutex::lock(&data).unwrap(); + *data = Some(x); + } + } +} + +fn main() { + let ctx = Context::new().expect("Could not create context"); + let dev = ctx + .find_device(None, None, None) + .expect("Could not find device"); + + let description = dev.description().unwrap(); + println!( + "Found device: Bus {:03} Device {:03} : ID {:04x}:{:04x} {} ({})", + dev.bus_number(), + dev.device_address(), + description.vendor_id, + description.product_id, + description.product.unwrap_or_else(|| "Unknown".to_owned()), + description + .manufacturer + .unwrap_or_else(|| "Unknown".to_owned()) + ); + + // Open multiple devices by enumerating: + // let mut list = ctx.devices().expect("Could not get devices"); + // let dev = list.next().expect("No device available"); + + let devh = dev.open().expect("Could not open device"); + + let format = devh + .get_preferred_format(|x, y| { + if x.fps >= y.fps && x.width * x.height >= y.width * y.height { + x + } else { + y + } + }) + .unwrap(); + + println!("Best format found: {:?}", format); + let mut streamh = devh.get_stream_handle_with_format(format).unwrap(); + + println!( + "Scanning mode: {:?}\nAuto-exposure mode: {:?}\nAuto-exposure priority: {:?}\nAbsolute exposure: {:?}\nRelative exposure: {:?}\nAboslute focus: {:?}\nRelative focus: {:?}", + devh.scanning_mode(), + devh.ae_mode(), + devh.ae_priority(), + devh.exposure_abs(), + devh.exposure_rel(), + devh.focus_abs(), + devh.focus_rel(), + ); + + let frame = Arc::new(Mutex::new(None)); + let _stream = streamh + .start_stream(callback_frame_to_image, frame.clone()) + .unwrap(); + + use glium::glutin; + let events_loop = glutin::event_loop::EventLoop::new(); + let window = glutin::window::WindowBuilder::new().with_title("Mirror"); + let context = glutin::ContextBuilder::new(); + let display = glium::Display::new(window, context, &events_loop).unwrap(); + + #[derive(Copy, Clone)] + pub struct QuadVertex { + pos: (f32, f32), + } + + implement_vertex!(QuadVertex, pos); + + let vertices: [QuadVertex; 4] = [ + QuadVertex { pos: (-1.0, -1.0) }, + QuadVertex { pos: (-1.0, 1.0) }, + QuadVertex { pos: (1.0, -1.0) }, + QuadVertex { pos: (1.0, 1.0) }, + ]; + + let indices: [u8; 6] = [0, 1, 2, 1, 3, 2]; + + let vertex_shader_source = r#" + #version 140 + in vec2 pos; + out vec2 v_position; + void main() { + v_position = (pos + 1.0)/2.0; + gl_Position = vec4(-pos.x, -pos.y, 0.0, 1.0); + } + "#; + + let fragment_shader_source = r#" + #version 140 + in vec2 v_position; + out vec4 colour; + uniform sampler2D u_image; + void main() { + vec2 pos = v_position; + colour = texture(u_image, pos); + } + "#; + + let vertices = glium::VertexBuffer::new(&display, &vertices).unwrap(); + let indices = glium::IndexBuffer::new( + &display, + glium::index::PrimitiveType::TrianglesList, + &indices, + ) + .unwrap(); + let program = + glium::Program::from_source(&display, vertex_shader_source, fragment_shader_source, None) + .unwrap(); + + let mut buffer: Option = None; + events_loop.run(move |event, _, control_flow| { + if let glutin::event::Event::WindowEvent { event, .. } = event { + if let glutin::event::WindowEvent::CloseRequested = event { + *control_flow = glutin::event_loop::ControlFlow::Exit; + return; + } + } + + let mut target = display.draw(); + target.clear_color(0.0, 0.0, 1.0, 1.0); + + let mut mutex = Mutex::lock(&frame).unwrap(); + + match mutex.take() { + None => { + // No new frame to render + } + Some(image) => { + let image = glium::texture::SrgbTexture2d::new(&display, image) + .expect("Could not use image"); + buffer = Some(image); + } + } + + if let Some(ref b) = buffer { + let uniforms = uniform! { u_image: b }; + target + .draw( + &vertices, + &indices, + &program, + &uniforms, + &Default::default(), + ) + .unwrap(); + } + + target.finish().unwrap(); + }); +} diff --git a/2021-03-04/password.py b/2021-03-04/password.py new file mode 100644 index 0000000..f785bb6 --- /dev/null +++ b/2021-03-04/password.py @@ -0,0 +1,36 @@ + +# Max's Original Solution +# password = input("Enter password: ") +# contain_digit = False +# length = len(password) + + +# while contain_digit == False and length < 8: +# for char in password: +# if char.isnumeric(): +# contain_digit = True +# break +# else: +# contain_digit = False +# password = input("Enter valid password: ") +# length = len(password) + + +password = input("Enter password: ") +valid = False + +while not valid: + # Check whether there's a digit + contains_digit = False + + for char in password: + if not contains_digit and char.isnumeric(): + contains_digit = True + + valid = contains_digit and len(password) > 8 + + if not valid: + password = input("Enter valid password: ") + + +print("Valid Password") diff --git a/2021-03-04/url_validate.py b/2021-03-04/url_validate.py new file mode 100644 index 0000000..d9d1f7a --- /dev/null +++ b/2021-03-04/url_validate.py @@ -0,0 +1,17 @@ +string = input("Gimme string: ") +valid = False +start = False +end = False + +while not valid: + if string[0:6] == "http://": + start = True + else: + start = False + if string[-4:] == ".com": + end = True + else: + end = False + valid = start and end + if not valid: + string = input("gimme good string: ") diff --git a/2021-03-10/zig-hello/build.zig b/2021-03-10/zig-hello/build.zig new file mode 100644 index 0000000..178a1c9 --- /dev/null +++ b/2021-03-10/zig-hello/build.zig @@ -0,0 +1,27 @@ +const Builder = @import("std").build.Builder; + +pub fn build(b: *Builder) void { + // Standard target options allows the person running `zig build` to choose + // what target to build for. Here we do not override the defaults, which + // means any target is allowed, and the default is native. Other options + // for restricting supported target set are available. + const target = b.standardTargetOptions(.{}); + + // Standard release options allow the person running `zig build` to select + // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. + const mode = b.standardReleaseOptions(); + + const exe = b.addExecutable("zig-hello", "src/main.zig"); + exe.setTarget(target); + exe.setBuildMode(mode); + exe.install(); + + const run_cmd = exe.run(); + run_cmd.step.dependOn(b.getInstallStep()); + if (b.args) |args| { + run_cmd.addArgs(args); + } + + const run_step = b.step("run", "Run the app"); + run_step.dependOn(&run_cmd.step); +} diff --git a/2021-03-10/zig-hello/src/main.zig b/2021-03-10/zig-hello/src/main.zig new file mode 100644 index 0000000..9b8cfbf --- /dev/null +++ b/2021-03-10/zig-hello/src/main.zig @@ -0,0 +1,6 @@ +const std = @import("std"); + +pub fn main() anyerror!void { + const test_num = 5; + std.log.info("All your codebase are belong to us.", .{}); +} diff --git a/2021-03-11/nichol-assignment/img/.gitkeep b/2021-03-11/nichol-assignment/img/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/2021-03-11/nichol-assignment/index.css b/2021-03-11/nichol-assignment/index.css new file mode 100644 index 0000000..16f9c63 --- /dev/null +++ b/2021-03-11/nichol-assignment/index.css @@ -0,0 +1,90 @@ +@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500&display=swap'); + +body { + margin: 0; + font-family: 'Roboto', Arial, Helvetica, sans-serif; +} + +div.container { + padding: 10px; + display: flex; + background-color: #e5e5e5; + width: 100vw; + height: 100vh; + flex-wrap: wrap; +} + +div.card-container { + flex: 1 0 calc(100vw / 6); + margin-bottom: 10px; + display: flex; + justify-content: center; +} + + +div.card { + background-color: white; + height: 500px; + width: 300px; + max-width: 350px; + border-radius: 5px; + box-shadow: 2px 2px 2px 2px rgba(0, 0, 0, 0.1); +} + +div.card-content { + display: flex; + flex-direction: column; + height: calc(500px / 2); +} + +div.card-content > p { + flex-grow: 1; + margin: 0; +} + +div.card-content > footer { + height: 2em; + letter-spacing: 3px; + color: #858585 +} + +div.card-content > footer > hr { + margin: 0; + color: #f5f5f5; +} + + +div.card > img { + border-radius: inherit; + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; + width: inherit; + height: calc(500px / 2); + object-fit: cover; +} + +div#card-content { + padding: 5px; +} + +div#card-content > h2 { + margin: 0; + font-weight: 500; +} + +div#card-content > p { + font-weight: 400; +} + +@media (max-width: 1000px) { + div.card-container { + flex: 1 0 calc(100vw / 3); + } +} + +@media (max-width: 600px) { + div.card-container { + flex: 1 0 100vw; + } +} + diff --git a/2021-03-11/nichol-assignment/index.html b/2021-03-11/nichol-assignment/index.html new file mode 100644 index 0000000..70ccbff --- /dev/null +++ b/2021-03-11/nichol-assignment/index.html @@ -0,0 +1,197 @@ + + + + + + + + + Nichol Assignment + + + +
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+
+
+ TWITTER +
+
+
+
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+
+
+ TWITTER +
+
+
+
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+
+
+ TWITTER +
+
+
+
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+
+
+ TWITTER +
+
+
+
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+
+
+ TWITTER +
+
+
+
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+
+
+ TWITTER +
+
+
+
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+
+
+ TWITTER +
+
+
+
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+
+
+ TWITTER +
+
+
+
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+
+
+ TWITTER +
+
+
+
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+
+
+ TWITTER +
+
+
+
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+
+
+ TWITTER +
+
+
+
+
+
+ A View of Harare from a nearby hill +
+

My Heading

+

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut + labore + et dolore magna al

+ +
+
+
+
+ + + \ No newline at end of file diff --git a/2021-03-16/zig8/build.zig b/2021-03-16/zig8/build.zig new file mode 100644 index 0000000..d1c0a58 --- /dev/null +++ b/2021-03-16/zig8/build.zig @@ -0,0 +1,29 @@ +const Builder = @import("std").build.Builder; + +pub fn build(b: *Builder) void { + // Standard target options allows the person running `zig build` to choose + // what target to build for. Here we do not override the defaults, which + // means any target is allowed, and the default is native. Other options + // for restricting supported target set are available. + const target = b.standardTargetOptions(.{}); + + // Standard release options allow the person running `zig build` to select + // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. + const mode = b.standardReleaseOptions(); + + const exe = b.addExecutable("zig8", "src/main.zig"); + exe.setTarget(target); + exe.setBuildMode(mode); + exe.linkSystemLibrary("SDL2"); + exe.linkSystemLibrary("c"); + exe.install(); + + const run_cmd = exe.run(); + run_cmd.step.dependOn(b.getInstallStep()); + if (b.args) |args| { + run_cmd.addArgs(args); + } + + const run_step = b.step("run", "Run the app"); + run_step.dependOn(&run_cmd.step); +} diff --git a/2021-03-16/zig8/src/cpu.zig b/2021-03-16/zig8/src/cpu.zig new file mode 100644 index 0000000..2ac98a7 --- /dev/null +++ b/2021-03-16/zig8/src/cpu.zig @@ -0,0 +1,203 @@ +const std = @import("std"); +const expect = @import("std").testing.expect; +const panic = @import("std").debug.panic; +const Dir = @import("std").fs.Dir; +const Instruction = @import("instructions.zig").Instruction; +const InstrType = @import("instructions.zig").Type; +const draw_sprite = @import("display.zig").draw_sprite; +const Display = @import("display.zig").Display; +const Point = @import("display.zig").Point; + +pub const Cpu = struct { + i: u16, + pc: u16, + sp: u16, + v: [16]u8, + stack: [16]u16, + memory: [4096]u8, + disp: Display, +}; + + +pub fn fetch(cpu: *Cpu) u16 { + const high: u16 = cpu.memory[cpu.pc]; + const low: u16 = cpu.memory[cpu.pc + 1]; + + cpu.pc += 2; + + return high << 8 | low; +} + +pub fn decode(cpu: *Cpu, word: u16) ?Instruction { + const nib1: u4 = @intCast(u4, (word & 0xF000) >> 12); + const nib2: u4 = @intCast(u4, (word & 0x0F00) >> 8); + const nib3: u4 = @intCast(u4, (word & 0x00F0) >> 4); + const nib4: u4 = @intCast(u4, (word & 0x000F) >> 0); + + + if (nib1 == 0x0) { + // nib2 is 0x0, nib3 is 0xE + + if (nib4 == 0) { + // 0x00E0 | CLS + return Instruction.CLS; + } + + if (nib4 == 0xE) { + // 0x00EE | RET + return Instruction.RET; + } + } else if (nib1 == 0x1) { + // 0x1nnn | JP addr + + const addr = calc_u12(nib2, nib3, nib4); + return Instruction { .JP = addr }; + } else if (nib1 == 0x2) { + // 0x2nnn | CALL addr + + const addr = calc_u12(nib2, nib3, nib4); + return Instruction { .CALL = addr }; + } else if (nib1 == 0x3) { + // 0x3xkk | SE Vx, u8 + + return Instruction { .SE_3 = .{ .x = nib2, .kk = calc_u8(nib3, nib4) }}; + } else if (nib1 == 0x6) { + // 0x6xkk | LD Vx, u8 + + return Instruction { .LD_6 = .{ .x = nib2, .kk = calc_u8(nib3, nib4) }}; + } else if(nib1 == 0x7) { + // 0x7xkk | LD Vx, kk + + return Instruction { .ADD_7 = .{ .x = nib2, .kk = calc_u8(nib3, nib4) }}; + } else if (nib1 == 0xA) { + // 0xAnnn | LD I, addr + const addr = calc_u12(nib2, nib3, nib4); + return Instruction { .LD_I = addr }; + } else if (nib1 == 0xD) { + // 0xDxyn | DRW Vx, Vy, n + return Instruction {.DRW = .{ .x = nib2, .y = nib3, .n = nib4 }}; + } + + + return null; +} + +pub fn execute(cpu: *Cpu, instr: Instruction) void { + switch (instr) { + .CLS => std.debug.print("CLS\n", .{}), + .RET => { + std.debug.print("RET\n", .{}); + + cpu.pc = cpu.stack[cpu.sp]; + cpu.sp -= 1; + }, + .JP => |addr| { + std.debug.print("JP 0x{X:}\n", .{ addr }); + + cpu.pc = addr; + }, + .CALL => |addr| { + std.debug.print("CALL 0x{X:}\n", .{ addr }); + + cpu.sp += 1; + cpu.stack[cpu.sp] = cpu.pc; + cpu.pc = addr; + }, + .SE_3 => |args| { + const x = args.x; + const kk = args.kk; + std.debug.print("SE V{}, 0x{X:}\n", .{ x, kk }); + + if (cpu.v[x] != kk) { + cpu.pc += 2; + } + }, + .LD_6 => |args| { + const x = args.x; + const kk = args.kk; + std.debug.print("LD V{} 0x{X:}\n", .{ x, kk }); + + cpu.v[x] = kk; + }, + .LD_I => |addr| { + std.debug.print("LD I, 0x{X:}\n", .{ addr }); + cpu.i = addr; + }, + .DRW => |args| { + const x = args.x; + const y = args.y; + const n = args.n; + std.debug.print("DRW V{}, V{}, 0x{X:}\n", .{ x, y, n }); + + const draw_pos: Point = .{ .x = cpu.v[x], .y = cpu.v[y] }; + const sprite_data = cpu.memory[cpu.i..(cpu.i + n)]; + + // Draw Sprite + const collision = draw_sprite(&cpu.disp, &draw_pos, &sprite_data); + + cpu.v[0xF] = if (collision) 1 else 0; + // Request Redraw + }, + .ADD_7 => |args| { + const x = args.x; + const kk = args.kk; + std.debug.print("ADD V{}, 0x{X:}\n", .{ x, kk }); + + cpu.v[x] = cpu.v[x] + kk; + } + } +} + +fn load_rom(cpu: *Cpu, buf: []u8) void { + var mem_index: usize = 0x200; + + for (buf) |byte| { + cpu.memory[mem_index] = byte; + mem_index += 1; + } +} + +pub fn load_rom_path(cpu: *Cpu, path: []const u8) !void { + var alloc = std.heap.page_allocator; + + const file = try std.fs.cwd().openFile(path, .{ .read = true }); + defer file.close(); + + const file_size = try file.getEndPos(); + const rom_buf = try file.readToEndAlloc(alloc, file_size); + + load_rom(cpu, rom_buf); +} + +pub fn cycle(cpu: *Cpu) void { + const opcode = fetch(cpu); + const maybe_instr = decode(cpu, opcode); + + if (maybe_instr) |instr| { + execute(cpu, instr); + } else { + panic("Unknown Opcode: 0x{X:}", . { opcode }); + } +} + +fn calc_u12(nib2: u4, nib3: u4, nib4: u4) u12 { + return @as(u12, nib2) << 8 | @as(u12, nib3) << 4 | @as(u12, nib4); +} + +fn calc_u8(nib_a: u4, nib_b: u4) u8 { + return @as(u8, nib_a) << 4 | @as(u8, nib_b); +} + +test "calc_u12 works" { + const left: u12 = 0xABC; + const right: u12 = calc_u12(0xA, 0xB, 0xC); + + expect(left == right); +} + +test "calc_u8 works" { + const left: u8 = 0xAB; + const right: u12 = calc_u8(0xA, 0xB); + + expect(left == right); +} diff --git a/2021-03-16/zig8/src/display.zig b/2021-03-16/zig8/src/display.zig new file mode 100644 index 0000000..57b09dc --- /dev/null +++ b/2021-03-16/zig8/src/display.zig @@ -0,0 +1,56 @@ +const DISPLAY_WIDTH: usize = 64; +const DISPLAY_HEIGHT: usize = 32; +const std = @import("std"); + +pub const Point = struct { + x: u16, + y: u16, +}; + + +pub const Display = struct { + buf: [DISPLAY_HEIGHT * DISPLAY_WIDTH]u8, + + + pub fn new() Display { + return .{ + .buf = [_]u8{0x00} ** (DISPLAY_HEIGHT * DISPLAY_WIDTH) + }; + } +}; + +pub fn clear(disp: *Display) void { + disp.buf = u8[DISPLAY_WIDTH * DISPLAY_HEIGHT]{0x00}; +} + +pub fn draw_sprite(disp: *Display, pos: *const Point, data: *const []u8) bool { + var set_vf: bool = false; + + for (data.*) |byte, y_offset| { + var offset_count: u8 = 0; + + while (offset_count < 8) : (offset_count += 1) { + const x_bit_offset = @intCast(u3, offset_count); + const x = @intCast(u8, pos.x + (7 - x_bit_offset)); + const y = @intCast(u8, pos.y + y_offset); + + + const temp = (byte >> x_bit_offset) & 0x01; + const bit = @intCast(u1, temp); + // const bit = @as(u1, temp); + + const i = DISPLAY_WIDTH * y + x; + + if (i >= disp.buf.len) break; + + if (bit == 0x1 and disp.buf[i] == 0x01) { + set_vf = true; + } + + disp.buf[i] ^= bit; + } + } + + + return set_vf; +} \ No newline at end of file diff --git a/2021-03-16/zig8/src/instructions.zig b/2021-03-16/zig8/src/instructions.zig new file mode 100644 index 0000000..f0fa619 --- /dev/null +++ b/2021-03-16/zig8/src/instructions.zig @@ -0,0 +1,12 @@ + +pub const Instruction = union(enum) { + CLS: void, // 0x00E0 + RET: void, // 0x00EE + JP: u12, // 0x1nnn + CALL: u12, // 0x2nnn + SE_3: struct { x: u4, kk: u8 }, // 0x3xkk + LD_6: struct {x: u4, kk: u8}, // 0x6xkk + LD_I: u12, // 0xAnnn + DRW: struct { x: u4, y: u4, n: u4 }, // 0xDxyn + ADD_7: struct { x: u4, kk: u8 } // 0x7xkk +}; \ No newline at end of file diff --git a/2021-03-16/zig8/src/main.zig b/2021-03-16/zig8/src/main.zig new file mode 100644 index 0000000..d72a97f --- /dev/null +++ b/2021-03-16/zig8/src/main.zig @@ -0,0 +1,107 @@ +const std = @import("std"); +const cpu = @import("cpu.zig"); +const Display = @import("display.zig").Display; +const c = @cImport({ + @cInclude("SDL2/SDL.h"); +}); +const assert = @import("std").debug.assert; + +// See https://github.com/zig-lang/zig/issues/565 +// SDL_video.h:#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) +// SDL_video.h:#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) +// SDL_video.h:#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000u +const SDL_WINDOWPOS_UNDEFINED = @bitCast(c_int, c.SDL_WINDOWPOS_UNDEFINED_MASK); + +extern fn SDL_PollEvent(event: *c.SDL_Event) c_int; + +// SDL_RWclose is fundamentally unrepresentable in Zig, because `ctx` is +// evaluated twice. One could make the case that this is a bug in SDL, +// especially since the docs list a real function prototype that would not +// have this double-evaluation of the parameter. +// If SDL would instead of a macro use a static inline function, +// it would resolve the SDL bug as well as make the function visible to Zig +// and to debuggers. +// SDL_rwops.h:#define SDL_RWclose(ctx) (ctx)->close(ctx) +inline fn SDL_RWclose(ctx: [*]c.SDL_RWops) c_int { + return ctx[0].close.?(ctx); +} + +pub fn main() !void { + // Initialize SDL2 + if (c.SDL_Init(c.SDL_INIT_VIDEO) != 0) { + c.SDL_Log("Unable to initialize SDL: %s", c.SDL_GetError()); + return error.SDLInitializationFailed; + } + defer c.SDL_Quit(); + + // Create Screen (Maybe introduce scaling somehow?) + const screen = c.SDL_CreateWindow("Zig8", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 640, 320, c.SDL_WINDOW_OPENGL) orelse + { + c.SDL_Log("Unable to create window: %s", c.SDL_GetError()); + return error.SDLInitializationFailed; + }; + defer c.SDL_DestroyWindow(screen); + + // Create Renderer + const renderer = c.SDL_CreateRenderer(screen, -1, c.SDL_RENDERER_ACCELERATED) orelse { + c.SDL_Log("Unable to create renderer: %s", c.SDL_GetError()); + return error.SDLInitializationFailed; + }; + defer c.SDL_DestroyRenderer(renderer); + + // Create RGBA Texture + const texture = c.SDL_CreateTexture(renderer, c.SDL_PIXELFORMAT_RGBA8888, c.SDL_TEXTUREACCESS_STREAMING, 64, 32) orelse { + c.SDL_Log("Unable to create texture: %s", c.SDL_GetError()); + return error.SDLInitializationFailed; + }; + defer c.SDL_DestroyTexture(texture); + + // Initialize CHIP-8 Emulator + var chip8 = cpu.Cpu { + .i = 0x00, + .pc = 0x0200, + .sp = 0x00, + .v = [_]u8{0x0} ** 16, + .stack = [_]u16{0x0} ** 16, + .memory = [_]u8{0x0} ** 4096, + .disp = Display.new(), + }; + + var path = "./bin/IBM Logo.ch8"; + + // Load Game ROM into CHIP-8 Emulator + try cpu.load_rom_path(&chip8, path); + + + // Create Pixel Buffer (Temporary) + const buf_size = 64 * 32 * @sizeOf(u32); + var pixels: [buf_size]u8 = [_]u8{255} ** buf_size; + + // Render + var quit = false; + while (!quit) { + + var buf_ptr: [*c]?*c_void = &@ptrCast(?*c_void, &pixels[0]); + + _ = c.SDL_LockTexture(texture, null, buf_ptr, 64 * @sizeOf(u32)); + c.SDL_UnlockTexture(texture); + + var event: c.SDL_Event = undefined; + while (SDL_PollEvent(&event) != 0) { + switch (event.@"type") { + c.SDL_QUIT => { + quit = true; + }, + else => {}, + } + } + + _ = c.SDL_RenderClear(renderer); + _ = c.SDL_RenderCopy(renderer, texture, null, null); + c.SDL_RenderPresent(renderer); + + cpu.cycle(&chip8); + + c.SDL_Delay(17); + } +} \ No newline at end of file