fix DrawText func && add enum with text encoding && update manual && other

This commit is contained in:
2025-04-07 21:11:37 +05:00
parent d6b784814f
commit 593c4a6596
7 changed files with 127 additions and 36 deletions

View File

@@ -29,16 +29,16 @@ int syscalls_drawLine(lua_State* L)
}
static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_color_t color, enum TextScale size, uint32_t len, bool fillBackground, ksys_color_t backgroundColor)
static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_color_t color, enum TextScale size, uint32_t len, bool fillBackground, ksys_color_t backgroundColor, enum DrawTextEncoding encoding)
{
enum DrawTextEncoding
enum DrawTextEncoding_
{
cp866_6x9 = 0,
cp866_8x16 = 1,
utf8 = 3,
utf16 = 4
cp866_8x16 = 1
};
enum scale
{
scale_x1 = 0,
@@ -55,19 +55,20 @@ static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_colo
color |= (fillBackground << 30);
switch (size)
{
case TextScale_SIZE_6x9:
color |= (cp866_8x16 << 28) | (scale_x1 << 24);
color |= (cp866_6x9 << 28) | (scale_x1 << 24);
break;
case TextScale_SIZE_8x16:
color |= (cp866_8x16 << 28);
color |= (encoding << 28) | (scale_x1 << 24);
break;
case TextScale_SIZE_12x18:
color |= (cp866_6x9 << 28) | (scale_x2 << 24);
break;
case TextScale_SIZE_16x32:
color |= (cp866_8x16 << 28) | (scale_x2 << 24);
color |= (encoding << 28) | (scale_x2 << 24);
break;
case TextScale_SIZE_18x27:
color |= (cp866_6x9 << 28) | (scale_x3 << 24);
@@ -76,16 +77,19 @@ static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_colo
color |= (cp866_6x9 << 28) | (scale_x4 << 24);
break;
case TextScale_SIZE_24x48:
color |= (cp866_8x16 << 28) | (scale_x3 << 24);
color |= (encoding << 28) | (scale_x3 << 24);
break;
case TextScale_SIZE_30x45:
color |= (cp866_6x9 << 28) | (scale_x5 << 24);
break;
case TextScale_SIZE_32x64:
color |= (encoding << 28) | (scale_x4 << 24);
break;
case TextScale_SIZE_36x54:
color |= (cp866_6x9 << 28) | (scale_x6 << 24);
break;
case TextScale_SIZE_40x80:
color |= (cp866_8x16 << 28) | (scale_x5 << 24);
color |= (encoding << 28) | (scale_x5 << 24);
break;
case TextScale_SIZE_42x63:
color |= (cp866_6x9 << 28) | (scale_x7 << 24);
@@ -94,19 +98,19 @@ static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_colo
color |= (cp866_6x9 << 28) | (scale_x8 << 24);
break;
case TextScale_SIZE_48x96:
color |= (cp866_8x16 << 28) | (scale_x6 << 24);
color |= (encoding << 28) | (scale_x6 << 24);
break;
case TextScale_SIZE_56x112:
color |= (cp866_8x16 << 28) | (scale_x7 << 24);
color |= (encoding << 28) | (scale_x7 << 24);
break;
case TextScale_SIZE_64x128:
color |= (cp866_8x16 << 28) | (scale_x8 << 24);
color |= (encoding << 28) | (scale_x8 << 24);
break;
default:
break;
};
if (len <= 0)
if (len == NULL)
color |= (1 << 31);
asm_inline(
@@ -120,15 +124,19 @@ static void syscall_drawText(const char* text, uint32_t x, uint32_t y, ksys_colo
int syscalls_drawText(lua_State* L)
{
LUA_INTEGER backgroundColor = luaL_optinteger(L, 7, 0);
syscall_drawText(
luaL_checkstring(L, 1),
luaL_checkinteger(L, 2),
luaL_checkinteger(L, 3),
luaL_checkinteger(L, 4),
luaL_optinteger(L, 5, TextScale_SIZE_8x16),
luaL_optinteger(L, 6, 0),
luaL_optinteger(L, 7, 0),
luaL_optinteger(L, 8, 0));
luaL_optinteger(L, 6, NULL),
backgroundColor << 32,
backgroundColor,
luaL_optinteger(L, 8, cp866)
);
return 0;
}