fix drawText Func
This commit is contained in:
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@@ -27,6 +27,7 @@
|
||||
"luaL_checkstring",
|
||||
"luaL_checkudata",
|
||||
"luaL_optinteger",
|
||||
"luaL_pushfail",
|
||||
"lua_pushboolean",
|
||||
"lua_pushinteger",
|
||||
"lua_pushnumber",
|
||||
|
1
Makefile
1
Makefile
@@ -61,3 +61,4 @@ src/graphic.h: src/syscalls.h
|
||||
src/sockets/socket_lua.h: src/syscalls.h src/sockets/socket.h
|
||||
src/sockets/sockaddr.h: src/sockets/socket.h src/syscalls.h
|
||||
src/debug/debug.h: src/syscalls.h
|
||||
src/debug/registers.h: src/syscalls.h
|
||||
|
@@ -158,8 +158,28 @@ int syscalls_DefineBreakpoint(lua_State* L)
|
||||
{
|
||||
uint32_t pid = luaL_checkinteger(L, 1);
|
||||
|
||||
|
||||
uint32_t flags = luaL_checkinteger(L, 2) & 0xFF | (luaL_checkinteger(L, 3) << 16) | (luaL_checkinteger(L, 4) << 18);
|
||||
// точки останова условие длина указатель
|
||||
uint32_t flags = luaL_checkinteger(L, 2) & 0xFF | (luaL_checkinteger(L, 3) << 16) | (luaL_checkinteger(L, 4) << 18) | (luaL_checkinteger(L, 4) << 20);
|
||||
|
||||
uint32_t ret;
|
||||
|
||||
asm_inline(
|
||||
"int $0x40"
|
||||
: "=a"(ret)
|
||||
: "a"(69), "b"(9), "c"(pid), "d"(flags)
|
||||
);
|
||||
|
||||
lua_pushinteger(L, ret);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int syscalls_UndefBreakpoint(lua_State* L)
|
||||
{
|
||||
uint32_t pid = luaL_checkinteger(L, 1);
|
||||
|
||||
// точки останова условие длина указатель бит
|
||||
uint32_t flags = luaL_checkinteger(L, 2) & 0xFF | (luaL_checkinteger(L, 3) << 16) | (luaL_checkinteger(L, 4) << 18) | (luaL_checkinteger(L, 4) << 20) | (1 << 31);
|
||||
|
||||
uint32_t ret;
|
||||
|
||||
|
@@ -23,4 +23,24 @@ int syscalls_DebugPuts(lua_State* L);
|
||||
|
||||
int syscalls_SetMessageArea(lua_State* L);
|
||||
|
||||
int syscalls_GetRegisters(lua_State* L);
|
||||
|
||||
int syscalls_SetRegisters(lua_State* L);
|
||||
|
||||
int syscalls_Disconnect(lua_State* L);
|
||||
|
||||
int syscalls_Stop(lua_State* L);
|
||||
|
||||
int syscalls_Continue(lua_State* L);
|
||||
|
||||
int syscalls_ReadFromMem(lua_State* L);
|
||||
|
||||
int syscalls_WriteToMem(lua_State* L);
|
||||
|
||||
int syscalls_Done(lua_State* L);
|
||||
|
||||
int syscalls_DefineBreakpoint(lua_State* L);
|
||||
|
||||
int syscalls_UndefBreakpoint(lua_State* L);
|
||||
|
||||
#endif // __DEBUG_LUA_H__
|
@@ -1,6 +1,7 @@
|
||||
#include "registers.h"
|
||||
#include "../syscalls.h"
|
||||
#include <string.h>
|
||||
#include "../debug.h"
|
||||
|
||||
static int syscalls_indexRegisters(lua_State* L)
|
||||
{
|
||||
@@ -79,7 +80,7 @@ static int syscalls_newindexRegisters(lua_State* L)
|
||||
}
|
||||
else
|
||||
{
|
||||
luaL_pushfail(L);
|
||||
luaL_error(L, "wrong index: %s", index);
|
||||
}
|
||||
|
||||
return 1;
|
||||
@@ -106,11 +107,11 @@ static const luaL_Reg syscalls_registers_m[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
struct ARP_entry* syscalls_pushRegisters(lua_State* L)
|
||||
struct registers* syscalls_pushRegisters(lua_State* L)
|
||||
{
|
||||
DEBUG_LINE("push ARP entry");
|
||||
DEBUG_LINE("push registers entry");
|
||||
|
||||
struct ARP_entry* entry = lua_newuserdata(L, sizeof(struct registers));
|
||||
struct registers* entry = lua_newuserdata(L, sizeof(struct registers));
|
||||
|
||||
luaL_setmetatable(L, syscalls_registers_metatable_name);
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
#ifndef __REGISTERS_H__
|
||||
#define __REGISTERS_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "../syscalls.h"
|
||||
|
||||
struct registers
|
||||
{
|
||||
|
@@ -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),
|
||||
|
@@ -1626,6 +1626,16 @@ static const luaL_Reg syscallsLib[] = {
|
||||
{"DebugPuts", syscalls_DebugPuts},
|
||||
{ "DebugPutc", syscalls_DebugPutc },
|
||||
{"SetMessageArea", syscalls_SetMessageArea},
|
||||
{ "GetRegisters", syscalls_GetRegisters },
|
||||
{ "SetRegisters", syscalls_SetRegisters },
|
||||
{ "Disconnect", syscalls_Disconnect },
|
||||
{ "Stop", syscalls_Stop },
|
||||
{ "Continue", syscalls_Continue },
|
||||
{ "ReadFromMem", syscalls_ReadFromMem },
|
||||
{ "WriteToMem", syscalls_WriteToMem },
|
||||
{ "Done", syscalls_Done },
|
||||
{ "DefineBreakpoint", syscalls_DefineBreakpoint },
|
||||
{ "UndefBreakpoint", syscalls_UndefBreakpoint },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
@@ -41,7 +41,7 @@ static int syscalls_indexSystemColors(lua_State* L)
|
||||
{
|
||||
lua_pushinteger(L, t->grab_bar_button);
|
||||
}
|
||||
else if (strcmp("grab_button_text", index) == 0)
|
||||
else if (strcmp("grabButtonText", index) == 0)
|
||||
{
|
||||
lua_pushinteger(L, t->grab_button_text);
|
||||
}
|
||||
|
Reference in New Issue
Block a user