fix drawText Func

This commit is contained in:
2025-04-11 14:49:53 +05:00
parent 764e5a1cde
commit 0eb821a67b
9 changed files with 83 additions and 33 deletions

View File

@@ -1,4 +1,5 @@
#include "graphic.h"
#include "debug.h"
/*
Кеш размера экрана.
@@ -30,14 +31,11 @@ int syscalls_drawLine(lua_State* L)
static inline void drawText(char* text, uint32_t x, uint32_t y, ksys_color_t color, size_t len, uint64_t backgroundColor)
{
bool fillBackground = !(backgroundColor << 32);
color |= (fillBackground << 30);
if (backgroundColor < (1 << 32))
color |= (1 << 30);
if (len == 0)
{
color |= (1 << 31);
}
asm_inline(
"int $0x40"
@@ -50,7 +48,7 @@ static inline void drawText(char* text, uint32_t x, uint32_t y, ksys_color_t col
}
static inline void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_color_t color, enum TextScale size, uint32_t len, uint64_t backgroundColor, enum DrawTextEncoding encoding)
static inline void drawTextFixSize(const char* text, uint32_t x, uint32_t y, ksys_color_t color, enum TextScale size, uint32_t len, uint64_t backgroundColor, enum DrawTextEncoding encoding)
{
enum DrawTextEncoding_
{
@@ -70,7 +68,7 @@ static inline void syscall_drawText(const char* text, uint32_t x, uint32_t y, ks
scale_x8 = 7
};
color &= 0x00FFFFFF;
color &= 0x00ffffff;
switch (size)
{
@@ -123,6 +121,7 @@ static inline void syscall_drawText(const char* text, uint32_t x, uint32_t y, ks
color |= (encoding << 28) | (scale_x8 << 24);
break;
default:
_ksys_debug_puts("Unknown size");
break;
};
@@ -131,25 +130,23 @@ static inline void syscall_drawText(const char* text, uint32_t x, uint32_t y, ks
int syscalls_drawText(lua_State* L)
{
const char text = luaL_checkstring(L, 1);
uint32_t x = luaL_checkinteger(L, 2);
uint32_t y = luaL_checkinteger(L, 3);
ksys_color_t color = luaL_checkinteger(L, 4);
uint8_t scale = luaL_optinteger(L, 5, 1);
uint32_t len = luaL_optinteger(L, 6, 0);
LUA_INTEGER backgroundColor = luaL_optinteger(L, 7, 1 << 32);
enum DrawTextEncoding encoding = luaL_optinteger(L, 8, DEFAULT_ENCODING);
color |= (encoding << 28) | (scale << 24);
drawText(text, x, y, color, len, backgroundColor);
drawText(
luaL_checkstring(L, 1),
luaL_checkinteger(L, 2),
luaL_checkinteger(L, 3),
(luaL_checkinteger(L, 4) & 0x00ffffff) |
((luaL_optinteger(L, 8, DEFAULT_ENCODING) & 0b11) << 28) |
(luaL_optinteger(L, 5, 1) << 24),
luaL_optinteger(L, 6, 0),
luaL_optinteger(L, 7, 1 << 32)
);
return 0;
}
int syscalls_drawTextFixSize(lua_State* L)
{
syscall_drawText(
drawTextFixSize(
luaL_checkstring(L, 1),
luaL_checkinteger(L, 2),
luaL_checkinteger(L, 3),