diff options
author | Benji Dial <benji@benjidial.net> | 2024-07-27 16:57:39 -0400 |
---|---|---|
committer | Benji Dial <benji@benjidial.net> | 2024-07-27 16:57:39 -0400 |
commit | fbfc078e9f44c1c1e95c9c484f1d5650bcf631b7 (patch) | |
tree | cab539c8cbbac81d895b6f8be695f3f53bf8f4d5 /applications | |
parent | 9af5588c30c4126a2800aae1afcb0de2c373dc6c (diff) | |
download | hilbert-os-fbfc078e9f44c1c1e95c9c484f1d5650bcf631b7.tar.gz |
lots and lots of userspace stuff
Diffstat (limited to 'applications')
-rw-r--r-- | applications/goldman/makefile | 2 | ||||
-rw-r--r-- | applications/goldman/source/main.cpp | 79 | ||||
-rw-r--r-- | applications/init/source/main.cpp | 22 |
3 files changed, 85 insertions, 18 deletions
diff --git a/applications/goldman/makefile b/applications/goldman/makefile index 5b93fe4..56f633d 100644 --- a/applications/goldman/makefile +++ b/applications/goldman/makefile @@ -6,7 +6,7 @@ build/%.cpp.o: source/%.cpp $(HILBERT_CC) -c $^ -o $@ build/goldman.elf: $(SOURCES:%=build/%.o) - $(HILBERT_CC) $^ -o $@ + $(HILBERT_CC) $^ -ldaguerre -o $@ clean: rm -rf build diff --git a/applications/goldman/source/main.cpp b/applications/goldman/source/main.cpp index 28ed00a..d74eaad 100644 --- a/applications/goldman/source/main.cpp +++ b/applications/goldman/source/main.cpp @@ -1,4 +1,79 @@ +#include <daguerre/framebuffer.hpp> +#include <daguerre/ppm.hpp> + +daguerre::hilbert_color trans_color; + +void convert_pointer( + daguerre::hilbert_color &dest, const daguerre::hilbert_color &src) { + if (src != trans_color) + dest = src; +} + int main(int, char **) { - while (1) - ; + + trans_color = euler::syscall::encode_color(0xff, 0x00, 0xff); + + daguerre::image<daguerre::hilbert_color> framebuffer = + daguerre::get_hilbert_framebuffer(); + + int fw = framebuffer.width; + int fh = framebuffer.height; + + daguerre::image<daguerre::hilbert_color> double_buffer(fw, fh); + + std::optional<daguerre::image<daguerre::hilbert_color>> + background_original = daguerre::try_load_ppm("/assets/background.ppm"); + + daguerre::image<daguerre::hilbert_color> background; + + if (background_original.has_value()) + background = background_original->stretch(fw, fh); + else { + background = daguerre::image<daguerre::hilbert_color>(fw, fh); + background.fill(euler::syscall::encode_color(0, 0, 0)); + } + + std::optional<daguerre::image<daguerre::hilbert_color>> + pointer_original = daguerre::try_load_ppm("/assets/pointer.ppm"); + + if (!pointer_original.has_value()) + //TODO + while (1) + ; + + daguerre::image<daguerre::hilbert_color> + pointer = std::move(*pointer_original); + + int mouse_x = fw / 2; + int mouse_y = fh / 2; + + while (true) { + + double_buffer.copy_from(background, 0, 0); + double_buffer.convert_from(pointer, mouse_x, mouse_y, 0, 0, + std::min(pointer. width, double_buffer. width - mouse_x), + std::min(pointer.height, double_buffer.height - mouse_y), + &convert_pointer); + + framebuffer.copy_from(double_buffer, 0, 0); + + auto result = euler::syscall::get_input_packet(); + if (std::holds_alternative<euler::syscall::mouse_packet>(result)) { + const auto &packet = std::get<euler::syscall::mouse_packet>(result); + mouse_x += packet.x_changed; + mouse_y += packet.y_changed; + if (mouse_x < 0) + mouse_x = 0; + else if (mouse_x >= fw) + mouse_x = fw - 1; + if (mouse_y < 0) + mouse_y = 0; + else if (mouse_y >= fh) + mouse_y = fh - 1; + } + + } + + return 0; + } diff --git a/applications/init/source/main.cpp b/applications/init/source/main.cpp index 5dfa81a..ca137a4 100644 --- a/applications/init/source/main.cpp +++ b/applications/init/source/main.cpp @@ -1,19 +1,11 @@ -#include <euler/start_process.hpp> +#include <euler/syscall.hpp> -int main(int, char **) { - - __euler_process_handle dummy; - - euler::start_process wm_process("/bin/compositor"); - wm_process.add_env_variable("ARGC", "1"); - wm_process.add_env_variable("ARGV0", "/bin/compositor"); - wm_process.start(dummy); - - euler::start_process hello_process("/bin/hello"); - hello_process.add_env_variable("ARGC", "1"); - hello_process.add_env_variable("ARGV0", "/bin/hello"); - hello_process.start(dummy); +//this does not keep track of the processes or whether they have started +//successfully, nor does it set their argc, argv, stdin, stdout, or stderr. +int main(int, char **) { + euler::syscall::process_handle dummy; + euler::syscall::start_process("/bin/compositor", {}, {}, dummy); + euler::syscall::start_process("/bin/hello", {}, {}, dummy); return 0; - } |