[fix] Better color?

This commit is contained in:
2026-05-31 20:03:46 +08:00
Unverified
parent 175eba1889
commit bd2f086329
4 changed files with 9 additions and 90 deletions
+3 -30
View File
@@ -3,16 +3,7 @@
#include <graphics/draw.h>
#include <common.h>
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, COLOR_RGB color) {
void pf_print_char(char c, uint16_t basex, uint16_t basey, COLOR_RGB color) {
for (unsigned int y = 0; y < 16; y++) {
unsigned char data = hankaku_pixels[c][y];
for (int x = 7; x >= 0; x--) {
@@ -31,27 +22,9 @@ void pf_print_char(char c, unsigned int basex, unsigned int basey, COLOR_RGB col
}
}
void pf_print(const char* text, COLOR_RGB color) {
void pf_print(const char* text, uint16_t basex, uint16_t basey, COLOR_RGB 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);
}
}