From 911faf00ab02bfb044800ca5672ec0db553cf1cc Mon Sep 17 00:00:00 2001 From: Burer Date: Thu, 1 Jan 2026 10:34:57 +0200 Subject: [PATCH 01/10] apps/reshare: fix wrong memory tabs names --- programs/cmm/misc/reshare.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/programs/cmm/misc/reshare.c b/programs/cmm/misc/reshare.c index ce0301422..832f81713 100644 --- a/programs/cmm/misc/reshare.c +++ b/programs/cmm/misc/reshare.c @@ -190,8 +190,8 @@ void draw_tabs() { #define TABX WINW-BTNW-PAD-BTNW-PAD-BTNW-PAD-BTNW/2 DrawFlatButton( TABX, PAD+30, "ICONS32", 10+ACTIVE_ICONS32, active_tab & ACTIVE_ICONS32); - DrawFlatButton(PAD+BTNW*1+TABX, PAD+30, "ICONS16", 10+ACTIVE_ICONS16, active_tab & ACTIVE_ICONS16); - DrawFlatButton(PAD+BTNW*2+TABX, PAD+30, "ICONS16W", 10+ACTIVE_ICONS16W, active_tab & ACTIVE_ICONS16W); + DrawFlatButton(PAD+BTNW*1+TABX, PAD+30, "ICONS18", 10+ACTIVE_ICONS16, active_tab & ACTIVE_ICONS16); + DrawFlatButton(PAD+BTNW*2+TABX, PAD+30, "ICONS18W", 10+ACTIVE_ICONS16W, active_tab & ACTIVE_ICONS16W); DrawFlatButton(PAD+BTNW*3+TABX, PAD+30, "CHECKBOX", 10+ACTIVE_CHECKBOX, active_tab & ACTIVE_CHECKBOX); draw_tab_icons32(); } -- 2.49.1 From f7b8d753ca840060efa979738cb26f8ce87c690d Mon Sep 17 00:00:00 2001 From: Burer Date: Mon, 2 Feb 2026 10:23:56 +0200 Subject: [PATCH 02/10] apps/reshare: rewrite to fasm Co-authored-by: rgimad --- data/Tupfile.lua | 6 +- programs/cmm/misc/reshare.c | 4 +- programs/system/reshare/Tupfile.lua | 4 + programs/system/reshare/checkbox.inc | 71 +++ programs/system/reshare/reshare.asm | 667 +++++++++++++++++++++++++++ 5 files changed, 747 insertions(+), 5 deletions(-) create mode 100644 programs/system/reshare/Tupfile.lua create mode 100644 programs/system/reshare/checkbox.inc create mode 100644 programs/system/reshare/reshare.asm diff --git a/data/Tupfile.lua b/data/Tupfile.lua index bfea67049..d8ad3d8eb 100644 --- a/data/Tupfile.lua +++ b/data/Tupfile.lua @@ -29,7 +29,7 @@ img_files = { {"ALLGAMES", "common/allgames"}, {"HOME.PNG", "common/wallpapers/T_Home.png"}, {"ICONS32.PNG", "common/icons32.png"}, - {"ICONS16.PNG", "common/icons16.png"}, + {"ICONS18.PNG", "common/icons18.png"}, {"INDEX.HTM", "common/index_htm"}, {"KUZKINA.MID", "common/kuzkina.mid"}, {"SINE.MP3", "common/sine.mp3"}, @@ -401,8 +401,9 @@ tup.append_table(img_files, { {"@MENU", VAR_PROGS .. "/system/menu/trunk/menu"}, {"@NOTIFY", VAR_PROGS .. "/system/notify3/notify"}, {"@OPEN", VAR_PROGS .. "/system/open/open"}, - {"@TASKBAR", VAR_PROGS .. "/system/taskbar/trunk/TASKBAR"}, + {"@RESHARE", VAR_PROGS .. "/system/reshare/reshare"}, {"@SS", VAR_PROGS .. "/system/scrsaver/scrsaver"}, + {"@TASKBAR", VAR_PROGS .. "/system/taskbar/trunk/TASKBAR"}, {"@VOLUME", VAR_PROGS .. "/media/volume/volume"}, {"HACONFIG", VAR_PROGS .. "/other/ha/HACONFIG"}, {"ACLOCK", VAR_PROGS .. "/demos/aclock/aclock"}, @@ -661,7 +662,6 @@ end -- tup.getconfig('NO_JWASM') ~= 'full' -- Programs that require C-- to compile. if tup.getconfig('NO_CMM') ~= 'full' then tup.append_table(img_files, { - {"@RESHARE", VAR_PROGS .. "/cmm/misc/reshare.com"}, {"APP_PLUS", VAR_PROGS .. "/cmm/app_plus/app_plus.com"}, {"EASYSHOT", VAR_PROGS .. "/cmm/misc/easyshot.com"}, {"MOUSECFG", VAR_PROGS .. "/cmm/mousecfg/mousecfg.com"}, diff --git a/programs/cmm/misc/reshare.c b/programs/cmm/misc/reshare.c index 832f81713..ce0301422 100644 --- a/programs/cmm/misc/reshare.c +++ b/programs/cmm/misc/reshare.c @@ -190,8 +190,8 @@ void draw_tabs() { #define TABX WINW-BTNW-PAD-BTNW-PAD-BTNW-PAD-BTNW/2 DrawFlatButton( TABX, PAD+30, "ICONS32", 10+ACTIVE_ICONS32, active_tab & ACTIVE_ICONS32); - DrawFlatButton(PAD+BTNW*1+TABX, PAD+30, "ICONS18", 10+ACTIVE_ICONS16, active_tab & ACTIVE_ICONS16); - DrawFlatButton(PAD+BTNW*2+TABX, PAD+30, "ICONS18W", 10+ACTIVE_ICONS16W, active_tab & ACTIVE_ICONS16W); + DrawFlatButton(PAD+BTNW*1+TABX, PAD+30, "ICONS16", 10+ACTIVE_ICONS16, active_tab & ACTIVE_ICONS16); + DrawFlatButton(PAD+BTNW*2+TABX, PAD+30, "ICONS16W", 10+ACTIVE_ICONS16W, active_tab & ACTIVE_ICONS16W); DrawFlatButton(PAD+BTNW*3+TABX, PAD+30, "CHECKBOX", 10+ACTIVE_CHECKBOX, active_tab & ACTIVE_CHECKBOX); draw_tab_icons32(); } diff --git a/programs/system/reshare/Tupfile.lua b/programs/system/reshare/Tupfile.lua new file mode 100644 index 000000000..e05054c3c --- /dev/null +++ b/programs/system/reshare/Tupfile.lua @@ -0,0 +1,4 @@ +if tup.getconfig("NO_FASM") ~= "" then return end +HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR") +tup.include(HELPERDIR .. "/use_fasm.lua") +tup.rule("reshare.asm", FASM .. " -dlang=" .. tup.getconfig("LANG") .. " %f %o" .. tup.getconfig("KPACK_CMD"), "%B") \ No newline at end of file diff --git a/programs/system/reshare/checkbox.inc b/programs/system/reshare/checkbox.inc new file mode 100644 index 000000000..5ce1cd5ad --- /dev/null +++ b/programs/system/reshare/checkbox.inc @@ -0,0 +1,71 @@ +; SPDX-License-Identifier: GPL-2.0-only +; +; Reshare - Shared Resources Daemon +; Copyright (C) 2024 KolibriOS-NG Team +; +; Contributor rgmaid - Main code +; Contributor Burer - Image conversion from 8bpp + +; ==================================================================== + +CHBOX_WIDTH = 13 +CHBOX_HEIGHT = 13 +CHBOX_PIXELS = CHBOX_WIDTH * CHBOX_HEIGHT +CHBOX_IMG_SIZE = CHBOX_PIXELS * 3 ; 24-bpp RGB, tight rows + +; ==================================================================== + +macro RGB24 c +{ + db (c) and 0xFF, (c shr 8) and 0xFF, (c shr 16) and 0xFF +} + +macro ROW13 c00, c01, c02, c03, c04, c05, c06, c07, c08, c09, c10, c11, c12 +{ + RGB24 c00 + RGB24 c01 + RGB24 c02 + RGB24 c03 + RGB24 c04 + RGB24 c05 + RGB24 c06 + RGB24 c07 + RGB24 c08 + RGB24 c09 + RGB24 c10 + RGB24 c11 + RGB24 c12 +} + +P00 = 0x04D4FC ; 0xRRGGBB +P01 = 0x04C8FC +P02 = 0x04DCFC +P03 = 0x04B4FC +P04 = 0x04BCFC +P05 = 0x04A9FC +P06 = 0x0498F9 +P07 = 0xD2F2FC +P08 = 0x04A5FA +P09 = 0xFFFFFF +P10 = 0xF6FDFD +P11 = 0xAFF9FC +P12 = 0x95E0F7 +P13 = 0x0464BC +P14 = 0x2CDCFC +P15 = 0x049FFA + +cbox_image: + ROW13 P00, P00, P00, P00, P00, P00, P00, P00, P00, P00, P00, P00, P01 + ROW13 P02, P01, P01, P01, P01, P01, P01, P01, P01, P01, P01, P01, P03 + ROW13 P02, P01, P01, P01, P01, P04, P04, P04, P03, P05, P05, P03, P03 + ROW13 P00, P01, P01, P01, P04, P04, P03, P03, P06, P07, P07, P08, P03 + ROW13 P00, P03, P05, P05, P03, P03, P03, P06, P09, P10, P11, P06, P03 + ROW13 P00, P05, P07, P07, P06, P03, P06, P09, P10, P12, P13, P06, P05 + ROW13 P00, P06, P10, P09, P14, P06, P09, P10, P12, P13, P06, P15, P05 + ROW13 P00, P06, P12, P10, P09, P09, P10, P12, P13, P06, P15, P05, P05 + ROW13 P00, P06, P13, P12, P10, P10, P12, P13, P06, P15, P05, P05, P05 + ROW13 P01, P08, P06, P13, P12, P12, P13, P06, P15, P05, P05, P05, P15 + ROW13 P01, P05, P15, P06, P13, P13, P06, P15, P05, P05, P05, P15, P15 + ROW13 P01, P05, P05, P15, P06, P06, P15, P05, P05, P05, P15, P15, P06 + ROW13 P03, P06, P06, P06, P06, P06, P06, P06, P06, P06, P06, P06, P06 +align 4 diff --git a/programs/system/reshare/reshare.asm b/programs/system/reshare/reshare.asm new file mode 100644 index 000000000..550774f23 --- /dev/null +++ b/programs/system/reshare/reshare.asm @@ -0,0 +1,667 @@ +; SPDX-License-Identifier: GPL-2.0-only +; +; Reshare - Shared Resources Daemon +; Copyright (C) 2024-2025 KolibriOS/-NG Team +; +; Contributor Leency - Original version in C-- +; Contributor rgmaid - Main code +; Contributor Burer - Refactoring and localization + +; ================================================================ + +use32 +org 0 + +; ================================================================ + +db "MENUET01" +dd 1 +dd START +dd I_END +dd MEM +dd STACKTOP +dd 0 +dd 0 + +; ================================================================ + +include "../macros.inc" +include "../KOSfuncs.inc" +include "../encoding.inc" +include "../proc32.inc" +include "../dll.inc" +include "../string.inc" +include "../debug-fdo.inc" + +include "../libimg.inc" + +include "checkbox.inc" + +; ================================================================ + +LIBS: + library img, "libimg.obj" + import img, img.destroy, "img_destroy", \ + img.from_file, "img_from_file" + +; ================================================================ + +START: + mcall SF_KEYBOARD, SSF_SET_INPUT_MODE, 1 + + mcall SF_SYS_MISC, SSF_HEAP_INIT + + ; check if this is second instance of app. if so - run gui, else - run daemon + mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, 0, SHM_OPEN + SHM_READ + test eax, eax + jz MODE_DAEMON + jmp MODE_GUI + +.exit: + mcall SF_TERMINATE_PROCESS + +; ================================================================ + +MODE_GUI: + +.event_loop: + + mcall SF_WAIT_EVENT + + cmp eax, EV_REDRAW + je .event_redraw + + cmp eax, EV_KEY + je .event_key + + cmp eax, EV_BUTTON + je .event_button + + jmp .event_loop + + +.event_redraw: + + mcall SF_REDRAW, SSF_BEGIN_DRAW + + mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, sizeof.system_colors + mcall , SSF_GET_SKIN_HEIGHT + + mov ecx, WIN.Y shl 16 + WIN.H + add ecx, eax + mov edx, [sc.work] + add edx, 0x34000000 + + mcall SF_CREATE_WINDOW, , , , , title + + ; visual dividers + mcall SF_DRAW_RECT, , , [sc.work_graph] + mcall , , , + + ; info row + mov ecx, FONT_TYPE shl 24 + add ecx, [sc.work_text] + mcall SF_DRAW_TEXT, , , lb_info + + ; tabs labels + mcall , , , lb_tab_i32 + mcall , , , + mcall , , , lb_tab_i32_res + mcall , , , lb_tab_i18 + mcall , , , + mcall , , , lb_tab_i18_res + mcall , , , lb_tab_i18w + mcall , , , + mcall , , , lb_tab_i18w_res + mcall , , , lb_tab_cbox + mcall , , , + mcall , , , lb_tab_cbox_res + + ; tabs buttons + mcall SF_DEFINE_BUTTON, , , 10 + BTN_HIDE + ACTIVE_ICONS32 + mcall , , , 10 + BTN_HIDE + ACTIVE_ICONS18 + mcall , , , 10 + BTN_HIDE + ACTIVE_ICONS18W + mcall , , , 10 + BTN_HIDE + ACTIVE_CHECKBOX + + ; tabs content + stdcall draw_tabs + + mcall SF_REDRAW, SSF_END_DRAW + + jmp .event_loop + + +.event_key: + + mcall SF_GET_KEY + cmp ah, 15 ; TAB + jne .event_loop + + shl [active_tab], 1 ; * 2 + cmp [active_tab], ACTIVE_CHECKBOX + jbe .tab_draw + mov [active_tab], 1 + + .tab_draw: + stdcall draw_tabs + + jmp .event_loop + + +.event_button: + + mcall SF_GET_BUTTON + + cmp ah, 1 + je .event_exit + + movzx eax, ah + sub eax, 10 + mov [active_tab], eax + stdcall draw_tabs + + jmp .event_loop + + +.event_exit: + mcall SF_TERMINATE_PROCESS + +; ================================================================ + +proc draw_tabs stdcall + ; draw tabs headers underlines + mov esi, [active_tab] + xor edi, edi + + .loop: + mov edx, [sc.work_dark] + mov eax, [tab_masks + edi * 4] + test esi, eax + jz .color_ok + mov edx, [sc.work_button] + + .color_ok: + mov eax, edi + imul eax, TAB_STEP + add eax, PAD + mpack ebx, eax, BTN.W + mpack ecx, PAD + BTN.H + 2, 2 + mcall SF_DRAW_RECT, ebx, ecx, edx + + inc edi + cmp edi, TAB_COUNT + jb .loop + + ; draw current tab content + mcall SF_DRAW_RECT, , , [sc.work] + + mov eax, [active_tab] + + .tab_i32: + cmp eax, ACTIVE_ICONS32 + jne .tab_i18 + stdcall draw_tab_icons, lb_tab_i32, META_I32_C, META_I32_W + ret + + .tab_i18: + cmp eax, ACTIVE_ICONS18 + jne .tab_i18w + stdcall draw_tab_icons, lb_tab_i18, META_I18_C, META_I18_W + ret + + .tab_i18w: + cmp eax, ACTIVE_ICONS18W + jne .tab_cbox + stdcall draw_tab_icons, lb_tab_i18w, META_I18W_C, META_I18W_W + ret + + .tab_cbox: + stdcall draw_tab_cbox + ret +endp + + +proc draw_tab_icons stdcall uses ebx ecx, _shm_name, _meta_c_off, _meta_w_off + mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, 0, SHM_OPEN + SHM_READ + test eax, eax + jz .done + + mov ebx, [_meta_c_off] + mov ecx, [eax + ebx] ; icon_c + mov ebx, [_meta_w_off] + mov edx, [eax + ebx] ; icon_w + + test ecx, ecx + jz .done + test edx, edx + jz .done + + push ecx + push edx + mcall SF_SYS_MISC, SSF_MEM_OPEN, [_shm_name], 0, SHM_OPEN + SHM_READ + pop edx + pop ecx + + test eax, eax + jz .done + + mov ebx, eax + + stdcall draw_tab_icons_grid, ebx, ecx, edx + + .done: + ret +endp + + +proc draw_tab_icons_grid stdcall uses eax ebx ecx edx esi edi, _icon_img, _icon_c, _icon_w +locals + x dd 0 + x_off dd 0 + y dd 0 + icon_size dd 0 +endl + ; icon_bytes = icon_w * icon_w * 4 + mov eax, [_icon_w] + imul eax, eax + shl eax, 2 + mov [icon_size], eax + + ; x_off = (CELL.W - icon_w) / 2 + mov eax, CELL.W + sub eax, [_icon_w] + shr eax, 1 + mov [x_off], eax + + ; y_step = icon_w + 28 + mov eax, [_icon_w] + add eax, 28 + mov edi, eax + + xor ecx, ecx + + .for_icons: + cmp ecx, [_icon_c] + jae .end_for_icons + push ecx + + ; SF_PUT_IMAGE_EXT, _icon_img+icon_size*index, <_icon_w, _icon_w>, , 32, 0, 0 + mov ebx, [icon_size] + imul ebx, ecx + add ebx, [_icon_img] + + mov ecx, [_icon_w] + shl ecx, 16 + add ecx, [_icon_w] + + mov edx, [x] + add edx, [x_off] + shl edx, 16 + add edx, [y] + add edx, GRID.Y + + push edi + push ebp + mcall SF_PUT_IMAGE_EXT, , , , 32, 0, 0 + pop ebp + pop edi + + ; draw number, centered in CELL.W + mov edx, [x] + add edx, GAP + shl edx, 16 + add edx, [y] + add edx, [_icon_w] + add edx, GRID.Y + 4 + mov esi, 0x10000000 + add esi, [sc.work_graph] + + pop ecx + mcall SF_DRAW_NUMBER, 0x00030000, , , , + inc ecx + + add [x], CELL.W + cmp [x], WIN.W - CELL.W + jle .for_icons + mov [x], 0 + add [y], edi + + jmp .for_icons + .end_for_icons: + + ret +endp + + +proc draw_tab_cbox stdcall + mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, 0, SHM_OPEN + SHM_READ + test eax, eax + jz .done + mov ebx, eax + mcall SF_PUT_IMAGE, , \ + , \ + <(WIN.W - CHBOX_WIDTH)/2, (WIN.H - RES_Y - CHBOX_HEIGHT)/2 + RES_Y> + + .done: + ret +endp + +; ================================================================ + +MODE_DAEMON: + + stdcall dll.Load, LIBS + + ; load shared resources from files + DEBUGF DBG_INFO, "@reshare: loading resources...\n" + + stdcall load_icons, icons32_path, icons32_image, size32 + stdcall load_icons, icons18_path, icons18_image, size18 + + ; publish meta + mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, META_SIZE, SHM_CREATE + SHM_WRITE + test eax, eax + jz .meta_done + mov edi, eax + + xor ebx, ebx + xor ecx, ecx + mov eax, [icons32_image] + test eax, eax + jz .i32_set + + mov ebx, [eax + Image.Width] + mov eax, [eax + Image.Height] + test ebx, ebx + jz .i32_set + xor edx, edx + div ebx + mov ecx, eax + + .i32_set: + mov [edi + META_I32_W], ebx + mov [edi + META_I32_C], ecx + xor ebx, ebx + xor ecx, ecx + mov eax, [icons18_image] + test eax, eax + jz .i18_set + mov ebx, [eax + Image.Width] + mov eax, [eax + Image.Height] + test ebx, ebx + jz .i18_set + xor edx, edx + div ebx + mov ecx, eax + + .i18_set: + mov [edi + META_I18_W], ebx + mov [edi + META_I18_C], ecx + mov [edi + META_I18W_W], ebx + mov [edi + META_I18W_C], ecx + + mov dword [edi + META_CBOX_W], CHBOX_WIDTH + mov dword [edi + META_CBOX_H], CHBOX_HEIGHT + mov dword [edi + META_CBOX_SIZE], CHBOX_IMG_SIZE + + .meta_done: + DEBUGF DBG_INFO, "@reshare: starting in daemon mode\n" + + mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, CHBOX_IMG_SIZE, SHM_CREATE + SHM_WRITE + test eax, eax + jz .skip_cbox + mov esi, cbox_image + mov edi, eax + mov ecx, CHBOX_IMG_SIZE + cld + rep movsb + .skip_cbox: + + cmp [icons32_image], 0 + jz .skip_i32 + stdcall copy_image_to_shm, lb_tab_i32, size32, icons32_image + test eax, eax + jz .skip_i32 + invoke img.destroy, [icons32_image] + .skip_i32: + + cmp [icons18_image], 0 + jz .skip_i18 + stdcall copy_image_to_shm, lb_tab_i18, size18, icons18_image + test eax, eax + jz .skip_i18 + + mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_i18w, [size18], SHM_CREATE + SHM_WRITE + test eax, eax + jz .skip_i18 + mov [shared_i18w], eax + .skip_i18: + + mcall SF_SET_EVENTS_MASK, EVM_BACKGROUND + + .event_loop: + push [sc.work] + mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, sizeof.system_colors + pop eax + cmp eax, [sc.work] + je .wait_event + cmp [icons18_image], 0 + jz .wait_event + cmp [shared_i18w], 0 + jz .wait_event + mov ebx, [icons18_image] + mov esi, [ebx + Image.Data] + mov edi, [shared_i18w] + mov ecx, [size18] + shr ecx, 2 ; / 4 to get size in dwords + cld + rep movsd + stdcall replace_2cols, [shared_i18w], [size18], 0xFFFFFFFF, [sc.work], 0xFFCACBD6, [sc.work_dark] + + .wait_event: + mcall SF_WAIT_EVENT + cmp eax, EV_BACKGROUND + je .event_loop + jmp .wait_event + +; ================================================================ + +proc load_icons stdcall uses ebx ecx, _path, _img_ptr, _size_ptr + invoke img.from_file, [_path] + test eax, eax + jz .fail + + mov ebx, [_img_ptr] + mov [ebx], eax + mov ebx, [eax + Image.Width] + mov ecx, [eax + Image.Height] + imul ecx, ebx + shl ecx, 2 ; * 4 to get size in bytes + mov ebx, [_size_ptr] + mov [ebx], ecx + + ret + + .fail: + DEBUGF DBG_ERR, "@reshare: error loading icons from %s\", [_path] + + ret +endp + + +proc copy_image_to_shm stdcall uses ebx ecx edx esi edi, _shm_name, _size_ptr, _image_ptr + mov edx, [_size_ptr] + mov edx, [edx] + mcall SF_SYS_MISC, SSF_MEM_OPEN, [_shm_name], edx, SHM_CREATE + SHM_WRITE + test eax, eax + jz .done + mov ebx, [_image_ptr] + mov ebx, [ebx] + mov esi, [ebx + Image.Data] + mov edi, eax + mov ecx, [_size_ptr] + mov ecx, [ecx] + shr ecx, 2 ; / 4 to get size in dwords + cld + rep movsd + + .done: + ret +endp + + +proc replace_2cols stdcall uses edi, imgsrc, imgsize, color_old_1, color_new_1, color_old_2, color_new_2 + mov edx, [imgsize] + add edx, [imgsrc] + mov edi, [imgsrc] + + .loop: + cmp edi, edx + jae .done + mov eax, [edi] + cmp eax, [color_old_1] + jne .check_second + mov eax, [color_new_1] + mov [edi], eax + jmp .next + + .check_second: + cmp eax, [color_old_2] + jne .next + mov eax, [color_new_2] + mov [edi], eax + + .next: + add edi, 4 + jmp .loop + .done: + + ret +endp + +; ================================================================ + +ICON_32_SIZE = 32 +ICON_18_SIZE = 18 + +BORD = 5 +PAD = 8 +GAP = 12 + +GRID_COLS = 16 +GRID_ROWS = 9 + +RES_Y = BTN.Y + BTN.H + PAD * 2 + 1 +TAB_STEP = BTN.W + PAD * 2 + +WIN RECT 80, 50, GRID.W + PAD * 2 + BORD * 2, 638 +BTN RECT 0, PAD + 4, CELL.W * 4 - PAD * 2 , 22 +CELL RECT 0, 0, 32 + PAD * 2 , 60 + +GRID RECT PAD, RES_Y + PAD, CELL.W * GRID_COLS - PAD * 2, CELL.H * GRID_ROWS + +FONT_TYPE = 0x90 +BTN_HIDE = 0x60000000 + +; ================================================================ + +if lang eq ru_RU + + title cp866 "@RESHARE - Служба общих ресурсов", 0 + lb_info cp866 "Имя каждой вкладки соответствует имени области памяти, доступной через сисфункцию 68.22.", 0 + +else if lang eq es_ES + + title db "@RESHARE - Servicio de recursos compartidos", 0 + lb_info db "Cada nombre de pestana corresponde al nombre de memoria accesible mediante sysfunc 68.22.", 0 + +else + + title cp850 "@RESHARE - Shared resources service", 0 + lb_info cp850 "Each tab name corresponds to shared memory page name that can be accessed via sysfunc 68.22.", 0 + +endf + +lb_tab_i32 db "ICONS32", 0 +lb_tab_i18 db "ICONS18", 0 +lb_tab_i18w db "ICONS18W", 0 +lb_tab_cbox db "CHECKBOX", 0 + +lb_tab_i32_res db "32x32x32bpp", 0 +lb_tab_i18_res db "18x18x32bpp", 0 +lb_tab_i18w_res db "18x18x32bpp", 0 +lb_tab_cbox_res db "13x13x24bpp", 0 + +dg_icons32_fail db "@reshare: error, icons32 not found in %s\n", 0 +dg_icons18_fail db "@reshare: error, icons18 not found in %s\n", 0 + +; ================================================================ + +DBG_ALL = 0 ; all messages +DBG_INFO = 1 ; info and errors +DBG_ERR = 2 ; only errors + +__DEBUG__ = 1 +__DEBUG_LEVEL__ = DBG_ERR + +SHM_OPEN = 0x00 +SHM_READ = 0x00 +SHM_WRITE = 0x01 +SHM_OPEN_ALWAYS = 0x04 +SHM_CREATE = 0x08 + +ACTIVE_ICONS32 = 1 +ACTIVE_ICONS18 = 2 +ACTIVE_ICONS18W = 4 +ACTIVE_CHECKBOX = 8 + +TAB_COUNT = 4 + +META_I32_C = 0 +META_I32_W = 4 +META_I18_C = 8 +META_I18_W = 12 +META_I18W_C = 16 +META_I18W_W = 20 +META_CBOX_W = 24 +META_CBOX_H = 28 +META_CBOX_SIZE = 32 +META_SIZE = 36 + +tab_masks dd ACTIVE_ICONS32, ACTIVE_ICONS18, ACTIVE_ICONS18W, ACTIVE_CHECKBOX + +; ================================================================ + +meta_name db "RESHARE_META", 0 + +icons32_path db "/SYS/ICONS32.PNG", 0 +icons18_path db "/SYS/ICONS16.PNG", 0 + +; pointers to Image structures +icons32_image dd 0 +icons18_image dd 0 + +; sizes of icons image data in bytes +size32 dd 0 +size18 dd 0 + +; currenly selected i18w section +shared_i18w dd 0 + +active_tab dd ACTIVE_ICONS32 + +sc system_colors + +thread_info process_information +thread_name rb 16 + +include_debug_strings + +; ================================================================ + +I_END: + rb 4096 + align 16 +STACKTOP: + +MEM: -- 2.49.1 From 9093ef356645e23c4efca26b1affb2e695191a7c Mon Sep 17 00:00:00 2001 From: Burer Date: Tue, 3 Feb 2026 12:24:52 +0200 Subject: [PATCH 03/10] apps/reshare: rewert broken files rename in data/Tupfile.lua --- data/Tupfile.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/Tupfile.lua b/data/Tupfile.lua index d8ad3d8eb..eb26a3b8c 100644 --- a/data/Tupfile.lua +++ b/data/Tupfile.lua @@ -29,7 +29,7 @@ img_files = { {"ALLGAMES", "common/allgames"}, {"HOME.PNG", "common/wallpapers/T_Home.png"}, {"ICONS32.PNG", "common/icons32.png"}, - {"ICONS18.PNG", "common/icons18.png"}, + {"ICONS16.PNG", "common/icons16.png"}, {"INDEX.HTM", "common/index_htm"}, {"KUZKINA.MID", "common/kuzkina.mid"}, {"SINE.MP3", "common/sine.mp3"}, -- 2.49.1 From b75f836a4f09b57f08ee6aa226269037ccf538e0 Mon Sep 17 00:00:00 2001 From: Burer Date: Tue, 3 Feb 2026 13:17:38 +0200 Subject: [PATCH 04/10] apps/reshare: fix autobuild and code formatting --- programs/system/reshare/reshare.asm | 44 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/programs/system/reshare/reshare.asm b/programs/system/reshare/reshare.asm index 550774f23..935f19836 100644 --- a/programs/system/reshare/reshare.asm +++ b/programs/system/reshare/reshare.asm @@ -7,12 +7,12 @@ ; Contributor rgmaid - Main code ; Contributor Burer - Refactoring and localization -; ================================================================ +; ==================================================================== use32 org 0 -; ================================================================ +; ==================================================================== db "MENUET01" dd 1 @@ -23,28 +23,28 @@ dd STACKTOP dd 0 dd 0 -; ================================================================ +; ==================================================================== -include "../macros.inc" -include "../KOSfuncs.inc" -include "../encoding.inc" -include "../proc32.inc" -include "../dll.inc" -include "../string.inc" -include "../debug-fdo.inc" +include "../../macros.inc" +include "../../KOSfuncs.inc" +include "../../encoding.inc" +include "../../proc32.inc" +include "../../dll.inc" +include "../../string.inc" +include "../../debug-fdo.inc" -include "../libimg.inc" +include "../develop/libraries/libs-dev/libimg/libimg.inc" include "checkbox.inc" -; ================================================================ +; ==================================================================== LIBS: library img, "libimg.obj" import img, img.destroy, "img_destroy", \ img.from_file, "img_from_file" -; ================================================================ +; ==================================================================== START: mcall SF_KEYBOARD, SSF_SET_INPUT_MODE, 1 @@ -60,7 +60,7 @@ START: .exit: mcall SF_TERMINATE_PROCESS -; ================================================================ +; ==================================================================== MODE_GUI: @@ -166,7 +166,7 @@ MODE_GUI: .event_exit: mcall SF_TERMINATE_PROCESS -; ================================================================ +; ==================================================================== proc draw_tabs stdcall ; draw tabs headers underlines @@ -346,7 +346,7 @@ proc draw_tab_cbox stdcall ret endp -; ================================================================ +; ==================================================================== MODE_DAEMON: @@ -464,7 +464,7 @@ MODE_DAEMON: je .event_loop jmp .wait_event -; ================================================================ +; ==================================================================== proc load_icons stdcall uses ebx ecx, _path, _img_ptr, _size_ptr invoke img.from_file, [_path] @@ -539,7 +539,7 @@ proc replace_2cols stdcall uses edi, imgsrc, imgsize, color_old_1, color_new_1, ret endp -; ================================================================ +; ==================================================================== ICON_32_SIZE = 32 ICON_18_SIZE = 18 @@ -563,7 +563,7 @@ GRID RECT PAD, RES_Y + PAD, CELL.W * GRID_COLS - PAD * 2, CELL.H * FONT_TYPE = 0x90 BTN_HIDE = 0x60000000 -; ================================================================ +; ==================================================================== if lang eq ru_RU @@ -595,7 +595,7 @@ lb_tab_cbox_res db "13x13x24bpp", 0 dg_icons32_fail db "@reshare: error, icons32 not found in %s\n", 0 dg_icons18_fail db "@reshare: error, icons18 not found in %s\n", 0 -; ================================================================ +; ==================================================================== DBG_ALL = 0 ; all messages DBG_INFO = 1 ; info and errors @@ -630,7 +630,7 @@ META_SIZE = 36 tab_masks dd ACTIVE_ICONS32, ACTIVE_ICONS18, ACTIVE_ICONS18W, ACTIVE_CHECKBOX -; ================================================================ +; ==================================================================== meta_name db "RESHARE_META", 0 @@ -657,7 +657,7 @@ thread_name rb 16 include_debug_strings -; ================================================================ +; ==================================================================== I_END: rb 4096 -- 2.49.1 From 916df5a769f19be9283f2994d33ef228baf3fbd5 Mon Sep 17 00:00:00 2001 From: Burer Date: Tue, 3 Feb 2026 13:25:11 +0200 Subject: [PATCH 05/10] apps/reshare: fix to previous --- programs/system/reshare/reshare.asm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/programs/system/reshare/reshare.asm b/programs/system/reshare/reshare.asm index 935f19836..809f25aa3 100644 --- a/programs/system/reshare/reshare.asm +++ b/programs/system/reshare/reshare.asm @@ -33,7 +33,7 @@ include "../../dll.inc" include "../../string.inc" include "../../debug-fdo.inc" -include "../develop/libraries/libs-dev/libimg/libimg.inc" +include "../../develop/libraries/libs-dev/libimg/libimg.inc" include "checkbox.inc" -- 2.49.1 From f676109eeaa6c5cc80e60f3f141ad0c587dc729d Mon Sep 17 00:00:00 2001 From: Burer Date: Thu, 5 Feb 2026 09:03:57 +0200 Subject: [PATCH 06/10] apps/reshare: RAM optimization, code cleanup, prefixes for debug logs --- programs/system/reshare/reshare.asm | 76 ++++++++++------------------- 1 file changed, 27 insertions(+), 49 deletions(-) diff --git a/programs/system/reshare/reshare.asm b/programs/system/reshare/reshare.asm index 809f25aa3..ebc4a1fec 100644 --- a/programs/system/reshare/reshare.asm +++ b/programs/system/reshare/reshare.asm @@ -30,7 +30,6 @@ include "../../KOSfuncs.inc" include "../../encoding.inc" include "../../proc32.inc" include "../../dll.inc" -include "../../string.inc" include "../../debug-fdo.inc" include "../../develop/libraries/libs-dev/libimg/libimg.inc" @@ -47,10 +46,11 @@ LIBS: ; ==================================================================== START: - mcall SF_KEYBOARD, SSF_SET_INPUT_MODE, 1 mcall SF_SYS_MISC, SSF_HEAP_INIT + mcall SF_KEYBOARD, SSF_SET_INPUT_MODE, 1 + ; check if this is second instance of app. if so - run gui, else - run daemon mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, 0, SHM_OPEN + SHM_READ test eax, eax @@ -112,7 +112,7 @@ MODE_GUI: mcall , , , lb_tab_i18_res mcall , , , lb_tab_i18w mcall , , , - mcall , , , lb_tab_i18w_res + mcall , , , lb_tab_i18_res mcall , , , lb_tab_cbox mcall , , , mcall , , , lb_tab_cbox_res @@ -124,7 +124,7 @@ MODE_GUI: mcall , , , 10 + BTN_HIDE + ACTIVE_CHECKBOX ; tabs content - stdcall draw_tabs + call draw_tabs mcall SF_REDRAW, SSF_END_DRAW @@ -143,7 +143,7 @@ MODE_GUI: mov [active_tab], 1 .tab_draw: - stdcall draw_tabs + call draw_tabs jmp .event_loop @@ -158,7 +158,7 @@ MODE_GUI: movzx eax, ah sub eax, 10 mov [active_tab], eax - stdcall draw_tabs + call draw_tabs jmp .event_loop @@ -168,7 +168,8 @@ MODE_GUI: ; ==================================================================== -proc draw_tabs stdcall +draw_tabs: + ; draw tabs headers underlines mov esi, [active_tab] xor edi, edi @@ -218,7 +219,6 @@ proc draw_tabs stdcall .tab_cbox: stdcall draw_tab_cbox ret -endp proc draw_tab_icons stdcall uses ebx ecx, _shm_name, _meta_c_off, _meta_w_off @@ -249,6 +249,9 @@ proc draw_tab_icons stdcall uses ebx ecx, _shm_name, _meta_c_off, _meta_w_off stdcall draw_tab_icons_grid, ebx, ecx, edx + mcall SF_SYS_MISC, SSF_MEM_CLOSE, [_shm_name] + mcall SF_SYS_MISC, SSF_MEM_CLOSE, meta_name + .done: ret endp @@ -285,7 +288,7 @@ endl jae .end_for_icons push ecx - ; SF_PUT_IMAGE_EXT, _icon_img+icon_size*index, <_icon_w, _icon_w>, , 32, 0, 0 + ; SF_PUT_IMAGE_EXT _icon_img+icon_size*index, <_icon_w, _icon_w>, , 32, 0, 0 mov ebx, [icon_size] imul ebx, ecx add ebx, [_icon_img] @@ -306,7 +309,7 @@ endl pop ebp pop edi - ; draw number, centered in CELL.W + ; DrawNumber with no leading zeros, centered in CELL.W mov edx, [x] add edx, GAP shl edx, 16 @@ -342,6 +345,8 @@ proc draw_tab_cbox stdcall , \ <(WIN.W - CHBOX_WIDTH)/2, (WIN.H - RES_Y - CHBOX_HEIGHT)/2 + RES_Y> + mcall SF_SYS_MISC, SSF_MEM_CLOSE, lb_tab_cbox + .done: ret endp @@ -353,7 +358,7 @@ MODE_DAEMON: stdcall dll.Load, LIBS ; load shared resources from files - DEBUGF DBG_INFO, "@reshare: loading resources...\n" + DEBUGF DBG_INFO, "I: @reshare: loading resources...\n" stdcall load_icons, icons32_path, icons32_image, size32 stdcall load_icons, icons18_path, icons18_image, size18 @@ -405,14 +410,14 @@ MODE_DAEMON: mov dword [edi + META_CBOX_SIZE], CHBOX_IMG_SIZE .meta_done: - DEBUGF DBG_INFO, "@reshare: starting in daemon mode\n" + DEBUGF DBG_INFO, "I: @reshare: starting in daemon mode\n" mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, CHBOX_IMG_SIZE, SHM_CREATE + SHM_WRITE test eax, eax jz .skip_cbox - mov esi, cbox_image + mov esi, cbox_image mov edi, eax - mov ecx, CHBOX_IMG_SIZE + mov ecx, CBOX_IMG_SIZE cld rep movsb .skip_cbox: @@ -430,11 +435,15 @@ MODE_DAEMON: stdcall copy_image_to_shm, lb_tab_i18, size18, icons18_image test eax, eax jz .skip_i18 + mov [shared_i18], eax mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_i18w, [size18], SHM_CREATE + SHM_WRITE test eax, eax jz .skip_i18 mov [shared_i18w], eax + + invoke img.destroy, [icons18_image] + mov dword [icons18_image], 0 .skip_i18: mcall SF_SET_EVENTS_MASK, EVM_BACKGROUND @@ -445,12 +454,11 @@ MODE_DAEMON: pop eax cmp eax, [sc.work] je .wait_event - cmp [icons18_image], 0 + cmp [shared_i18], 0 jz .wait_event cmp [shared_i18w], 0 jz .wait_event - mov ebx, [icons18_image] - mov esi, [ebx + Image.Data] + mov esi, [shared_i18] mov edi, [shared_i18w] mov ecx, [size18] shr ecx, 2 ; / 4 to get size in dwords @@ -483,33 +491,12 @@ proc load_icons stdcall uses ebx ecx, _path, _img_ptr, _size_ptr ret .fail: - DEBUGF DBG_ERR, "@reshare: error loading icons from %s\", [_path] + DEBUGF DBG_ERR, "E: @reshare: error loading icons from %s\", [_path] ret endp -proc copy_image_to_shm stdcall uses ebx ecx edx esi edi, _shm_name, _size_ptr, _image_ptr - mov edx, [_size_ptr] - mov edx, [edx] - mcall SF_SYS_MISC, SSF_MEM_OPEN, [_shm_name], edx, SHM_CREATE + SHM_WRITE - test eax, eax - jz .done - mov ebx, [_image_ptr] - mov ebx, [ebx] - mov esi, [ebx + Image.Data] - mov edi, eax - mov ecx, [_size_ptr] - mov ecx, [ecx] - shr ecx, 2 ; / 4 to get size in dwords - cld - rep movsd - - .done: - ret -endp - - proc replace_2cols stdcall uses edi, imgsrc, imgsize, color_old_1, color_new_1, color_old_2, color_new_2 mov edx, [imgsize] add edx, [imgsrc] @@ -541,9 +528,6 @@ endp ; ==================================================================== -ICON_32_SIZE = 32 -ICON_18_SIZE = 18 - BORD = 5 PAD = 8 GAP = 12 @@ -589,12 +573,8 @@ lb_tab_cbox db "CHECKBOX", 0 lb_tab_i32_res db "32x32x32bpp", 0 lb_tab_i18_res db "18x18x32bpp", 0 -lb_tab_i18w_res db "18x18x32bpp", 0 lb_tab_cbox_res db "13x13x24bpp", 0 -dg_icons32_fail db "@reshare: error, icons32 not found in %s\n", 0 -dg_icons18_fail db "@reshare: error, icons18 not found in %s\n", 0 - ; ==================================================================== DBG_ALL = 0 ; all messages @@ -646,15 +626,13 @@ size32 dd 0 size18 dd 0 ; currenly selected i18w section +shared_i18 dd 0 shared_i18w dd 0 active_tab dd ACTIVE_ICONS32 sc system_colors -thread_info process_information -thread_name rb 16 - include_debug_strings ; ==================================================================== -- 2.49.1 From 084110a2ba750739e946ca6b678ceb1177e2f260 Mon Sep 17 00:00:00 2001 From: Burer Date: Thu, 5 Feb 2026 09:24:01 +0200 Subject: [PATCH 07/10] apps/reshare: fix to previous --- programs/system/reshare/checkbox.inc | 8 ++++---- programs/system/reshare/reshare.asm | 16 ++++++++-------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/programs/system/reshare/checkbox.inc b/programs/system/reshare/checkbox.inc index 5ce1cd5ad..88eb8796d 100644 --- a/programs/system/reshare/checkbox.inc +++ b/programs/system/reshare/checkbox.inc @@ -8,10 +8,10 @@ ; ==================================================================== -CHBOX_WIDTH = 13 -CHBOX_HEIGHT = 13 -CHBOX_PIXELS = CHBOX_WIDTH * CHBOX_HEIGHT -CHBOX_IMG_SIZE = CHBOX_PIXELS * 3 ; 24-bpp RGB, tight rows +CBOX_WIDTH = 13 +CBOX_HEIGHT = 13 +CBOX_PIXELS = CBOX_WIDTH * CBOX_HEIGHT +CBOX_IMG_SIZE = CBOX_PIXELS * 3 ; 24-bpp RGB, tight rows ; ==================================================================== diff --git a/programs/system/reshare/reshare.asm b/programs/system/reshare/reshare.asm index ebc4a1fec..a82be8f23 100644 --- a/programs/system/reshare/reshare.asm +++ b/programs/system/reshare/reshare.asm @@ -288,7 +288,7 @@ endl jae .end_for_icons push ecx - ; SF_PUT_IMAGE_EXT _icon_img+icon_size*index, <_icon_w, _icon_w>, , 32, 0, 0 + ; SF_PUT_IMAGE_EXT _icon_img+icon_size*index, <_icon_w, _icon_w>, , 32, 0, 0 mov ebx, [icon_size] imul ebx, ecx add ebx, [_icon_img] @@ -342,8 +342,8 @@ proc draw_tab_cbox stdcall jz .done mov ebx, eax mcall SF_PUT_IMAGE, , \ - , \ - <(WIN.W - CHBOX_WIDTH)/2, (WIN.H - RES_Y - CHBOX_HEIGHT)/2 + RES_Y> + , \ + <(WIN.W - CBOX_WIDTH)/2, (WIN.H - RES_Y - CBOX_HEIGHT)/2 + RES_Y> mcall SF_SYS_MISC, SSF_MEM_CLOSE, lb_tab_cbox @@ -405,17 +405,17 @@ MODE_DAEMON: mov [edi + META_I18W_W], ebx mov [edi + META_I18W_C], ecx - mov dword [edi + META_CBOX_W], CHBOX_WIDTH - mov dword [edi + META_CBOX_H], CHBOX_HEIGHT - mov dword [edi + META_CBOX_SIZE], CHBOX_IMG_SIZE + mov dword [edi + META_CBOX_W], CBOX_WIDTH + mov dword [edi + META_CBOX_H], CBOX_HEIGHT + mov dword [edi + META_CBOX_SIZE], CBOX_IMG_SIZE .meta_done: DEBUGF DBG_INFO, "I: @reshare: starting in daemon mode\n" - mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, CHBOX_IMG_SIZE, SHM_CREATE + SHM_WRITE + mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, CBOX_IMG_SIZE, SHM_CREATE + SHM_WRITE test eax, eax jz .skip_cbox - mov esi, cbox_image + mov esi, cbox_image mov edi, eax mov ecx, CBOX_IMG_SIZE cld -- 2.49.1 From 7ec23b14001f342a3999a91bf4246bb0470c8201 Mon Sep 17 00:00:00 2001 From: Burer Date: Thu, 5 Feb 2026 10:37:15 +0200 Subject: [PATCH 08/10] apps/reshare: fix to previous --- programs/system/reshare/reshare.asm | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/programs/system/reshare/reshare.asm b/programs/system/reshare/reshare.asm index a82be8f23..8ed54a871 100644 --- a/programs/system/reshare/reshare.asm +++ b/programs/system/reshare/reshare.asm @@ -491,12 +491,33 @@ proc load_icons stdcall uses ebx ecx, _path, _img_ptr, _size_ptr ret .fail: - DEBUGF DBG_ERR, "E: @reshare: error loading icons from %s\", [_path] + DEBUGF DBG_ERR, "E: @reshare: error loading icons from %s\n", [_path] ret endp +proc copy_image_to_shm stdcall uses ebx ecx edx esi edi, _shm_name, _size_ptr, _image_ptr + mov edx, [_size_ptr] + mov edx, [edx] + mcall SF_SYS_MISC, SSF_MEM_OPEN, [_shm_name], edx, SHM_CREATE + SHM_WRITE + test eax, eax + jz .done + mov ebx, [_image_ptr] + mov ebx, [ebx] + mov esi, [ebx + Image.Data] + mov edi, eax + mov ecx, [_size_ptr] + mov ecx, [ecx] + shr ecx, 2 ; / 4 to get size in dwords + cld + rep movsd + + .done: + ret +endp + + proc replace_2cols stdcall uses edi, imgsrc, imgsize, color_old_1, color_new_1, color_old_2, color_new_2 mov edx, [imgsize] add edx, [imgsrc] -- 2.49.1 From 0380ec11575949c8c5b8a45461f87ae34a3dc123 Mon Sep 17 00:00:00 2001 From: Burer Date: Sun, 8 Mar 2026 13:08:51 +0200 Subject: [PATCH 09/10] apps/reshare: code refactoring, creds cleanup Co-authored-by: @rgimad --- programs/system/reshare/checkbox.inc | 77 ++++---- programs/system/reshare/reshare.asm | 273 +++++++++++++++------------ 2 files changed, 192 insertions(+), 158 deletions(-) diff --git a/programs/system/reshare/checkbox.inc b/programs/system/reshare/checkbox.inc index 88eb8796d..b14363270 100644 --- a/programs/system/reshare/checkbox.inc +++ b/programs/system/reshare/checkbox.inc @@ -1,40 +1,23 @@ ; SPDX-License-Identifier: GPL-2.0-only ; ; Reshare - Shared Resources Daemon -; Copyright (C) 2024 KolibriOS-NG Team ; -; Contributor rgmaid - Main code -; Contributor Burer - Image conversion from 8bpp +; Copyright (C) 2024-2026 KolibriOS Team +; Copyright (C) 2024-2026 KolibriOS-NG Team ; ==================================================================== CBOX_WIDTH = 13 CBOX_HEIGHT = 13 CBOX_PIXELS = CBOX_WIDTH * CBOX_HEIGHT -CBOX_IMG_SIZE = CBOX_PIXELS * 3 ; 24-bpp RGB, tight rows +CBOX_IMG_SIZE = CBOX_PIXELS * 3 ; 24-bpp BGR, tight rows ; ==================================================================== -macro RGB24 c +; Palette entry: 4 bytes BGR0 (padded for dword-indexed lookup) +macro BGRA c { - db (c) and 0xFF, (c shr 8) and 0xFF, (c shr 16) and 0xFF -} - -macro ROW13 c00, c01, c02, c03, c04, c05, c06, c07, c08, c09, c10, c11, c12 -{ - RGB24 c00 - RGB24 c01 - RGB24 c02 - RGB24 c03 - RGB24 c04 - RGB24 c05 - RGB24 c06 - RGB24 c07 - RGB24 c08 - RGB24 c09 - RGB24 c10 - RGB24 c11 - RGB24 c12 + db (c) and 0xFF, (c shr 8) and 0xFF, (c shr 16) and 0xFF, 0 } P00 = 0x04D4FC ; 0xRRGGBB @@ -54,18 +37,36 @@ P13 = 0x0464BC P14 = 0x2CDCFC P15 = 0x049FFA -cbox_image: - ROW13 P00, P00, P00, P00, P00, P00, P00, P00, P00, P00, P00, P00, P01 - ROW13 P02, P01, P01, P01, P01, P01, P01, P01, P01, P01, P01, P01, P03 - ROW13 P02, P01, P01, P01, P01, P04, P04, P04, P03, P05, P05, P03, P03 - ROW13 P00, P01, P01, P01, P04, P04, P03, P03, P06, P07, P07, P08, P03 - ROW13 P00, P03, P05, P05, P03, P03, P03, P06, P09, P10, P11, P06, P03 - ROW13 P00, P05, P07, P07, P06, P03, P06, P09, P10, P12, P13, P06, P05 - ROW13 P00, P06, P10, P09, P14, P06, P09, P10, P12, P13, P06, P15, P05 - ROW13 P00, P06, P12, P10, P09, P09, P10, P12, P13, P06, P15, P05, P05 - ROW13 P00, P06, P13, P12, P10, P10, P12, P13, P06, P15, P05, P05, P05 - ROW13 P01, P08, P06, P13, P12, P12, P13, P06, P15, P05, P05, P05, P15 - ROW13 P01, P05, P15, P06, P13, P13, P06, P15, P05, P05, P05, P15, P15 - ROW13 P01, P05, P05, P15, P06, P06, P15, P05, P05, P05, P15, P15, P06 - ROW13 P03, P06, P06, P06, P06, P06, P06, P06, P06, P06, P06, P06, P06 -align 4 +cbox_palette: + BGRA P00 + BGRA P01 + BGRA P02 + BGRA P03 + BGRA P04 + BGRA P05 + BGRA P06 + BGRA P07 + BGRA P08 + BGRA P09 + BGRA P10 + BGRA P11 + BGRA P12 + BGRA P13 + BGRA P14 + BGRA P15 + +; 4-bit palette indices, one byte per pixel (upper nibble unused — values 0..15) +cbox_indexed: + db 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 ; row 1 + db 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3 ; row 2 + db 2, 1, 1, 1, 1, 4, 4, 4, 3, 5, 5, 3, 3 ; row 3 + db 0, 1, 1, 1, 4, 4, 3, 3, 6, 7, 7, 8, 3 ; row 4 + db 0, 3, 5, 5, 3, 3, 3, 6, 9,10,11, 6, 3 ; row 5 + db 0, 5, 7, 7, 6, 3, 6, 9,10,12,13, 6, 5 ; row 6 + db 0, 6,10, 9,14, 6, 9,10,12,13, 6,15, 5 ; row 7 + db 0, 6,12,10, 9, 9,10,12,13, 6,15, 5, 5 ; row 8 + db 0, 6,13,12,10,10,12,13, 6,15, 5, 5, 5 ; row 9 + db 1, 8, 6,13,12,12,13, 6,15, 5, 5, 5,15 ; row 10 + db 1, 5,15, 6,13,13, 6,15, 5, 5, 5,15,15 ; row 11 + db 1, 5, 5,15, 6, 6,15, 5, 5, 5,15,15, 6 ; row 12 + db 3, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6 ; row 13 diff --git a/programs/system/reshare/reshare.asm b/programs/system/reshare/reshare.asm index 8ed54a871..7e2fbebea 100644 --- a/programs/system/reshare/reshare.asm +++ b/programs/system/reshare/reshare.asm @@ -1,11 +1,9 @@ ; SPDX-License-Identifier: GPL-2.0-only ; ; Reshare - Shared Resources Daemon -; Copyright (C) 2024-2025 KolibriOS/-NG Team ; -; Contributor Leency - Original version in C-- -; Contributor rgmaid - Main code -; Contributor Burer - Refactoring and localization +; Copyright (C) 2024-2026 KolibriOS Team +; Copyright (C) 2024-2026 KolibriOS-NG Team ; ==================================================================== @@ -25,14 +23,14 @@ dd 0 ; ==================================================================== -include "../../macros.inc" -include "../../KOSfuncs.inc" -include "../../encoding.inc" -include "../../proc32.inc" -include "../../dll.inc" -include "../../debug-fdo.inc" +include "../macros.inc" +include "../KOSfuncs.inc" +include "../encoding.inc" +include "../proc32.inc" +include "../dll.inc" +include "../debug-fdo.inc" -include "../../develop/libraries/libs-dev/libimg/libimg.inc" +include "../libimg.inc" include "checkbox.inc" @@ -52,9 +50,10 @@ START: mcall SF_KEYBOARD, SSF_SET_INPUT_MODE, 1 ; check if this is second instance of app. if so - run gui, else - run daemon - mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, 0, SHM_OPEN + SHM_READ + mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, 0, SHM_READ test eax, eax jz MODE_DAEMON + mcall SF_SYS_MISC, SSF_MEM_CLOSE, meta_name jmp MODE_GUI .exit: @@ -87,41 +86,75 @@ MODE_GUI: mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, sizeof.system_colors mcall , SSF_GET_SKIN_HEIGHT - mov ecx, WIN.Y shl 16 + WIN.H - add ecx, eax + add eax, WIN.H + mov esi, eax + mcall SF_GET_SCREEN_SIZE + movzx ecx, ax + shr eax, 16 + sub eax, WIN.W + shr eax, 1 + shl eax, 16 + add eax, WIN.W + mov ebx, eax + sub ecx, esi + shr ecx, 1 + shl ecx, 16 + add ecx, esi mov edx, [sc.work] - add edx, 0x34000000 + add edx, WIN_STYLE - mcall SF_CREATE_WINDOW, , , , , title + mcall SF_CREATE_WINDOW, , , , , title ; visual dividers - mcall SF_DRAW_RECT, , , [sc.work_graph] + mcall SF_DRAW_RECT, , , [sc.work_graph] mcall , , , ; info row mov ecx, FONT_TYPE shl 24 add ecx, [sc.work_text] - mcall SF_DRAW_TEXT, , , lb_info + mcall SF_DRAW_TEXT, , , lb_info ; tabs labels - mcall , , , lb_tab_i32 - mcall , , , - mcall , , , lb_tab_i32_res - mcall , , , lb_tab_i18 - mcall , , , - mcall , , , lb_tab_i18_res - mcall , , , lb_tab_i18w - mcall , , , - mcall , , , lb_tab_i18_res - mcall , , , lb_tab_cbox - mcall , , , - mcall , , , lb_tab_cbox_res + mov esi, tab_label_strs + xor edi, edi + .tab_label_loop: + mov ebx, edi + imul ebx, TAB_STEP + push ebx + add ebx, PAD * 2 + shl ebx, 16 + add ebx, BTN.Y + mov edx, [esi] + mcall SF_DRAW_TEXT + add ebx, 1 shl 16 ; bold: x+1, same string + mcall SF_DRAW_TEXT + pop ebx + add ebx, PAD * 11 + shl ebx, 16 + add ebx, BTN.Y + mov edx, [esi + 4] + mcall SF_DRAW_TEXT + add esi, 8 + inc edi + cmp edi, TAB_COUNT + jb .tab_label_loop ; tabs buttons - mcall SF_DEFINE_BUTTON, , , 10 + BTN_HIDE + ACTIVE_ICONS32 - mcall , , , 10 + BTN_HIDE + ACTIVE_ICONS18 - mcall , , , 10 + BTN_HIDE + ACTIVE_ICONS18W - mcall , , , 10 + BTN_HIDE + ACTIVE_CHECKBOX + mov ecx, BTN.Y shl 16 + BTN.H + mov esi, ACTIVE_ICONS32 + xor edi, edi + .btn_loop: + mov ebx, edi + imul ebx, TAB_STEP + add ebx, PAD + shl ebx, 16 + add ebx, BTN.W + lea edx, [esi + BTN_BASE + BTN_HIDE] + mcall SF_DEFINE_BUTTON + add esi, esi ; 1→2→4→8 (next ACTIVE bit) + inc edi + cmp edi, TAB_COUNT + jb .btn_loop ; tabs content call draw_tabs @@ -134,7 +167,7 @@ MODE_GUI: .event_key: mcall SF_GET_KEY - cmp ah, 15 ; TAB + cmp ah, KEY_TAB jne .event_loop shl [active_tab], 1 ; * 2 @@ -156,7 +189,7 @@ MODE_GUI: je .event_exit movzx eax, ah - sub eax, 10 + sub eax, BTN_BASE mov [active_tab], eax call draw_tabs @@ -170,14 +203,13 @@ MODE_GUI: draw_tabs: - ; draw tabs headers underlines - mov esi, [active_tab] + ; draw tab underlines; active tab gets highlight color xor edi, edi + mov esi, 1 ; current tab bit (ACTIVE_ICONS32=1, then 2, 4, 8) .loop: mov edx, [sc.work_dark] - mov eax, [tab_masks + edi * 4] - test esi, eax + test [active_tab], esi jz .color_ok mov edx, [sc.work_button] @@ -190,6 +222,7 @@ draw_tabs: mcall SF_DRAW_RECT, ebx, ecx, edx inc edi + add esi, esi ; shift to next tab bit (1→2→4→8) cmp edi, TAB_COUNT jb .loop @@ -197,59 +230,46 @@ draw_tabs: mcall SF_DRAW_RECT, , , [sc.work] mov eax, [active_tab] - - .tab_i32: - cmp eax, ACTIVE_ICONS32 - jne .tab_i18 - stdcall draw_tab_icons, lb_tab_i32, META_I32_C, META_I32_W + bsf eax, eax ; 0=i32, 1=i18, 2=i18w, 3=cbox + cmp eax, 3 + je .cbox + lea esi, [tab_icon_args + eax * 8] + stdcall draw_tab_icons, [esi], [esi + 4] ret - .tab_i18: - cmp eax, ACTIVE_ICONS18 - jne .tab_i18w - stdcall draw_tab_icons, lb_tab_i18, META_I18_C, META_I18_W - ret - - .tab_i18w: - cmp eax, ACTIVE_ICONS18W - jne .tab_cbox - stdcall draw_tab_icons, lb_tab_i18w, META_I18W_C, META_I18W_W - ret - - .tab_cbox: + .cbox: stdcall draw_tab_cbox ret -proc draw_tab_icons stdcall uses ebx ecx, _shm_name, _meta_c_off, _meta_w_off - mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, 0, SHM_OPEN + SHM_READ +proc draw_tab_icons stdcall, _shm_name, _meta_off + mcall SF_SYS_MISC, SSF_MEM_OPEN, meta_name, 0, SHM_READ test eax, eax jz .done - mov ebx, [_meta_c_off] - mov ecx, [eax + ebx] ; icon_c - mov ebx, [_meta_w_off] - mov edx, [eax + ebx] ; icon_w + add eax, [_meta_off] + mov ecx, [eax] ; icon_c + mov edx, [eax + 4] ; icon_w (always next field: _meta_off + 4) test ecx, ecx - jz .done + jz .close_meta test edx, edx - jz .done + jz .close_meta push ecx push edx - mcall SF_SYS_MISC, SSF_MEM_OPEN, [_shm_name], 0, SHM_OPEN + SHM_READ + mcall SF_SYS_MISC, SSF_MEM_OPEN, [_shm_name], 0, SHM_READ pop edx pop ecx test eax, eax - jz .done + jz .close_meta - mov ebx, eax - - stdcall draw_tab_icons_grid, ebx, ecx, edx + stdcall draw_tab_icons_grid, eax, ecx, edx mcall SF_SYS_MISC, SSF_MEM_CLOSE, [_shm_name] + + .close_meta: mcall SF_SYS_MISC, SSF_MEM_CLOSE, meta_name .done: @@ -257,7 +277,7 @@ proc draw_tab_icons stdcall uses ebx ecx, _shm_name, _meta_c_off, _meta_w_off endp -proc draw_tab_icons_grid stdcall uses eax ebx ecx edx esi edi, _icon_img, _icon_c, _icon_w +proc draw_tab_icons_grid stdcall uses ebx esi edi, _icon_img, _icon_c, _icon_w locals x dd 0 x_off dd 0 @@ -276,10 +296,8 @@ endl shr eax, 1 mov [x_off], eax - ; y_step = icon_w + 28 - mov eax, [_icon_w] - add eax, 28 - mov edi, eax + ; y_step = CELL.H + mov edi, CELL.H xor ecx, ecx @@ -288,7 +306,7 @@ endl jae .end_for_icons push ecx - ; SF_PUT_IMAGE_EXT _icon_img+icon_size*index, <_icon_w, _icon_w>, , 32, 0, 0 + ; SF_PUT_IMAGE_EXT _icon_img+icon_size*index, <_icon_w, _icon_w>, , 32, 0, 0 mov ebx, [icon_size] imul ebx, ecx add ebx, [_icon_img] @@ -309,18 +327,18 @@ endl pop ebp pop edi - ; DrawNumber with no leading zeros, centered in CELL.W + ; draw number with no leading zeros, centered in CELL.W mov edx, [x] add edx, GAP shl edx, 16 add edx, [y] add edx, [_icon_w] - add edx, GRID.Y + 4 - mov esi, 0x10000000 + add edx, GRID.Y + 2 + mov esi, DRAWNUM_NOZERO add esi, [sc.work_graph] pop ecx - mcall SF_DRAW_NUMBER, 0x00030000, , , , + mcall SF_DRAW_NUMBER, DRAWNUM_DEC3, , , , inc ecx add [x], CELL.W @@ -337,16 +355,14 @@ endp proc draw_tab_cbox stdcall - mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, 0, SHM_OPEN + SHM_READ + mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, 0, SHM_READ test eax, eax jz .done mov ebx, eax mcall SF_PUT_IMAGE, , \ , \ - <(WIN.W - CBOX_WIDTH)/2, (WIN.H - RES_Y - CBOX_HEIGHT)/2 + RES_Y> - + <(WIN.W - CBOX_WIDTH)/2, (WIN.H - CBOX_HEIGHT)/2> mcall SF_SYS_MISC, SSF_MEM_CLOSE, lb_tab_cbox - .done: ret endp @@ -359,7 +375,6 @@ MODE_DAEMON: ; load shared resources from files DEBUGF DBG_INFO, "I: @reshare: loading resources...\n" - stdcall load_icons, icons32_path, icons32_image, size32 stdcall load_icons, icons18_path, icons18_image, size18 @@ -391,6 +406,7 @@ MODE_DAEMON: mov eax, [icons18_image] test eax, eax jz .i18_set + mov ebx, [eax + Image.Width] mov eax, [eax + Image.Height] test ebx, ebx @@ -415,14 +431,24 @@ MODE_DAEMON: mcall SF_SYS_MISC, SSF_MEM_OPEN, lb_tab_cbox, CBOX_IMG_SIZE, SHM_CREATE + SHM_WRITE test eax, eax jz .skip_cbox - mov esi, cbox_image mov edi, eax - mov ecx, CBOX_IMG_SIZE + mov esi, cbox_indexed + mov ecx, CBOX_PIXELS cld - rep movsb + .cbox_expand: + movzx ebx, byte [esi] + inc esi + mov eax, [cbox_palette + ebx * 4] + stosb ; B + shr eax, 8 + stosb ; G + shr eax, 8 + stosb ; R + dec ecx + jnz .cbox_expand .skip_cbox: - cmp [icons32_image], 0 + cmp [icons32_image], 0 jz .skip_i32 stdcall copy_image_to_shm, lb_tab_i32, size32, icons32_image test eax, eax @@ -472,7 +498,6 @@ MODE_DAEMON: je .event_loop jmp .wait_event -; ==================================================================== proc load_icons stdcall uses ebx ecx, _path, _img_ptr, _size_ptr invoke img.from_file, [_path] @@ -484,15 +509,13 @@ proc load_icons stdcall uses ebx ecx, _path, _img_ptr, _size_ptr mov ebx, [eax + Image.Width] mov ecx, [eax + Image.Height] imul ecx, ebx - shl ecx, 2 ; * 4 to get size in bytes + shl ecx, 2 mov ebx, [_size_ptr] mov [ebx], ecx - ret .fail: DEBUGF DBG_ERR, "E: @reshare: error loading icons from %s\n", [_path] - ret endp @@ -509,41 +532,36 @@ proc copy_image_to_shm stdcall uses ebx ecx edx esi edi, _shm_name, _size_ptr, _ mov edi, eax mov ecx, [_size_ptr] mov ecx, [ecx] - shr ecx, 2 ; / 4 to get size in dwords + shr ecx, 2 cld rep movsd - .done: ret endp -proc replace_2cols stdcall uses edi, imgsrc, imgsize, color_old_1, color_new_1, color_old_2, color_new_2 - mov edx, [imgsize] - add edx, [imgsrc] - mov edi, [imgsrc] - +proc replace_2cols stdcall uses edi, _imgsrc, _imgsize, _col_old1, _col_new1, _col_old2, _col_new2 + mov edx, [_imgsize] + add edx, [_imgsrc] + mov edi, [_imgsrc] .loop: cmp edi, edx jae .done mov eax, [edi] - cmp eax, [color_old_1] - jne .check_second - mov eax, [color_new_1] + cmp eax, [_col_old1] + jne .check2 + mov eax, [_col_new1] mov [edi], eax jmp .next - - .check_second: - cmp eax, [color_old_2] + .check2: + cmp eax, [_col_old2] jne .next - mov eax, [color_new_2] + mov eax, [_col_new2] mov [edi], eax - .next: add edi, 4 jmp .loop .done: - ret endp @@ -556,17 +574,25 @@ GAP = 12 GRID_COLS = 16 GRID_ROWS = 9 -RES_Y = BTN.Y + BTN.H + PAD * 2 + 1 +GRID_Y = BTN.Y + BTN.H + PAD * 2 + 1 TAB_STEP = BTN.W + PAD * 2 -WIN RECT 80, 50, GRID.W + PAD * 2 + BORD * 2, 638 -BTN RECT 0, PAD + 4, CELL.W * 4 - PAD * 2 , 22 -CELL RECT 0, 0, 32 + PAD * 2 , 60 +WIN RECT 0, 0, GRID.W + PAD * 2 + BORD * 2, GRID.H + GRID_Y + 1 + PAD + 10 + GAP +BTN RECT 0, PAD + 4, CELL.W * 4 - PAD * 2 , 22 +CELL RECT 0, 0, 32 + PAD * 2 , 32 + 4 + 10 + PAD -GRID RECT PAD, RES_Y + PAD, CELL.W * GRID_COLS - PAD * 2, CELL.H * GRID_ROWS +GRID RECT PAD, GRID_Y, CELL.W * GRID_COLS - PAD * 2, CELL.H * GRID_ROWS FONT_TYPE = 0x90 +WIN_STYLE = 0x34000000 ; skinned window, draws itself + BTN_HIDE = 0x60000000 +BTN_BASE = 10 ; first user-defined button ID + +DRAWNUM_DEC3 = 0x00030000 ; SF_DRAW_NUMBER: decimal, 3 digits +DRAWNUM_NOZERO = 0x10000000 ; SF_DRAW_NUMBER: no leading zeros + +KEY_TAB = 15 ; Tab key scan code ; ==================================================================== @@ -605,10 +631,8 @@ DBG_ERR = 2 ; only errors __DEBUG__ = 1 __DEBUG_LEVEL__ = DBG_ERR -SHM_OPEN = 0x00 SHM_READ = 0x00 SHM_WRITE = 0x01 -SHM_OPEN_ALWAYS = 0x04 SHM_CREATE = 0x08 ACTIVE_ICONS32 = 1 @@ -629,8 +653,6 @@ META_CBOX_H = 28 META_CBOX_SIZE = 32 META_SIZE = 36 -tab_masks dd ACTIVE_ICONS32, ACTIVE_ICONS18, ACTIVE_ICONS18W, ACTIVE_CHECKBOX - ; ==================================================================== meta_name db "RESHARE_META", 0 @@ -652,7 +674,18 @@ shared_i18w dd 0 active_tab dd ACTIVE_ICONS32 -sc system_colors +tab_icon_args: + dd lb_tab_i32, META_I32_C ; META_I32_W = META_I32_C + 4 + dd lb_tab_i18, META_I18_C ; META_I18_W = META_I18_C + 4 + dd lb_tab_i18w, META_I18W_C ; META_I18W_W = META_I18W_C + 4 + +tab_label_strs: + dd lb_tab_i32, lb_tab_i32_res + dd lb_tab_i18, lb_tab_i18_res + dd lb_tab_i18w, lb_tab_i18_res + dd lb_tab_cbox, lb_tab_cbox_res + +sc system_colors include_debug_strings -- 2.49.1 From eab5059e00e8aed86f916e2974f35d377f08687c Mon Sep 17 00:00:00 2001 From: Burer Date: Sun, 8 Mar 2026 13:13:07 +0200 Subject: [PATCH 10/10] apps/reshare: fix includes --- programs/system/reshare/reshare.asm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/programs/system/reshare/reshare.asm b/programs/system/reshare/reshare.asm index 7e2fbebea..d1e4ecb01 100644 --- a/programs/system/reshare/reshare.asm +++ b/programs/system/reshare/reshare.asm @@ -23,14 +23,14 @@ dd 0 ; ==================================================================== -include "../macros.inc" -include "../KOSfuncs.inc" -include "../encoding.inc" -include "../proc32.inc" -include "../dll.inc" -include "../debug-fdo.inc" +include "../../macros.inc" +include "../../KOSfuncs.inc" +include "../../encoding.inc" +include "../../proc32.inc" +include "../../dll.inc" +include "../../debug-fdo.inc" -include "../libimg.inc" +include "../../develop/libraries/libs-dev/libimg/libimg.inc" include "checkbox.inc" -- 2.49.1