diff --git a/.gitignore b/.gitignore index 2a685f7..284a6a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ repbuild/target ableos/target aos_wasm_stress_test/target -facepalm/target \ No newline at end of file +facepalm/target +shadeable/target \ No newline at end of file diff --git a/ableos/Cargo.lock b/ableos/Cargo.lock index ab715c3..3e64378 100644 --- a/ableos/Cargo.lock +++ b/ableos/Cargo.lock @@ -33,9 +33,11 @@ dependencies = [ "lazy_static", "linked_list_allocator", "lliw", + "log", "pic8259", "pretty-hex", "qoi_rs", + "shadeable", "spin", "uart_16550", "vga", @@ -44,6 +46,18 @@ dependencies = [ "x86_64", ] +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "const-random", + "getrandom", + "once_cell", + "version_check", +] + [[package]] name = "autocfg" version = "1.0.1" @@ -68,6 +82,12 @@ version = "0.9.20" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6b0718f186cd449b21f044683933284ed90fb83f3e13949ff0e03b0b6f02e38e" +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + [[package]] name = "conquer-once" version = "0.3.2" @@ -83,11 +103,48 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e763eef8846b13b380f37dfecda401770b0ca4e56e95170237bd7c25c7db3582" +[[package]] +name = "const-random" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f590d95d011aa80b063ffe3253422ed5aa462af4e9867d43ce8337562bac77c4" +dependencies = [ + "const-random-macro", + "proc-macro-hack", +] + +[[package]] +name = "const-random-macro" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "615f6e27d000a2bffbc7f2f6a8669179378fa27ee4d0a509e985dfc0a7defb40" +dependencies = [ + "getrandom", + "lazy_static", + "proc-macro-hack", + "tiny-keccak", +] + +[[package]] +name = "core-error" +version = "0.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efcdb2972eb64230b4c50646d8498ff73f5128d196a90c7236eec4cbe8619b8f" +dependencies = [ + "version_check", +] + [[package]] name = "cpuio" version = "0.3.0" source = "git+https://github.com/anyusernameworks/cpuio.git#3908ecab79df80670ee1c5121870fc131f07627b" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "downcast-rs" version = "1.2.0" @@ -108,6 +165,26 @@ version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "875488b8711a968268c7cf5d139578713097ca4635a76044e8fe8eedf831d07e" +[[package]] +name = "getrandom" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + [[package]] name = "lazy_static" version = "1.4.0" @@ -117,6 +194,12 @@ dependencies = [ "spin", ] +[[package]] +name = "libc" +version = "0.2.112" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" + [[package]] name = "libm" version = "0.2.1" @@ -147,12 +230,27 @@ dependencies = [ "scopeguard", ] +[[package]] +name = "log" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +dependencies = [ + "cfg-if", +] + [[package]] name = "memory_units" version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "71d96e3f3c0b6325d8ccd83c33b28acb183edcb6c67938ba104ec546854b0882" +[[package]] +name = "no-std-compat" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" + [[package]] name = "num-integer" version = "0.1.44" @@ -181,8 +279,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" dependencies = [ "autocfg", + "libm", ] +[[package]] +name = "once_cell" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" + [[package]] name = "owned_ttf_parser" version = "0.14.0" @@ -213,18 +318,92 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc5c99d529f0d30937f6f4b8a86d988047327bb88d04d2c4afc356de74722131" +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + [[package]] name = "qoi_rs" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f7ac44f12a8cec33865a699b2257e8454499fb4c3b13835710ff35c66bb65669" +[[package]] +name = "quote" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rhai" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c7433068977c56619bf2b7831da26eb986d0645fe56f2ad9357eda7ae4c435e" +dependencies = [ + "ahash", + "core-error", + "instant", + "libm", + "no-std-compat", + "num-traits", + "rhai_codegen", + "smallvec", + "smartstring", +] + +[[package]] +name = "rhai_codegen" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e02d33d76a7aa8ec72ac8298d5b52134fd2dff77445ada0c65f6f8c40d8f2931" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "scopeguard" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" +[[package]] +name = "shadeable" +version = "0.1.0" +dependencies = [ + "rhai", +] + +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" + +[[package]] +name = "smartstring" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31aa6a31c0c2b21327ce875f7e8952322acfcfd0c27569a6e18a647281352c9b" +dependencies = [ + "static_assertions", +] + [[package]] name = "spin" version = "0.5.2" @@ -240,6 +419,32 @@ dependencies = [ "lock_api", ] +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "syn" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "ttf-parser" version = "0.14.0" @@ -256,6 +461,18 @@ dependencies = [ "x86_64", ] +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "vga" version = "0.2.7" @@ -282,6 +499,12 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e4c2dbd44eb8b53973357e6e207e370f0c1059990df850aca1eca8947cf464f0" +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" + [[package]] name = "wasmi" version = "0.9.1" diff --git a/ableos/Cargo.toml b/ableos/Cargo.toml index 3b56350..054e5c7 100644 --- a/ableos/Cargo.toml +++ b/ableos/Cargo.toml @@ -32,6 +32,11 @@ qoi_rs = "*" spin = "0.5.2" vga = "*" pretty-hex = "0.2.1" +log= "*" +[dependencies.shadeable] + +path = "../shadeable" + [dependencies.ab_glyph] diff --git a/ableos/assets/fonts/Roboto/LICENSE.txt b/ableos/assets/fonts/Roboto/LICENSE.txt deleted file mode 100644 index 75b5248..0000000 --- a/ableos/assets/fonts/Roboto/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/ableos/assets/fonts/Roboto/Roboto-Black.ttf b/ableos/assets/fonts/Roboto/Roboto-Black.ttf deleted file mode 100644 index 43a00e0..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-Black.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Roboto/Roboto-BlackItalic.ttf b/ableos/assets/fonts/Roboto/Roboto-BlackItalic.ttf deleted file mode 100644 index 5082cdc..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-BlackItalic.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Roboto/Roboto-Bold.ttf b/ableos/assets/fonts/Roboto/Roboto-Bold.ttf deleted file mode 100644 index 3742457..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-Bold.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Roboto/Roboto-BoldItalic.ttf b/ableos/assets/fonts/Roboto/Roboto-BoldItalic.ttf deleted file mode 100644 index e85e7fb..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-BoldItalic.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Roboto/Roboto-Italic.ttf b/ableos/assets/fonts/Roboto/Roboto-Italic.ttf deleted file mode 100644 index c9df607..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-Italic.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Roboto/Roboto-Light.ttf b/ableos/assets/fonts/Roboto/Roboto-Light.ttf deleted file mode 100644 index 0e97751..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-Light.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Roboto/Roboto-LightItalic.ttf b/ableos/assets/fonts/Roboto/Roboto-LightItalic.ttf deleted file mode 100644 index 3ad14fa..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-LightItalic.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Roboto/Roboto-Medium.ttf b/ableos/assets/fonts/Roboto/Roboto-Medium.ttf deleted file mode 100644 index e89b0b7..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-Medium.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Roboto/Roboto-MediumItalic.ttf b/ableos/assets/fonts/Roboto/Roboto-MediumItalic.ttf deleted file mode 100644 index a5a41d3..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-MediumItalic.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Roboto/Roboto-Regular.ttf b/ableos/assets/fonts/Roboto/Roboto-Regular.ttf deleted file mode 100644 index 3d6861b..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-Regular.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Roboto/Roboto-Thin.ttf b/ableos/assets/fonts/Roboto/Roboto-Thin.ttf deleted file mode 100644 index 7d084ae..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-Thin.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Roboto/Roboto-ThinItalic.ttf b/ableos/assets/fonts/Roboto/Roboto-ThinItalic.ttf deleted file mode 100644 index c173389..0000000 Binary files a/ableos/assets/fonts/Roboto/Roboto-ThinItalic.ttf and /dev/null differ diff --git a/ableos/assets/fonts/Untitled1.ttf b/ableos/assets/fonts/Untitled1.ttf index 8c97b1f..86f77ce 100644 Binary files a/ableos/assets/fonts/Untitled1.ttf and b/ableos/assets/fonts/Untitled1.ttf differ diff --git a/ableos/notes/UNICODE_PRIV.md b/ableos/notes/UNICODE_PRIV.md new file mode 100644 index 0000000..f379d01 --- /dev/null +++ b/ableos/notes/UNICODE_PRIV.md @@ -0,0 +1 @@ +start custom unicode at E100 \ No newline at end of file diff --git a/ableos/src/arch/x86_64/init.rs b/ableos/src/arch/x86_64/init.rs index 42d4c4d..a842677 100644 --- a/ableos/src/arch/x86_64/init.rs +++ b/ableos/src/arch/x86_64/init.rs @@ -1,10 +1,14 @@ #![allow(clippy::print_literal)] -use { - super::{gdt, interrupts}, - crate::info, -}; +use crate::logger; + +use super::{gdt, interrupts}; pub fn init() { + let result = logger::init(); + match result { + Ok(_) => {} + Err(err) => error!("{}", err), + } gdt::init(); interrupts::init_idt(); unsafe { interrupts::PICS.lock().initialize() }; diff --git a/ableos/src/arch/x86_64/mod.rs b/ableos/src/arch/x86_64/mod.rs index 99b201a..e91890c 100644 --- a/ableos/src/arch/x86_64/mod.rs +++ b/ableos/src/arch/x86_64/mod.rs @@ -1,4 +1,4 @@ -use crate::{arch::drivers::allocator, info}; +use crate::arch::drivers::allocator; use bootloader::{entry_point, BootInfo}; use x86_64::{ instructions::hlt, diff --git a/ableos/src/experiments/mail.rs b/ableos/src/experiments/mail.rs index 3778b6b..6470643 100644 --- a/ableos/src/experiments/mail.rs +++ b/ableos/src/experiments/mail.rs @@ -1,5 +1,4 @@ #![allow(dead_code)] -use crate::trace; // TODO: Evaluate variable sized mailboxes pub struct MailBoxes { diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index 0661952..19b0959 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -1,12 +1,18 @@ #![allow(clippy::empty_loop)] +use alloc::{fmt, format}; +use shadeable::rhai_test; use vga::{colors::Color16, writers::GraphicsWriter}; use crate::{ + logger, relib::network::socket::SocketReturns, + unicode_utils, vga_e::{self, VGAE}, }; +use log::*; + use { crate::{ arch::{drivers::graphics::GraphicsBuffer, init, sloop}, @@ -17,7 +23,7 @@ use { }, // log::LOG_STATE, relib::math::rand::RAND_HANDLE, - relib::network::socket::{Socket, SOCKETS}, + relib::network::socket::Socket, scheduler::{test_fn, Thread, ThreadList}, }, alloc::{ @@ -45,6 +51,8 @@ lazy_static! { pub fn kernel_main() -> ! { init::init(); + log::set_max_level(LevelFilter::Info); + { let mut a_thread = Thread::new(); @@ -97,11 +105,25 @@ pub fn kernel_main() -> ! { println!("$GREEN$able$RESET$@$LIGHTBLUE$stAble$ $RED$->$RESET$"); - VGAE.lock().clear_screen(Color16::Black); + if false { + VGAE.lock().clear_screen(Color16::Black); - for x in "μkernel".chars().enumerate() { - vga_e::draw_char(x.1, x.0); + let xyz = format!("\u{e100}ableOS"); + + for x in xyz.chars().enumerate() { + vga_e::draw_char(x.1, x.0); + } } + for y in 0..480 { + for x in 0..640 { + // info!("{x}"); + VGAE.lock().set_pixel(x, y, Color16::Blue) + } + } + + let _ = rhai_test(); + + println!("hi"); // vga_e::test_it_fucko(); // stack_overflow(); diff --git a/ableos/src/lib.rs b/ableos/src/lib.rs index c93ab6d..defb8a3 100644 --- a/ableos/src/lib.rs +++ b/ableos/src/lib.rs @@ -28,19 +28,28 @@ pub mod arch; #[macro_use] pub mod print; +/* #[macro_use] pub mod log; +*/ + +// pub use log2; + +#[macro_use] +pub extern crate log; pub mod allocator; pub mod driver_traits; pub mod experiments; pub mod keyboard; pub mod kmain; +pub mod logger; pub mod panic; pub mod relib; pub mod scheduler; pub mod wasm; +mod unicode_utils; pub mod utils; pub extern crate alloc; diff --git a/ableos/src/log.rs b/ableos/src/log.rs deleted file mode 100644 index 2a76199..0000000 --- a/ableos/src/log.rs +++ /dev/null @@ -1,142 +0,0 @@ -pub trait Log { - fn debug(val: &str); - fn error(val: &str); - fn info(val: &str); - fn trace(val: &str); -} -pub struct LogState { - pub log_to_serial: bool, - pub log_to_screen: bool, - - pub debug: bool, - pub error: bool, - pub info: bool, - pub trace: bool, -} - -lazy_static::lazy_static! { - pub static ref LOG_STATE: Mutex = spin::Mutex::new(LogState { - log_to_screen: true, - log_to_serial: true, - debug: true, - error: true, - info: true, - trace: true, - }); -} - -use crate::serial_println; -use lliw::{Fg, Reset}; -use spin::Mutex; -pub struct ANSISerialLogger; -impl Log for ANSISerialLogger { - fn debug(val: &str) { - if LOG_STATE.lock().log_to_serial { - serial_println!( - "[{}Debug{}][{}FakeTempTime{}] {}", - Fg::Blue, - Reset, - Fg::Green, - Reset, - val - ); - } - if LOG_STATE.lock().log_to_screen { - // NOTE: LIGHTBLUE because gamma color theory probably - println!( - "[$LIGHTBLUE$Debug$RESET$][$GREEN$FakeTempTime$RESET$] {}", - val - ); - } - } - fn error(val: &str) { - if LOG_STATE.lock().log_to_serial { - serial_println!( - "[{}Error{}][{}FakeTempTime{}] {}", - Fg::Red, - Reset, - Fg::Green, - Reset, - val - ); - } - - if LOG_STATE.lock().log_to_screen { - println!("[$RED$Error$RESET$][$GREEN$FakeTempTime$RESET$] {}", val); - } - } - fn info(val: &str) { - if LOG_STATE.lock().log_to_serial { - serial_println!( - "[{}Info{} ][{}FakeTempTime{}] {}", - Fg::LightWhite, - Reset, - Fg::Green, - Reset, - val - ); - } - if LOG_STATE.lock().log_to_screen { - println!( - "[$LIGHTGRAY$Info$RESET$ ][$GREEN$FakeTempTime$RESET$] {}", - val - ); - } - } - fn trace(val: &str) { - if LOG_STATE.lock().log_to_serial { - serial_println!( - "[{}Trace{}][{}FakeTempTime{}] {}", - Fg::Yellow, - Reset, - Fg::Green, - Reset, - val - ); - } - if LOG_STATE.lock().log_to_screen { - println!("[$YELLOW$Trace$RESET$][$GREEN$FakeTempTime$RESET$] {}", val); - } - } -} - -#[macro_export] -macro_rules! debug { - ($($arg:tt)*) => ({ - if $crate::log::LOG_STATE.lock().debug{ - use crate::log::Log; - - let _ = crate::log::ANSISerialLogger::debug(&alloc::format!($($arg)*)); - } - }) -} - -#[macro_export] -macro_rules! error { - ($($arg:tt)*) => ({ - if $crate::log::LOG_STATE.lock().error{ - use crate::log::Log; - crate::log::ANSISerialLogger::error(&alloc::format!($($arg)*)); - } - }); -} - -#[macro_export] -macro_rules! info { - ($($arg:tt)*) => ({ - if $crate::log::LOG_STATE.lock().info{ - use crate::log::Log; - crate::log::ANSISerialLogger::info(&alloc::format!($($arg)*)); - } - }) -} - -#[macro_export] -macro_rules! trace { - ($($arg:tt)*) => ({ - if $crate::log::LOG_STATE.lock().trace{ - use crate::log::Log; - crate::log::ANSISerialLogger::trace(&alloc::format!($($arg)*)); - } - }) -} diff --git a/ableos/src/logger.rs b/ableos/src/logger.rs new file mode 100644 index 0000000..b093105 --- /dev/null +++ b/ableos/src/logger.rs @@ -0,0 +1,52 @@ +use crate::serial_println; +use lliw::{Fg, Reset}; +pub use log::{debug, info, trace, warn}; +use log::{Level, Metadata, Record}; + +struct SimpleLogger; + +impl log::Log for SimpleLogger { + fn enabled(&self, metadata: &Metadata) -> bool { + metadata.level() <= Level::Trace + } + + fn log(&self, record: &Record) { + if self.enabled(record.metadata()) { + let color; // = (Fg::Reset, "$GREEN$"); + + match record.level() { + log::Level::Error => color = (Fg::Red, "$RED$"), + log::Level::Warn => color = (Fg::LightYellow, "$LIGHTYELLOW$"), + log::Level::Info => color = (Fg::LightWhite, "$LIGHTGRAY$"), + log::Level::Debug => color = (Fg::Blue, "$BLUE$"), + log::Level::Trace => color = (Fg::Yellow, "$YELLOW$"), + } + + println!( + "[{}{}$RESET$][$GREEN$FakeTempTime$RESET$] {}", + color.1, + record.level(), + record.args() + ); + serial_println!( + "[{}{}{}][{}FakeTempTime{}] {}", + color.0, + record.level(), + Fg::Reset, + Fg::Green, + Reset, + record.args() + ); + } + } + + fn flush(&self) {} +} + +use log::{LevelFilter, SetLoggerError}; + +static LOGGER: SimpleLogger = SimpleLogger; + +pub fn init() -> Result<(), SetLoggerError> { + log::set_logger(&LOGGER).map(|()| log::set_max_level(LevelFilter::Trace)) +} diff --git a/ableos/src/unicode_utils.rs b/ableos/src/unicode_utils.rs new file mode 100644 index 0000000..fb9d21f --- /dev/null +++ b/ableos/src/unicode_utils.rs @@ -0,0 +1,2 @@ +pub const POWER_SIGN: &str = "\u{23FB}"; +pub const CONSOLE: &str = "\u{E795}"; diff --git a/ableos/src/vga_e.rs b/ableos/src/vga_e.rs index 30de4d5..e3d2e53 100644 --- a/ableos/src/vga_e.rs +++ b/ableos/src/vga_e.rs @@ -15,9 +15,6 @@ lazy_static::lazy_static! { }; } -pub const FONT: &[u8; 1279380] = - include_bytes!("../../ableos/assets/fonts/MesloLGS NF Regular.ttf"); - pub fn test_it_fucko() { let mode = Graphics640x480x16::new(); mode.set_mode(); @@ -51,31 +48,32 @@ pub trait GraphicsAPI { } pub struct Buffer { - label: String, - resolution: (u64, u64), + pub label: String, + pub resolution: (u64, u64), } // #[deprecated(note = "Deprecated because you should use the damn graphics api")] pub fn draw_char(character: char, offset: usize) { let mode = *VGAE.lock(); - let font = FontRef::try_from_slice(FONT).unwrap(); + let font = FontRef::try_from_slice(include_bytes!( + "../../ableos/assets/fonts/MesloLGS NF Regular.ttf" + )) + .unwrap(); // Get a glyph for 'q' with a scale & position. - let q_glyph: Glyph = font.glyph_id(character).with_scale(100.0); - - // Draw it. + let q_glyph: Glyph = font.glyph_id(character).with_scale(20.0); + // Draw it. if let Some(q) = font.outline_glyph(q_glyph) { + let scale = q.glyph().scale; q.draw(|x, y, c| { - // info!("{}", c); - if c > 0.2 { mode.set_pixel( - x as usize + (offset * 50), + x as usize + (offset * scale.y as usize / 2), // y as usize, - Color16::LightBlue, + Color16::LightGreen, ); } }); diff --git a/shadeable/.config/cargo.toml b/shadeable/.config/cargo.toml new file mode 100644 index 0000000..0789674 --- /dev/null +++ b/shadeable/.config/cargo.toml @@ -0,0 +1,4 @@ + +[unstable] +build-std = ["core", "compiler_builtins", "alloc"] +build-std-features = ["compiler-builtins-mem"] \ No newline at end of file diff --git a/shadeable/Cargo.lock b/shadeable/Cargo.lock new file mode 100644 index 0000000..88cd017 --- /dev/null +++ b/shadeable/Cargo.lock @@ -0,0 +1,242 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "const-random", + "getrandom", + "once_cell", + "version_check", +] + +[[package]] +name = "autocfg" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "const-random" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f590d95d011aa80b063ffe3253422ed5aa462af4e9867d43ce8337562bac77c4" +dependencies = [ + "const-random-macro", + "proc-macro-hack", +] + +[[package]] +name = "const-random-macro" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "615f6e27d000a2bffbc7f2f6a8669179378fa27ee4d0a509e985dfc0a7defb40" +dependencies = [ + "getrandom", + "lazy_static", + "proc-macro-hack", + "tiny-keccak", +] + +[[package]] +name = "core-error" +version = "0.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "efcdb2972eb64230b4c50646d8498ff73f5128d196a90c7236eec4cbe8619b8f" +dependencies = [ + "version_check", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "getrandom" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "418d37c8b1d42553c93648be529cb70f920d3baf8ef469b74b9638df426e0b4c" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.112" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b03d17f364a3a042d5e5d46b053bbbf82c92c9430c592dd4c064dc6ee997125" + +[[package]] +name = "libm" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7d73b3f436185384286bd8098d17ec07c9a7d2388a6599f824d8502b529702a" + +[[package]] +name = "no-std-compat" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b93853da6d84c2e3c7d730d6473e8817692dd89be387eb01b94d7f108ecb5b8c" + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "once_cell" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5" + +[[package]] +name = "proc-macro-hack" +version = "0.5.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" + +[[package]] +name = "proc-macro2" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" +dependencies = [ + "unicode-xid", +] + +[[package]] +name = "quote" +version = "1.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47aa80447ce4daf1717500037052af176af5d38cc3e571d9ec1c7353fc10c87d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rhai" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c7433068977c56619bf2b7831da26eb986d0645fe56f2ad9357eda7ae4c435e" +dependencies = [ + "ahash", + "core-error", + "instant", + "libm", + "no-std-compat", + "num-traits", + "rhai_codegen", + "smallvec", + "smartstring", +] + +[[package]] +name = "rhai_codegen" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e02d33d76a7aa8ec72ac8298d5b52134fd2dff77445ada0c65f6f8c40d8f2931" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "shadeable" +version = "0.1.0" +dependencies = [ + "rhai", +] + +[[package]] +name = "smallvec" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" + +[[package]] +name = "smartstring" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31aa6a31c0c2b21327ce875f7e8952322acfcfd0c27569a6e18a647281352c9b" +dependencies = [ + "static_assertions", +] + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "syn" +version = "1.0.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a684ac3dcd8913827e18cd09a68384ee66c1de24157e3c556c9ab16d85695fb7" +dependencies = [ + "proc-macro2", + "quote", + "unicode-xid", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + +[[package]] +name = "unicode-xid" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + +[[package]] +name = "wasi" +version = "0.10.2+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" diff --git a/shadeable/Cargo.toml b/shadeable/Cargo.toml new file mode 100644 index 0000000..e5954bd --- /dev/null +++ b/shadeable/Cargo.toml @@ -0,0 +1,16 @@ +[package] +name = "shadeable" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] + + + +[dependencies.rhai] +version = "*" +features = [ "no_std", "only_i64"] +default-features = false + diff --git a/shadeable/README.md b/shadeable/README.md new file mode 100644 index 0000000..dcf214e --- /dev/null +++ b/shadeable/README.md @@ -0,0 +1 @@ +# Shadeable is a rhai based shader language \ No newline at end of file diff --git a/shadeable/shaders/simple.shade b/shadeable/shaders/simple.shade new file mode 100644 index 0000000..65abf65 --- /dev/null +++ b/shadeable/shaders/simple.shade @@ -0,0 +1,11 @@ +const VERSION = 0.5; + + +fn main(){ + let abcd = RGBA(0, 33, 0, 0); + + // print(rand_float()); + + + PIXEL_RGBA; +} \ No newline at end of file diff --git a/shadeable/src/engine_internals.rs b/shadeable/src/engine_internals.rs new file mode 100644 index 0000000..2bb7411 --- /dev/null +++ b/shadeable/src/engine_internals.rs @@ -0,0 +1,18 @@ +use crate::pixel_format::{rgba_add, rgba_div, rgba_mult, rgba_sub, RGBA}; + +use rhai::Engine; +pub fn engine_startup() -> Engine { + let mut engine = Engine::new(); + + engine + .register_type::() + .register_fn("RGBA", RGBA::new) + .register_fn("*", rgba_mult) + .register_fn("/", rgba_div) + .register_fn("+", rgba_add) + .register_fn("-", rgba_sub); + + // engine.register_global_module(RandomPackage::new().as_shared_module()); + + engine +} diff --git a/shadeable/src/lib.rs b/shadeable/src/lib.rs new file mode 100644 index 0000000..fac2fcf --- /dev/null +++ b/shadeable/src/lib.rs @@ -0,0 +1,68 @@ +#![no_std] +extern crate alloc; +use alloc::{boxed::Box, vec, vec::Vec}; +use engine_internals::engine_startup; +use pixel_format::RGBA; +// use core::fmt::Result; +use core::result::Result; +use rhai::{EvalAltResult, Scope}; + +mod engine_internals; +mod pixel_format; + +pub const SHADER: &str = include_str!("../shaders/simple.shade"); + +pub fn rhai_test() -> Result, Box> +// ^^^^^^^^^^^^^^^^^^ +// Rhai API error type +{ + // Create an 'Engine' + + let engine = engine_startup(); + + let ast = engine.compile(SHADER)?; + let mut scope = Scope::new(); + + let a = vec![ + RGBA { + r: 255, + g: 0, + b: 0, + a: 0, + }, + RGBA { + r: 0, + g: 255, + b: 0, + a: 0, + }, + RGBA { + r: 0, + g: 0, + b: 255, + a: 0, + }, + RGBA { + r: 0, + g: 0, + b: 0, + a: 255, + }, + ]; + + let mut result_rgba = vec![]; + + for pixel in a { + /* + scope.push("PIXEL_X", 0); + scope.push("PIXEL_Y", index); + */ + scope.push("PIXEL_RGBA", pixel); + + let result: RGBA = engine.call_fn(&mut scope, &ast, "main", ())?; + result_rgba.push(result); + } + + // Done! + Ok(result_rgba) +} diff --git a/shadeable/src/pixel_format.rs b/shadeable/src/pixel_format.rs new file mode 100644 index 0000000..50f3c84 --- /dev/null +++ b/shadeable/src/pixel_format.rs @@ -0,0 +1,113 @@ +use rhai::INT; + +pub type Rgba64 = u64; + +pub fn get_r(rgba: Rgba64) -> u8 { + let x: u64 = rgba; + + let y = x >> 24; + + return (y & 0xff).try_into().unwrap(); +} +pub fn get_g(rgba: Rgba64) -> u8 { + let x: u64 = rgba; + + let y = x >> 16; + + return (y & 0xff).try_into().unwrap(); +} +pub fn get_b(rgba: Rgba64) -> u8 { + let x: u64 = rgba; + + let y = x >> (24 - 16); + + return (y & 0xff).try_into().unwrap(); +} +pub fn get_a(rgba: Rgba64) -> u8 { + let x = rgba; + + let y = x >> (24 - 16 - 8); + + return (y & 0xff).try_into().unwrap(); +} + +pub fn set_r(rgba: Rgba64, r: u8) -> Rgba64 { + let z = (r as Rgba64) << 24; + let y = rgba & 0xffffff; + return z | y; +} + +pub fn set_g(rgba: Rgba64, r: u8) -> Rgba64 { + let z = (r as Rgba64) << 16; + let y = rgba & 0xffffff; + return z | y; +} + +pub fn set_b(rgba: Rgba64, r: u8) -> Rgba64 { + let z = (r as Rgba64) << 26 - 16; + let y = rgba & 0xffffff; + return z | y; +} + +pub fn set_a(rgba: Rgba64, r: u8) -> Rgba64 { + let z = (r as Rgba64) << 8; + let y = rgba & 0xffffff; + return z | y; +} + +#[derive(Debug, Clone)] +pub struct RGBA { + pub r: INT, + pub g: INT, + pub b: INT, + pub a: INT, +} +impl RGBA { + pub fn new(r: INT, g: INT, b: INT, a: INT) -> Self { + Self { r, g, b, a } + } +} + +pub fn rgba_div(a: Rgba64, b: Rgba64) -> Rgba64 { + let mut fin: Rgba64 = 0; + + // println!("{}", fin); + fin = set_r(fin, get_r(a) / get_r(b)); + // println!("{}", fin); + + fin = set_g(fin, get_g(a) / get_g(b)); + /* + + get_b(a) / get_b(b); + + get_a(a) / get_a(b); + */ + + return fin; +} + +pub fn rgba_mult(a: RGBA, b: RGBA) -> RGBA { + RGBA { + r: a.r * b.r, + g: a.g * b.g, + b: a.b * b.b, + a: a.a * b.a, + } +} +pub fn rgba_add(a: RGBA, b: RGBA) -> RGBA { + RGBA { + r: a.r + b.r, + g: a.g + b.g, + b: a.b + b.b, + a: a.a + b.a, + } +} +pub fn rgba_sub(a: RGBA, b: RGBA) -> RGBA { + RGBA { + r: a.r - b.r, + g: a.g - b.g, + b: a.b - b.b, + a: a.a - b.a, + } +} +//