Reverse framebuffer vertical coordinates to start with 0 at top

This commit is contained in:
josh committed 2023-09-13 11:57:47 -04:00
1 parent c958b9ffcc
commit 4fcea6a283
2 files changed
+24 -18

No files matched your search

+8 -3
View File
@@ -6,6 +6,11 @@ module hulk.console;
import hulk.fb;
import hulk.kfont;
/**
* Represent the HULK console.
*
* Coordinate (0,0) is the top-left console position.
*/
struct Console
{
/** Console width in text columns. */
@@ -64,7 +69,7 @@ struct Console
if (m_y == m_height)
{
m_y--;
Fb.copy_rows_up(fb_y(m_height - 1u),
Fb.copy_rows_up(fb_y(1u),
(m_height - 1u) * Kfont.line_height,
Kfont.line_height);
Fb.rect(0u, fb_y(m_height - 1u), fb_x(m_width), Kfont.line_height, 0u);
@@ -81,7 +86,7 @@ struct Console
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) + Kfont.baseline_offset + ci.top - ci.height, ci.bitmap, ci.width, ci.height);
Fb.blit_alpha_bitmap(fb_x(x) + ci.left, fb_y(y) + Kfont.line_height - Kfont.baseline_offset - ci.top, ci.bitmap, ci.width, ci.height);
}
/**
@@ -97,6 +102,6 @@ struct Console
*/
private static size_t fb_y(size_t y)
{
return Fb.height - ((y + 1u) * Kfont.line_height);
return y * Kfont.line_height;
}
}