From 5a31effcf12e59054e4a2ac7287055313cc96cfa Mon Sep 17 00:00:00 2001 From: pyao12 Date: Fri, 5 Jun 2026 17:49:19 +0800 Subject: [PATCH] [fix] Remove PF auto-pos --- fonts/pixel_font.cpp | 31 ++----------------------------- include/fonts/pixel_font.h | 3 +-- kernel/main.cpp | 2 +- 3 files changed, 4 insertions(+), 32 deletions(-) diff --git a/fonts/pixel_font.cpp b/fonts/pixel_font.cpp index 188dee3..88e7189 100644 --- a/fonts/pixel_font.cpp +++ b/fonts/pixel_font.cpp @@ -3,15 +3,6 @@ #include #include -static unsigned int pf_x = 0; -static unsigned int pf_y = 1; - -void pf_reset_position(void) { - // 其实应该还要清一下屏,后面思考一个安全的做法 - pf_x = 0; - pf_y = 1; -} - void pf_print_char(char c, unsigned int basex, unsigned int basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) { for (unsigned int y = 0; y < 16; y++) { unsigned char data = hankaku_pixels[c][y]; @@ -31,27 +22,9 @@ void pf_print_char(char c, unsigned int basex, unsigned int basey, EFI_GRAPHICS_ } } -void pf_print(const char* text, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) { +void pf_print(const char* text, unsigned int basex, unsigned int basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color) { for (unsigned int i = 0; i < strlen(text); i++) { char c = text[i]; - if (c == '\n') { - pf_x = 0; - pf_y++; - if ((pf_y - 1) * 16 >= g_gfx.vr) { - gfx_clear(); - pf_y = 1; - } - continue; - } - if (pf_x * 9 + 9 > g_gfx.hr) { - pf_x = 0; - pf_y++; - if ((pf_y - 1) * 16 >= g_gfx.vr) { - gfx_clear(); - pf_y = 1; - } - } - pf_print_char(c, pf_x * 9, (pf_y - 1) * 16, color); - pf_x++; + pf_print_char(c, basex + i * 8, basey, color); // 只要 字数 * 8 + basex 不爆hr就没事 } } \ No newline at end of file diff --git a/include/fonts/pixel_font.h b/include/fonts/pixel_font.h index 353328e..9008641 100644 --- a/include/fonts/pixel_font.h +++ b/include/fonts/pixel_font.h @@ -4,5 +4,4 @@ void pf_print_char(char c, unsigned int basex, unsigned int basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color = {255, 255, 255, 255}); // Pixel Font 打印字符 -void pf_print(const char* text, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color = {255, 255, 255, 255}); // Pixel Font 打印string -void pf_reset_position(void); // 重设Pixel Font Cursor位置 \ No newline at end of file +void pf_print(const char* text, unsigned int basex, unsigned int basey, EFI_GRAPHICS_OUTPUT_BLT_PIXEL color = {255, 255, 255, 255}); // Pixel Font 打印string \ No newline at end of file diff --git a/kernel/main.cpp b/kernel/main.cpp index 0c206b5..7561cb0 100644 --- a/kernel/main.cpp +++ b/kernel/main.cpp @@ -130,7 +130,7 @@ extern "C" void kernel_main() { fs_list(); } - pf_print("Welcome to Sylva OS!\n"); + // pf_print("Welcome to Sylva OS!\n"); serial_write(" Kernel prepared well.\n"); // --- Interrupt infrastructure ---