diff options
Diffstat (limited to 'applications/init')
-rw-r--r-- | applications/init/main.cpp | 50 | ||||
-rw-r--r-- | applications/init/makefile | 12 | ||||
-rw-r--r-- | applications/init/source/main.cpp | 28 |
3 files changed, 40 insertions, 50 deletions
diff --git a/applications/init/main.cpp b/applications/init/main.cpp deleted file mode 100644 index 57ebd02..0000000 --- a/applications/init/main.cpp +++ /dev/null @@ -1,50 +0,0 @@ -#include <daguerre/image.hpp> - -int main(int, char **) { - - auto fb = daguerre::get_hilbert_framebuffer(); - - auto white = daguerre::to_hilbert_color({.r = 255, .g = 255, .b = 255}); - auto gray = daguerre::to_hilbert_color({.r = 127, .g = 127, .b = 127}); - - 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; - } - - daguerre::image<daguerre::color24> img; - - std::FILE *file = std::fopen("/init/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); - - while (true) { - - uint32_t kp = _syscall_read_key_packet(); - if ((kp & 0x0400ff) == 0x04005a) { - for (unsigned y = 0; y < img.get_height(); ++y) - for (unsigned x = 0; x < img.get_width(); ++x) { - img.get(x, y).r = ~img.get(x, y).r; - img.get(x, y).g = ~img.get(x, y).g; - img.get(x, y).b = ~img.get(x, y).b; - } - daguerre::copy_image(img, fb, 0, 0, x_off, y_off, width, height); - } - - } - - return 0; - -} diff --git a/applications/init/makefile b/applications/init/makefile new file mode 100644 index 0000000..6799406 --- /dev/null +++ b/applications/init/makefile @@ -0,0 +1,12 @@ +SOURCES = \ + main.cpp + +build/%.cpp.o: source/%.cpp + @mkdir -p $(@D) + $(HILBERT_CC) -c $^ -o $@ + +build/init.elf: $(SOURCES:%=build/%.o) + $(HILBERT_CC) $^ -ldaguerre -o $@ + +clean: + rm -rf build diff --git a/applications/init/source/main.cpp b/applications/init/source/main.cpp new file mode 100644 index 0000000..ed0ef8e --- /dev/null +++ b/applications/init/source/main.cpp @@ -0,0 +1,28 @@ +#include <daguerre.hpp> + +int main(int, char **) { + + auto hfb = daguerre::get_hilbert_framebuffer(); + daguerre::image<daguerre::rgb24> bim; + + std::FILE *burdon = std::fopen("/assets/burden.ppm", "r"); + daguerre::try_load_ppm(burdon, bim); + std::fclose(burdon); + + unsigned width = bim.width < hfb.width ? bim.width : hfb.width; + unsigned height = bim.height < hfb.height ? bim.height : hfb.height; + unsigned x = (hfb.width - width) / 2; + unsigned y = (hfb.height - height) / 2; + + while (1) { + daguerre::copy_region<>(hfb, bim, 0, 0, x, y, width, height); + while ((__euler_read_key_packet() & 0x0400ff) != 0x00005a) + ; + for (unsigned i = 0; i < bim.width * bim.height; ++i) { + bim.buffer[i].r = 255 - bim.buffer[i].r; + bim.buffer[i].g = 255 - bim.buffer[i].g; + bim.buffer[i].b = 255 - bim.buffer[i].b; + } + } + +} |