diff options
Diffstat (limited to 'applications/init/main.cpp')
-rw-r--r-- | applications/init/main.cpp | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/applications/init/main.cpp b/applications/init/main.cpp index 1a39513..06a8203 100644 --- a/applications/init/main.cpp +++ b/applications/init/main.cpp @@ -1,29 +1,35 @@ -#include <hilbert/syscall.hpp> +#include <daguerre/image.hpp> -using hilbert::syscall::encoded_color; -using hilbert::syscall::color; +int main(int, char **) { -encoded_color *fb; -uint32_t fb_width; -uint32_t fb_height; -uint32_t fb_pitch; + auto fb = daguerre::get_hilbert_framebuffer(); -int main(int, char **) { + auto white = daguerre::to_hilbert_color({.r = 255, .g = 255, .b = 255}); + auto gray = daguerre::to_hilbert_color({.r = 127, .g = 127, .b = 127}); - hilbert::syscall::get_framebuffer(fb, fb_width, fb_height, fb_pitch); - for (uint32_t y = 0; y < fb_height; ++y) - for (uint32_t x = 0; x < fb_width; ++x) { - color c = { - .r = 0, - .g = (uint8_t)(y * 255 / fb_height), - .b = (uint8_t)(x * 255 / fb_width) - }; - fb[y * fb_pitch + x] = hilbert::syscall::encode_color(c); + for (unsigned y = 0; y < fb.get_height(); ++y) + for (unsigned x = 0; x < fb.get_width(); ++x) { + uint8_t v = (y / 16) % 2 == (x / 16) % 2; + fb.get(x, y) = v ? white : gray; } - //*(int *)0x12345678 = 0; - //fb_width = *(uint32_t *)0xffffffffc0000000; - //return 100 / (uint8_t)(uint64_t)fb; + daguerre::image<daguerre::color24> img; + + std::FILE *file = std::fopen("/assets/burdon.ppm", "r"); + assert(file != 0); + assert(daguerre::try_load_ppm(file, img)); + std::fclose(file); + + unsigned width = + img.get_width() < fb.get_width() ? img.get_width() : fb.get_width(); + unsigned height = + img.get_height() < fb.get_height() ? img.get_height() : fb.get_height(); + + unsigned x_off = (fb.get_width() - width) / 2; + unsigned y_off = (fb.get_height() - height) / 2; + + daguerre::copy_image(img, fb, 0, 0, x_off, y_off, width, height); + return 0; } |