diff --git a/src/hulk/console.d b/src/hulk/console.d index 2e7ffbc..deba2ec 100644 --- a/src/hulk/console.d +++ b/src/hulk/console.d @@ -8,17 +8,30 @@ import hulk.kfont; struct console { + /** Console width in text columns. */ private static __gshared size_t m_width; + + /** Console height in text rows. */ private static __gshared size_t m_height; + + /** Current console cursor X position. */ private static __gshared size_t m_x; + + /** Current console cursor Y position. */ private static __gshared size_t m_y; + /** + * Initialize the console. + */ public static void initialize() { m_width = fb.width / kfont.advance; m_height = fb.height / kfont.line_height; } + /** + * Clear the console. + */ public static void clear() { fb.clear(); @@ -26,6 +39,11 @@ struct console m_y = 0u; } + /** + * Write a character to the console. + * + * @param ch Character to write. + */ public static void write(char ch) { if (ch == '\n') @@ -53,17 +71,30 @@ struct console } } + /** + * Render a character. + * + * @param x X position. + * @param y Y position. + * @param ch Character to render. + */ private static void render_char(size_t x, size_t y, char ch) { const(CharInfo) * ci = &kfont.chars[ch]; fb.blit_alpha_bitmap(fb_x(x) + ci.left, fb_y(y) + ci.top - ci.height, ci.bitmap, ci.width, ci.height); } + /** + * Get the framebuffer X coordinate corresponding to the console X position. + */ private static size_t fb_x(size_t x) { return x * kfont.advance; } + /** + * Get the framebuffer Y coordinate corresponding to the console Y position. + */ private static size_t fb_y(size_t y) { return fb.height - ((y + 1u) * kfont.line_height); diff --git a/src/hulk/hulk.d b/src/hulk/hulk.d index 4a9d93b..9bb2a39 100644 --- a/src/hulk/hulk.d +++ b/src/hulk/hulk.d @@ -28,30 +28,11 @@ private __gshared Header hulk_header = { extern(C) void hulk_start(ulong rdi, ulong rsi, ulong rdx, BootInfo * bootinfo) { fb.initialize(bootinfo.fb.buffer, bootinfo.fb.width, bootinfo.fb.height, bootinfo.fb.stride); - fb.clear(0xFF8800u); - - for (size_t y = 100u; y < 120u; y++) - { - memset32(&bootinfo.fb.buffer[y * bootinfo.fb.stride + 20u], 0x001199u, 20u); - } - - string message = "Hello, world! 0123456789!@#$%^&*()_-=+[]{};:\"'<>,./"; - int x = 100u; - foreach (ch; message) - { - const(CharInfo) * ci = &kfont.chars[ch]; - fb.blend_alpha_bitmap(x + ci.left, 100 + ci.top - ci.height, ci.bitmap, ci.width, ci.height, 0x0088CCu); - x += kfont.advance; - } - console.initialize(); console.clear(); klog.initialize(); - for (size_t i = 1u; i != 0u; i++) - { - klog.writef("Hello! i = %010u\n", i); - } + klog.writefln("Welcome to HULK, the HOS UltraLight Kernel!"); for (;;) {