From a6df8ef3031c3d133b9669a53ef528beea9f0674 Mon Sep 17 00:00:00 2001 From: Kirill Zhumarin Date: Fri, 11 Sep 2026 20:58:30 +0000 Subject: [PATCH] Some changes --- src/elfloader/loadlib.c | 2 +- src/glue.cpp | 4 ++-- src/main.cpp | 1 - src/swi/gui/TextRender.cpp | 6 +++++- src/swi/gui/drwobj.cpp | 2 +- src/swi/libc.cpp | 21 ++++++++++++++++++--- src/swi/settings.cpp | 2 +- src/swilib/switab.c | 11 +++++++---- toolchain.cmake | 1 + 9 files changed, 36 insertions(+), 14 deletions(-) diff --git a/src/elfloader/loadlib.c b/src/elfloader/loadlib.c index fb77bd6..fa7cd8f 100644 --- a/src/elfloader/loadlib.c +++ b/src/elfloader/loadlib.c @@ -174,6 +174,7 @@ Elf32_Lib *loader_lib_open(const char *name, Elf32_Exec *_ex) { Elf32_Ehdr ehdr; Elf32_Exec *ex; char __mem[256]; + uint32_t err; // Поищем среди уже загруженых Global_Queue *ready_libs = lib_top; @@ -224,7 +225,6 @@ Elf32_Lib *loader_lib_open(const char *name, Elf32_Exec *_ex) { try_again: /* Открываем */ - uint32_t err; if (((fp = sys_open(ld_path, A_ReadOnly | A_BIN, P_READ, &err)) < 0)) { strcpy(dlerr, NO_FILEORDIR); return 0; diff --git a/src/glue.cpp b/src/glue.cpp index 16fbed1..38108e0 100644 --- a/src/glue.cpp +++ b/src/glue.cpp @@ -11,11 +11,11 @@ extern "C" void loader_swi_stub(int swi) { } extern "C" void loader_subproc_impl(void *func, void *p1) { - SUBPROC(func, (int) p1); + SUBPROC(func, reinterpret_cast(p1)); } extern "C" int *loader_library_impl() { - return (int *) SWILIB; + return reinterpret_cast(SWILIB); } extern "C" void loader_log_error(const char *format, ...) { diff --git a/src/main.cpp b/src/main.cpp index 3f5cc2b..304be18 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -29,7 +29,6 @@ #include "src/utils/fs.h" #include "src/utils/string.h" -static volatile sig_atomic_t sigalrm_called = 0; static std::string buildLibraryPathEnv(const std::vector &library_path); /* diff --git a/src/swi/gui/TextRender.cpp b/src/swi/gui/TextRender.cpp index 48c31db..d8668fa 100644 --- a/src/swi/gui/TextRender.cpp +++ b/src/swi/gui/TextRender.cpp @@ -3,6 +3,7 @@ #include "src/Resources.h" #include "src/swi/gui.h" #include "src/swi/image.h" +#include TextRender::TextRender(Painter *painter, RECT *rect, uint16_t *str, int length) { m_rect = rect; @@ -43,6 +44,7 @@ void TextRender::parseWord(int start, int end) { } int TextRender::drawWord(Word *word, int x, int y) { + spdlog::debug("drawWord {} {}", x, y); auto *res = Resources::instance(); int width = 0; for (int j = word->start; j <= word->end; j++) { @@ -56,6 +58,7 @@ int TextRender::drawWord(Word *word, int x, int y) { } void TextRender::renderLine() { + spdlog::debug("renderLine {}", m_words.size()); if (m_words.size() == 0) return; @@ -147,7 +150,8 @@ void TextRender::renderInline(int x_offset) { int ctrl_chars = handleModifiers(&m_style, m_str, m_length); for (int i = ctrl_chars; i < m_length; i++) { auto *img = res->getFontChar(m_style.font, m_str[i], false); - if (virtual_x >= (x_offset - 1)) { + spdlog::debug("renderInline {}>={}", virtual_x, (x_offset - 1)); + if ((virtual_x + img->w) >= (x_offset - 1)) { m_painter->drawBitmap(x, 0, img->w, img->h, img->bitmap, IMG_GetBitmapType(img->bpnum), 0, 0, m_style.brush, m_style.pen); if ((m_style.flags & (TEXT_INVERT | TEXT_INVERT2))) diff --git a/src/swi/gui/drwobj.cpp b/src/swi/gui/drwobj.cpp index a65b806..fccb649 100644 --- a/src/swi/gui/drwobj.cpp +++ b/src/swi/gui/drwobj.cpp @@ -281,7 +281,7 @@ int PushDRWOBJOnLAYER(DRWOBJ *drwobj, LCDLAYER *layer) { // TODO: merge DRWOBJ rect + LCDLAYER rect? RECT *rect = &drw->rect; - // spdlog::debug("DRAW [ {}, {}, {}, {} ]", rect->x, rect->y, rect->x2, rect->y2); + spdlog::debug("DRW [ {}, {}, {}, {} ]", rect->x, rect->y, rect->x2, rect->y2); painter.setBuffer(reinterpret_cast(layer->buffer), layer->w, layer->h, LCDLAYER_GetBitmapType(layer)); painter.setWindow(rect->x, rect->y, rect->x2, rect->y2); diff --git a/src/swi/libc.cpp b/src/swi/libc.cpp index 368182b..89895d4 100644 --- a/src/swi/libc.cpp +++ b/src/swi/libc.cpp @@ -4,13 +4,28 @@ #include #include #include +#include +#include +#include #include #include #include "src/elfloader/loader.h" +#include +#include +#include +#include +#include +#include +#include -void _longjmp(jmp_buf env, int val) { - spdlog::debug("{}: not implemented!", __func__); - abort(); +jmp_buf buf; + +extern "C" int SWI_setjmp(int env[11]) { + return setjmp(buf); +} + +extern "C" void SWI_longjmp(int env[11], int val) { + longjmp(buf, val); } int _dlopen(const char *name) { diff --git a/src/swi/settings.cpp b/src/swi/settings.cpp index 82e81e3..c41fb66 100644 --- a/src/swi/settings.cpp +++ b/src/swi/settings.cpp @@ -30,7 +30,7 @@ static const char *SET_TO_PATH[] = { "1:\\Default\\orangehomescreen.pd", }; -static constexpr int MAX_SETTINGS_ID = (sizeof(SET_TO_PATH) / sizeof(SET_TO_PATH[0])) - 1; +// static constexpr int MAX_SETTINGS_ID = (sizeof(SET_TO_PATH) / sizeof(SET_TO_PATH[0])) - 1; static std::string SettingsAE_GetPath(int id) { assert(id >= 0 && id <= MAX_SETTINGS_ID); diff --git a/src/swilib/switab.c b/src/swilib/switab.c index 7a9842d..5fcb5d3 100644 --- a/src/swilib/switab.c +++ b/src/swilib/switab.c @@ -10,6 +10,9 @@ #include #include +int SWI_setjmp(int *env); +void SWI_longjmp(int *env, int val); + static void __swi_0000() { loader_swi_stub(0x0000); } @@ -12470,7 +12473,7 @@ void loader_init_swilib() { SWILIB[0x015F] = (void *) png_get_rowbytes; SWILIB[0x0160] = (void *) png_read_row; SWILIB[0x0161] = (void *) png_init_io; - SWILIB[0x0162] = (void *) _setjmp; + SWILIB[0x0162] = (void *) SWI_setjmp; SWILIB[0x0163] = (void *) AllocEQueue; SWILIB[0x0164] = (void *) PrepareEditControl; SWILIB[0x0165] = (void *) ConstructEditControl; @@ -12669,7 +12672,7 @@ void loader_init_swilib() { SWILIB[0x0226] = (void *) PlayMelody_StopPlayback; SWILIB[0x0227] = (void *) PlayMelody_PausePlayback; SWILIB[0x0228] = (void *) PlayMelody_ResumePlayBack; - SWILIB[0x0229] = (void *) _longjmp; + SWILIB[0x0229] = (void *) SWI_longjmp; SWILIB[0x022A] = (void *) FreeGSMTXTpkt; SWILIB[0x022B] = (void *) CreateRadioButtonList; SWILIB[0x022C] = (void *) pdcache_getval; @@ -13092,9 +13095,9 @@ void loader_init_swilib() { SWILIB[0x03CD] = (void *) __swi_03cd; SWILIB[0x03CE] = (void *) __swi_03ce; SWILIB[0x03CF] = (void *) __swi_03cf; - SWILIB[0x03D0] = (void *) ShowScreenSaverCodeProtection; +// SWILIB[0x03D0] = (void *) ShowScreenSaverCodeProtection; SWILIB[0x03D1] = (void *) MediaProc_LaunchLastPlayback; - SWILIB[0x03D2] = (void *) GetScreenSaverType; +// SWILIB[0x03D2] = (void *) GetScreenSaverType; SWILIB[0x03D3] = (void *) IllumFilterSet; SWILIB[0x03D4] = (void *) DrawCroppedIMGHDR; SWILIB[0x03D5] = (void *) BuildPath; diff --git a/toolchain.cmake b/toolchain.cmake index 88c6dc0..776ea16 100644 --- a/toolchain.cmake +++ b/toolchain.cmake @@ -6,6 +6,7 @@ set(CMAKE_SYSTEM_NAME Linux) set(CMAKE_SYSTEM_VERSION 1) set(CMAKE_SYSTEM_PROCESSOR arm) set(CMAKE_LIBRARY_ARCHITECTURE arm-linux-gnueabihf) +set(CMAKE_LINKER_TYPE BFD) find_program(ARM_C_COMPILER arm-linux-gnueabihf-gcc${CMAKE_EXECUTABLE_SUFFIX} NO_CACHE REQUIRED) find_program(ARM_CXX_COMPILER arm-linux-gnueabihf-g++${CMAKE_EXECUTABLE_SUFFIX} NO_CACHE REQUIRED)