diff --git a/data/Tupfile.lua b/data/Tupfile.lua index 1db764d16..e6635042d 100644 --- a/data/Tupfile.lua +++ b/data/Tupfile.lua @@ -49,8 +49,6 @@ img_files = { {"MEDIA/IMGF/INVSOL.OBJ", "common/media/ImgF/invSol.obj"}, {"MEDIA/PIXIESKN.PNG", SRC_PROGS .. "/cmm/pixie2/pixieskn.png"}, {"NETWORK/FTPC.INI", SRC_PROGS .. "/network/ftpc/ftpc.ini"}, - {"NETWORK/FTPC_SYS.PNG", SRC_PROGS .. "/network/ftpc/ftpc_sys.png"}, - {"NETWORK/FTPC_NOD.PNG", SRC_PROGS .. "/network/ftpc/ftpc_nod.png"}, {"NETWORK/FTPD.INI", "common/network/ftpd.ini"}, {"NETWORK/KNMAP", "common/network/knmap"}, {"NETWORK/USERS.INI", "common/network/users.ini"}, @@ -412,6 +410,7 @@ tup.append_table(img_files, { {"ACLOCK", VAR_PROGS .. "/demos/aclock/aclock"}, {"APM", VAR_PROGS .. "/system/apm/apm"}, {"CALC", VAR_PROGS .. "/other/calc/trunk/calc"}, + {"CALCPLUS", VAR_PROGS .. "/other/calcplus/calcplus"}, {"CALENDAR", VAR_PROGS .. "/system/calendar/trunk/calendar"}, {"COLRDIAL", VAR_PROGS .. "/system/colrdial/color_dialog"}, {"CROPFLAT", VAR_PROGS .. "/system/cropflat/cropflat"}, @@ -629,7 +628,6 @@ tup.append_table(extra_files, { {"kolibrios/media/zsea/plugins/rotate.obj", VAR_PROGS .. "/media/zsea/plugins/rotate/rotate.obj"}, {"kolibrios/media/zsea/plugins/scaling.obj", VAR_PROGS .. "/media/zsea/plugins/scaling/scaling.obj"}, {"kolibrios/utils/AMDtemp", VAR_PROGS .. "/system/amd_temp_view/AMDtemp"}, - {"kolibrios/utils/calcplus", VAR_PROGS .. "/other/calcplus/calcplus"}, {"kolibrios/utils/kfm/kfm", VAR_PROGS .. "/fs/kfm/trunk/kfm"}, {"kolibrios/utils/tedit/t_edit", VAR_PROGS .. "/other/t_edit/t_edit"}, {"kolibrios/3D/blocks/block.bin", VAR_PROGS .. "/bcc32/games/blocks/block.bin"} diff --git a/data/common/settings/app_plus.ini b/data/common/settings/app_plus.ini index c5a571062..97faf56db 100644 --- a/data/common/settings/app_plus.ini +++ b/data/common/settings/app_plus.ini @@ -29,7 +29,6 @@ Dicty=/k/utils/DICTY.KEX,79 fNav=/k/utils/fNav/fNav,93 CncEditor=/k/utils/cnc_editor/cnc_editor,15 Life=/k/demos/life2,13 -Calc+=/k/utils/calcplus,4 TinyBasic=/k/develop/TinyBasic/TinyBasic,91 THashView=/k/utils/thashview,124 Notes=/k/utils/notes,117 diff --git a/data/en_US/settings/icon.ini b/data/en_US/settings/icon.ini index 918208874..a52b7835f 100644 --- a/data/en_US/settings/icon.ini +++ b/data/en_US/settings/icon.ini @@ -235,8 +235,8 @@ ico=58 x=68 y=68 [21] -name=CALC -path=CALC +name=CALC+ +path=CALCPLUS param= ico=4 x=204 diff --git a/data/en_US/settings/menu.dat b/data/en_US/settings/menu.dat index d3fd5709a..0a08cde79 100644 --- a/data/en_US/settings/menu.dat +++ b/data/en_US/settings/menu.dat @@ -92,6 +92,7 @@ 59 Screen keyboard |zkey #10 **** DATA PROCESSING 16 Calculator |calc +16 Calculator+ |calcplus 03 Tinypad |tinypad 28 CodeEdit |develop/cedit 21 Table processor |table diff --git a/data/es_ES/settings/icon.ini b/data/es_ES/settings/icon.ini index 918208874..a52b7835f 100644 --- a/data/es_ES/settings/icon.ini +++ b/data/es_ES/settings/icon.ini @@ -235,8 +235,8 @@ ico=58 x=68 y=68 [21] -name=CALC -path=CALC +name=CALC+ +path=CALCPLUS param= ico=4 x=204 diff --git a/data/es_ES/settings/menu.dat b/data/es_ES/settings/menu.dat index 5ae082fe7..dd26b370d 100644 --- a/data/es_ES/settings/menu.dat +++ b/data/es_ES/settings/menu.dat @@ -96,6 +96,7 @@ 24 NDN * |/kolibrios/utils/ndn/ndn #11 **** PROCESO DE DATOS 16 Calculadora |calc +16 Calculadora+ |calcplus 16 Tinypad |tinypad 16 CodeEdit |develop/cedit 16 Procesador de tablas |table diff --git a/data/et_EE/settings/icon.ini b/data/et_EE/settings/icon.ini index 316e7459a..0e2a4d8ec 100644 --- a/data/et_EE/settings/icon.ini +++ b/data/et_EE/settings/icon.ini @@ -235,8 +235,8 @@ ico=58 x=68 y=68 [21] -name=CALC -path=CALC +name=CALC+ +path=CALCPLUS param= ico=4 x=204 diff --git a/data/et_EE/settings/menu.dat b/data/et_EE/settings/menu.dat index 56cc76124..58b4cadfd 100644 --- a/data/et_EE/settings/menu.dat +++ b/data/et_EE/settings/menu.dat @@ -80,6 +80,7 @@ 65 NDN * |/kolibrios/utils/ndn/ndn #11 **** DATA PROCESSING **** 16 Kalkulaator |calc +16 Kalkulaator+ |calcplus 16 Teksti redaktor |tinypad 16 CodeEdit |develop/cedit 16 Tabelarvutus |table diff --git a/data/it_IT/settings/icon.ini b/data/it_IT/settings/icon.ini index 918208874..a52b7835f 100644 --- a/data/it_IT/settings/icon.ini +++ b/data/it_IT/settings/icon.ini @@ -235,8 +235,8 @@ ico=58 x=68 y=68 [21] -name=CALC -path=CALC +name=CALC+ +path=CALCPLUS param= ico=4 x=204 diff --git a/data/it_IT/settings/menu.dat b/data/it_IT/settings/menu.dat index 95d6703b8..e3521b39b 100644 --- a/data/it_IT/settings/menu.dat +++ b/data/it_IT/settings/menu.dat @@ -79,6 +79,7 @@ 65 NDN * |/kolibrios/utils/ndn/ndn #11 **** DATA PROCESSING 16 Calcolatrice |calc +16 Calcolatrice+ |calcplus 16 Tinypad |tinypad 16 CodeEdit |develop/cedit 16 Table Processor |table diff --git a/data/ru_RU/settings/icon.ini b/data/ru_RU/settings/icon.ini index 3883986d9..c707f7bec 100644 --- a/data/ru_RU/settings/icon.ini +++ b/data/ru_RU/settings/icon.ini @@ -235,8 +235,8 @@ ico=58 x=68 y=68 [21] -name=CALC -path=CALC +name=CALC+ +path=CALCPLUS param= ico=4 x=204 diff --git a/data/ru_RU/settings/menu.dat b/data/ru_RU/settings/menu.dat index 33ba40721..b30d0589e 100644 --- a/data/ru_RU/settings/menu.dat +++ b/data/ru_RU/settings/menu.dat @@ -90,6 +90,7 @@ 59 Экранная клавиатура |zkey #10 **** Офис 16 Калькулятор |calc +16 Калькулятор+ |calcplus 03 Редактор Tinypad |tinypad 28 Редактор CodeEdit |develop/cedit 21 Табличный процессор |table diff --git a/programs/develop/charsets/Tupfile.lua b/programs/develop/charsets/Tupfile.lua index 3e4f662d6..a1cabfb8a 100644 --- a/programs/develop/charsets/Tupfile.lua +++ b/programs/develop/charsets/Tupfile.lua @@ -1,2 +1,4 @@ if tup.getconfig("NO_FASM") ~= "" then return end -tup.rule("charsets.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "charsets") +HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR") +tup.include(HELPERDIR .. "/use_fasm.lua") +tup.rule("charsets.asm", FASM .. " -dlang=" .. tup.getconfig("LANG") .. " %f %o" .. tup.getconfig("KPACK_CMD"), "%B") diff --git a/programs/develop/charsets/changelog.txt b/programs/develop/charsets/changelog.txt index 801a97083..8334cb93d 100644 --- a/programs/develop/charsets/changelog.txt +++ b/programs/develop/charsets/changelog.txt @@ -31,3 +31,19 @@ Development history - Renamed to Charsets Viewer/Charsets - Symbol highlight UI tweaks - Fixed rolled up bug + +30.03.2025 - 0.4.0 +- Localization for all system languages +- Display all character scales +- Abolity to copy character codes +- Block on charpage 00 for CP866 +- New character code half markers +- Navigation using keys (see hotkeys.txt) + +03.04.2025 - 0.4.1 +- Fixed bug with codes color subscription + +04.04.2025 - 0.4.2 +- Fixed bug with resetting UTF charpage to zero on double charset swap to CP866 +- Improved charpage blocking for CP866 UX +- Improved char codes copying UI diff --git a/programs/develop/charsets/charsets.asm b/programs/develop/charsets/charsets.asm index 73c233b63..3b4d9d5c6 100644 --- a/programs/develop/charsets/charsets.asm +++ b/programs/develop/charsets/charsets.asm @@ -1,562 +1,455 @@ ; SPDX-License-Identifier: GPL-2.0-only -; SPDX-FileCopyrightText: 2024-2025 KolibriOS Team +; +; Charsets - Charsets Viewer +; Copyright (C) 2025 KolibriOS team +; +; Contributor Burer - Main code +; Contributor Doczom - UTF-8 to UTF-16 convertor ; ================================================================ -format binary as "" use32 org 0 ; ================================================================ -db 'MENUET01' -dd 1 -dd START -dd I_END -dd MEM -dd STACKTOP -dd 0, 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" + +; ================================================================ START: ; start of execution call draw_window ; draw the window event_wait: - mov eax, 10 ; function 10 : wait until event - mcall ; event type is returned in eax - cmp eax, 1 ; Event redraw request - je red ; Expl.: there has been activity on screen and - ; parts of the applications has to be redrawn. - cmp eax, 2 ; Event key in buffer - je key ; Expl.: User has pressed a key while the - ; app is at the top of the window stack. - cmp eax, 3 ; Event button in buffer - je button ; Expl.: User has pressed one of the - ; applications buttons. + mcall SF_WAIT_EVENT + + cmp al, 1 + je red + cmp al, 2 + je key + cmp al, 3 + je button + jmp event_wait -red: ; Redraw event handler - call draw_window ; We call the window_draw function and - jmp event_wait ; jump back to event_wait +red: + call draw_window -key: ; Keypress event handler - mov eax, 2 ; The key is returned in ah. The key must be - mcall ; read and cleared from the system queue. - cmp eax, 1 ; Just read the key, ignore it and jump to event_wait. + jmp event_wait + +key: + mcall SF_GET_KEY + + ; no input + cmp al, 1 je event_wait - mov cl, [reading] - cmp cl, 0x00 - je event_wait - mov [char], ah - mov [page], 0x00 - push eax - shr ax, 8 - xor ah, ah - mov [char_ascii], ax - pop eax + + ; if not reading - skip + cmp [reading], 0x01 + je .read_input + + ; moving scancode to ah shr eax, 16 - mov [char_scan], ax - mov [letter], 0x0000 - call draw_update - jmp event_wait -button: ; Buttonpress event handler - mov eax, 17 ; The button number defined in window_draw - mcall + .key_pagedown: + cmp al, 81 + jne .key_pageup - .close: + call logic_charpage_dec + + jmp .key_end + + .key_pageup: + cmp al, 73 + jne .key_pagezero + + call logic_charpage_inc + + jmp .key_end + + .key_pagezero: + cmp al, 82 + jne .key_arr_left + + call logic_charpage_zero + + jmp .key_end + + .key_arr_left: + cmp al, 75 + jne .key_arr_right + + call logic_char_left + + jmp .key_end + + .key_arr_right: + cmp al, 77 + jne .key_arr_down + + call logic_char_right + + jmp .key_end + + .key_arr_down: + cmp al, 72 + jne .key_arr_up + + call logic_char_down + + jmp .key_end + + .key_arr_up: + cmp al, 80 + jne .key_scale_down + + call logic_char_up + + jmp .key_end + + .key_scale_down: + cmp al, 74 + jne .key_scale_up + + call logic_scale_down + + jmp .key_end + + .key_scale_up: + cmp al, 78 + jne .key_home + + call logic_scale_up + + jmp .key_end + + .key_home: + cmp al, 71 + jne .key_end + + call logic_charpage_zero + + jmp .key_end + + ; reading inputted char + .read_input: + mov [char], ah + mov [page], 0x00 + push eax + shr ax, 8 + xor ah, ah + mov [char_ascii], ax + pop eax + shr eax, 16 + mov [char_scan], ax + mov [letter], 0x0000 + + .key_end: + call logic_update + jmp event_wait + + +button: + mcall SF_GET_BUTTON + + .close: ; window close button cmp ah, 1 jne .button_a - mov eax, -1 - mcall - .button_a: ; select character + mcall SF_TERMINATE_PROCESS + + .button_a: ; 0A - select character cmp ah, 0x0A jne .button_b - mcall 37, 1 - push eax - sub ax, 34 + + mcall SF_MOUSE_GET, SSF_WINDOW_POSITION + sub eax, 0x00220022 mov bl, 24 div bl mov cl, al shl cl, 4 - pop eax shr eax, 16 - sub ax, 34 div bl add cl, al mov [char], cl mov [char_scan], 0x0000 - call logic_update - call draw_update - jmp event_wait - .button_b: ; charset CP866 6x9 + jmp .button_end + + .button_b: ; 0B - charset CP866 6x9 cmp ah, 0x0B jne .button_c + + call draw_charpage_delete + + mov [page], 0x00 + mov [charset], 0x80 mov [lb_curr], lb_cp6x9 - call draw_update - jmp event_wait - .button_c: ; charset CP866 8x16 + jmp .button_end + + .button_c: ; 0C - charset CP866 8x16 cmp ah, 0x0C jne .button_d + + call draw_charpage_delete + + mov [page], 0x00 + mov [charset], 0x90 mov [lb_curr], lb_cp8x16 - call draw_update - jmp event_wait - .button_d: ; charset UTF-16 8x16 + jmp .button_end + + .button_d: ; 0D - charset UTF-16 8x16 cmp ah, 0x0D jne .button_e + + call draw_charpage_buttons + + mov al, [page_utf] + mov [page], al + mov [charset], 0xA0 mov [lb_curr], lb_utf16 - call draw_update - jmp event_wait - .button_e: ; charset UTF-8 8x16 + jmp .button_end + + .button_e: ; 0E - charset UTF-8 8x16 cmp ah, 0x0E jne .button_f + + call draw_charpage_buttons + + mov al, [page_utf] + mov [page], al + mov [charset], 0xB0 mov [lb_curr], lb_utf8 - call draw_update - jmp event_wait - .button_f: ; charpage reset + call .button_end + + .button_f: ; 0F - charpage reset cmp ah, 0x0F jne .button_10 - mov [page], 0x00 - call logic_update - call draw_update + + call logic_charpage_zero + jmp event_wait - .button_10: ; charpage decrement + .button_10: ; 10 - charpage decrement cmp ah, 0x10 jne .button_11 - mov ch, [page] - dec ch - mov [page], ch - call logic_update - call draw_update + + call logic_charpage_dec + jmp event_wait - .button_11: ; charpage increment + .button_11: ; 11 - charpage increment cmp ah, 0x11 jne .button_12 - mov ch, [page] - inc ch - mov [page], ch - call logic_update - call draw_update + + call logic_charpage_inc + jmp event_wait - .button_12: ; read/stop keyboard input + .button_12: ; 12 - read/stop keyboard input cmp ah, 0x12 - jne event_wait + jne .button_13 + mov al, 0x01 sub al, [reading] mov [reading], al + call draw_toggle + jmp event_wait - jmp event_wait + .button_13: ; 13 - character scale down + cmp ah, 0x13 + jne .button_14 -; ================================================================ + call logic_scale_down -draw_window: + jmp event_wait - mcall 12, 1 + .button_14: ; 14 - character scale up + cmp ah, 0x14 + jne .button_15 - mcall 48, 3, window_colors, 40 + call logic_scale_up - mcall , 4 - add eax, 3 - mov [win_head], eax + jmp event_wait - mov eax, 0 - mov ebx, 100 * 65536 + 685 - mov ecx, 100 * 65536 + 518 - mov edx, [window_colors.work] - add edx, 0x34000000 - mov edi, title - mcall + .button_15: ; 15 - copy ascii dec + cmp ah, 0x15 + jne .button_16 - ; Don't draw rolled up or rolled down window - mcall 9, proc_info, -1 - mov eax, [proc_info + 70] - mov [win_stat], eax - test [win_stat], 100b - jnz .draw_end + mov dx, [char_ascii] + call logic_copy_dec - ; Draw all app content - add [win_head], 492 + jmp event_wait - call draw_base - call draw_update - call draw_toggle + .button_16: ; 18 - copy scan dec + cmp ah, 0x16 + jne .button_17 - .draw_end: - mov esi, [win_head] - mcall 67, -1, -1, -1, - mcall 12, 2 + mov dx, [char_scan] + call logic_copy_dec + + jmp event_wait + + .button_17: ; 17 - copy ascii hex + cmp ah, 0x17 + jne .button_18 + + mov dx, [char_ascii] + call logic_copy_hex + + jmp event_wait + + .button_18: ; 18 - copy scan hex + cmp ah, 0x18 + jne event_wait + + mov dx, [char_scan] + call logic_copy_hex + + jmp event_wait + + .button_end: + call logic_update + jmp event_wait + +; =================================================================== + +; set charpage number to zero +logic_charpage_zero: + + cmp [charset], 0x90 + jle event_wait + + mov [page], 0x00 + mov [page_utf], 0x00 + + call logic_update ret -; ================================================================ -; unchangeble base - table, headers and buttons -draw_base: +; decrement charpage number +logic_charpage_dec: - .tables: - ; both tables background - mcall 13, 65536 * 9 + 410, 65536 * 9 + 410, [window_colors.work_light] - mcall , 65536 * 428 + 240, 65536 * 9 + 442, + cmp [charset], 0x90 + jle event_wait - ; 16x16 characters table - mcall , 65536 * 8 + 411, 65536 * 8 + 1, [window_colors.work_text] - mcall , , 65536 * 33 + 1, - mcall , , 65536 * 418 + 1, - mcall , 65536 * 8 + 1, 65536 * 8 + 410, - mcall , 65536 * 33 + 1, , - mcall , 65536 * 418 + 1, , + dec byte [page] + dec byte [page_utf] - ; single character table - mcall , 65536 * 427 + 1, 65536 * 8 + 443, - mcall , 65536 * 668 + 1, , - mcall , 65536 * 427 + 242, 65536 * 8 + 1, - mcall , , 65536 * 376 + 1, - mcall , , 65536 * 401 + 1, - mcall , , 65536 * 426 + 1, - mcall , , 65536 * 451 + 1, - mcall , 65536 * 562 + 1, 65536 * 377 + 75, - mcall , 65536 * 619 + 1, , - - .headers: - ; horizontal table headers - mov eax, 4 - mov ebx, 65536 * 38 + 14 - mov ecx, [window_colors.work_text] - add ecx, 0x90000000 - mov esi, 16 - - .loop_hx: - mov edx, header - mcall - - mov dx, [header] - add dx, 0x0100 - - cmp dx, 0x3A2D - jne .hx_af - add dx, 0x0700 - - .hx_af: - mov [header], dx - add ebx, 65536 * 24 - dec esi - jnz .loop_hx - - ; vertical headers - mov ebx, 65536 * 13 + 39 - mov esi, 16 - mov [header], 0x2D30 - - .loop_hy: - mov edx, header - mcall - - mov dx, [header] - add dx, 0x0001 - - cmp dx, 0x2D3A - jne .hy_af - add dx, 0x0007 - - .hy_af: - mov [header], dx - add ebx, 24 - dec esi - jnz .loop_hy - - ; reset headers - mov [header], 0x302D - - ; single character table headers - mcall , 65536 * 579 + 382, , lb_dec, - mcall , 65536 * 632 + 382, , lb_hex, - mcall , 65536 * 436 + 407, , lb_asci, - mcall , 65536 * 436 + 432, , lb_scan, - - .buttons: - ; button on table to pick single character - mcall 8, 65536 * 34 + 384, 65536 * 34 + 384, 0x6000000A, - - ; charsets change buttons - mcall , 65536 * 8 + 95, 65536 * 459 + 23, 0x0000000B, [window_colors.work_button] - mcall , 65536 * 113 + 95, , 0x0000000C, - mcall , 65536 * 218 + 95, , 0x0000000D, - mcall , 65536 * 323 + 95, , 0x0000000E, - - ; page swap buttons - mcall , 65536 * 323 + 31, 65536 * 427 + 23, 0x0000000F, - mcall , 65536 * 363 + 23, , 0x00000010, - mcall , 65536 * 395 + 23, , 0x00000011, - - ; charsets change buttons subscriptions - mov ecx, [window_colors.work_button_text] - add ecx, 0xB0000000 - mcall 4, 65536 * 20 + 464, , lb_cp6x9 - mcall , 65536 * 121 + 464, , lb_cp8x16 - mcall , 65536 * 222 + 464, , lb_utf16 - mcall , 65536 * 331 + 464, , lb_utf8 - - ; page swap buttons subscriptions - mcall , 65536 * 331 + 432, , bt_res - mcall , 65536 * 370 + 432, , bt_dec - mcall , 65536 * 403 + 432, , bt_inc + call logic_update ret -; changable data: current charset, charpage, chars, single char and it's codes -draw_update: - ; background for letters - mcall 13, 65536 * 34 + 384, 65536 * 34 + 384, [window_colors.work_light] +; increment charpage number +logic_charpage_inc: - ; current charset and charpage - .charpage: - ; current charpage - mov esi, [window_colors.work_text] - add esi, 0x50000000 - mcall 47, 65536 * 2 + 257, page, 0x000D000E, , [window_colors.work_light] + cmp [charset], 0x90 + jle event_wait - ; current charset - mov ecx, [window_colors.work_text] - add ecx, 0xD0000000 - mcall 4, 65536 * 8 + 432, , [lb_curr], , [window_colors.work] + inc byte [page] + inc byte [page_utf] - ; 16x16 table of letters - .letters: - ;different coordinates for 6x9 charset - mov bl, [charset] - cmp bl, 0x80 - jne .char_big - - .char_sm: - mov ebx, 65536 * 44 + 42 - jmp .char_draw - - .char_big: - mov ebx, 65536 * 42 + 39 - - .char_draw: - mov cl, [charset] - shl ecx, 24 - add ecx, [window_colors.work_text] - mov esi, 16 - - ; letters draw loop - .loop_ly: - mov edi, 16 - - .loop_lx: - mov edx, letter - - cmp [charset], 0xB0 - jne .skip_lx - - ;utf 8 to 16 - xor edx, edx - mov dx, [letter] - push esi - mov esi, letutf - call logic_utf16to8 - pop esi - mov edx, letutf - - .skip_lx: - - mcall - - mov dx, [letter] - add dx, 0x01 - mov [letter], dx - - add ebx, 65536 * 24 - - dec edi - jnz .loop_lx - - ; start new row of letters - sub ebx, 65536 * 383 + 65512 - - dec esi - jnz .loop_ly - - ; reset letter from 0x0100 to 0x0000 - mov dx, [letter] - dec dh - mov [letter], dx - - ; highlight of current character in table - .highlight: - mov al, [char] - shr al, 4 - mov bl, 24 - mul bl - add ax, 34 - shl eax, 16 - mov al, 0x01 - mov ecx, eax - push ecx - - mov eax, 13 - mov ebx, 65536 * 34 + 384 - mov edx, [window_colors.work_button] - - ;skip lines aligned to table borders - cmp ecx, 65536 * 34 + 65536 - jle .hl_next_hr - mcall - .hl_next_hr: - add ecx, 65536 * 23 - cmp ecx, 65536 * 417 - jge .hl_end_hr - mcall - .hl_end_hr: - - mov al, [char] - and al, 0x0F - mov bl, 24 - mul bl - add ax, 34 - shl eax, 16 - mov al, 0x01 - mov ebx, eax - - mov eax, 13 - mov ecx, 65536 * 34 + 384 - mov edx, [window_colors.work_button] - - ;skip lines aligned to table borders - cmp ebx, 65536 * 34 + 65536 - jle .hl_next_vr - mcall - .hl_next_vr: - add ebx, 65536 * 23 - cmp ebx, 65536 * 417 - jge .hl_end_vr - mcall - .hl_end_vr: - - pop ecx - add ecx, 23 - sub ebx, 65535 * 23 - mcall - - ; redraw active symbol - shr ecx, 16 - mov bx, cx - add ebx, 65536 * 8 + 5 - - mov cl, [charset] - cmp cl, 0xB0 - jne .check_80 - mov cl, 0xA0 - jmp .process - - .check_80: - cmp cl, 0x80 - jne .process - add ebx, 65536 * 2 + 3 - - .process: - shl ecx, 24 - add ecx, [window_colors.work_button_text] - mcall 4, , , char_ascii - - ; single character big display - .single: - - mcall 13, 65536 * 452 + 192, 65536 * 24 + 336, [window_colors.work_light] - mov ah, [page] - mov al, [char] - mov [char_ascii], ax - - cmp [charset], 0xB0 - - jne .skip_sn - ;utf 8 to 16 - xor edx, edx - mov dx, [char_ascii] - push esi - mov esi, char_utf - call logic_utf16to8 - pop esi - - mov ecx, 0xF7000000 - add ecx, [window_colors.work_text] - mcall 4, 65536 * 516 + 136, , char_utf, 0, [window_colors.work_light] - jmp .codes - - .skip_sn: - mov ebx, 65536 * 516 + 136 - mov cl, [charset] - - cmp cl, 0x80 - jne .not_80 - add ebx, 65536 * 12 + 29 - - .not_80: - add cl, 0x07 - shl ecx, 24 - add ecx, [window_colors.work_text] - mcall 4, , , char_ascii, 1, [window_colors.work_light] - - ; singe character codes - .codes: - - mov esi, [window_colors.work_text] - add esi, 0x50000000 - - xor ecx, ecx - - mov cx, [char_ascii] - mcall 47, 0x00050000, , 65536 * 571 + 407, , [window_colors.work_light] - mov cx, [char_scan] - mcall , , , 65536 * 571 + 432, - - mov cx, [char_ascii] - mcall , 0x00040100, , 65536 * 628 + 407, - mov cx, [char_scan] - mcall , , , 65536 * 628 + 432, + call logic_update ret -; redraw keyboard input toggle button -draw_toggle: - mcall 8, 65536 * 427 + 241, 65536 * 459 + 23, 0x00000012, [window_colors.work_button] +; moving in charpage +; dec/inc lower nibble mod 16 +; input: al = +1 or -1 +logic_char_modify_lower_nibble: - mov ecx, [window_colors.work_button_text] - add ecx, 0xB0000000 + mov bl, [char] + mov cl, bl + and cl, 0x0F + add cl, al + and cl, 0x0F + and bl, 0xF0 + or bl, cl + mov [char], bl - mov al, [reading] - cmp al, 0x01 + ret - je .stop - mcall 4, 65536 * 472 + 464, , bt_read - ret - .stop: - mcall 4, 65536 * 472 + 464, , bt_stop - ret -; ================================================================ +; dec/inc upper nibble mod 16 +; input: al = +1 or -1 +logic_char_modify_upper_nibble: + + mov bl, [char] + mov cl, bl + and cl, 0xF0 + shr cl, 4 + add cl, al + and cl, 0x0F + shl cl, 4 + and bl, 0x0F + or bl, cl + mov [char], bl + + ret + + +; move left in charpage +logic_char_left: + + mov al, -1 + call logic_char_modify_lower_nibble + + ret + + +; move right in charpage +logic_char_right: + + mov al, 1 + call logic_char_modify_lower_nibble + + ret + + +; move down in charpage +logic_char_down: + + mov al, -1 + call logic_char_modify_upper_nibble + + ret + + +; move up in charpage +logic_char_up: + + mov al, 1 + call logic_char_modify_upper_nibble + + ret + ; update all dependant values logic_update: @@ -571,8 +464,12 @@ logic_update: mov al, [char] mov [char_ascii], ax + call draw_update_table + call draw_update_single + ret + ; edx = num, esi -> buffer of size 4 logic_utf16to8: @@ -612,9 +509,669 @@ logic_utf16to8: ret -; ================================================================ -title db "Charsets Viewer 0.3.2", 0 +; scale down single character display +logic_scale_down: + + cmp [scale], 0x00 + jle event_wait + + mov bl, [scale] + dec bl + mov [scale], bl + + call draw_update_single + + ret + + +; scale up single character display +logic_scale_up: + + cmp [scale], 0x07 + jge event_wait + + mov bl, [scale] + inc bl + mov [scale], bl + + call draw_update_single + + ret + + +; char codes copying functions +; edx - code +logic_copy_dec: + + mov ax, dx + mov bx, 10 + mov ecx, 5 + + .copy_d_loop: + + xor dx, dx + div bx + add dl, 0x30 + mov [char_code_dec + 11 + ecx], byte dl + + loop .copy_d_loop + + mcall SF_CLIPBOARD, SSF_WRITE_CB, char_code_dec.end - char_code_dec, char_code_dec + + ret + + +; edx - code +logic_copy_hex: + + mov ecx, 4 + + .copy_ah_loop: ; iterate over all hex-digits of color + mov al, dl + and al, 0x0F + add al, 0x30 ; 0x30 = ASCII code of "0" + + cmp al, 0x39 + jbe .cont ; if digit + + add al, 0x07 ; if letter + + .cont: + mov [char_code_hex + 11 + ecx], byte al + shr edx, 4 + loop .copy_ah_loop + + mcall SF_CLIPBOARD, SSF_WRITE_CB, char_code_hex.end - char_code_hex, char_code_hex + + ret + +; =================================================================== + +draw_window: + + mcall SF_REDRAW, SSF_BEGIN_DRAW + + mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, win_cols, sizeof.system_colors + mcall , SSF_GET_SKIN_HEIGHT, + + mov ecx, eax + add ecx, WN_RECT.Y shl 16 + WN_RECT.H + + mov edx, [win_cols.work] + add edx, 0x34000000 + mcall SF_CREATE_WINDOW, , , , , title + + call draw_base + call draw_update_table + call draw_update_single + call draw_toggle + + mcall SF_REDRAW, SSF_END_DRAW + + ret + +; =================================================================== + +; unchangeble base - table, headers and buttons +draw_base: + + ; both tables background + mcall SF_DRAW_RECT, , , [win_cols.work_text] + mcall , , , + mcall , , , [win_cols.work_light] + mcall , , + + ; buttons + ; button on charpage table to pick single character + mcall SF_DEFINE_BUTTON, , , 0x6000000A, + + ; charsets change buttons + mcall , , , 0x0000000B, [win_cols.work_button] + mcall , , , 0x0000000C, + mcall , , , 0x0000000D, + mcall , , , 0x0000000E, + + ; character scale buttons + mcall , , , 0x00000013, + mcall , , , 0x00000014, + + ; tables + ; 16x16 characters table + mcall SF_DRAW_RECT, , , [win_cols.work_text] + mcall , , , + + ; single character table + mcall SF_DRAW_RECT, , , + mcall , , , + mcall , , , + mcall , , , + + ; headers + ; horizontal page table headers + mov eax, SF_DRAW_TEXT + mov ebx, HD_TABL.X shl 16 + HD_TABL.Y + mov ecx, [win_cols.work_text] + add ecx, 0x90000000 + xor edx, edx + mov esi, 16 + + .loop_hx: + mov edx, header + mcall + + mov dx, [header] + add dx, 0x0100 + + cmp dx, 0x3AFF + jne .hx_af + add dx, 0x0700 + + .hx_af: + mov [header], dx + add ebx, 24 shl 16 + dec esi + jnz .loop_hx + + ; vertical headers + mov ebx, 13 shl 16 + 39 + mov esi, 16 + mov [header], 0xFF30 + + .loop_hy: + mov edx, header + mcall + + mov dx, [header] + add dx, 0x0001 + + cmp dx, 0xFF3A + jne .hy_af + add dx, 0x0007 + + .hy_af: + mov [header], dx + add ebx, 24 + dec esi + jnz .loop_hy + + ; reset headers + mov [header], 0x30FF + + ; single character table headers + mcall , , , lb_size, + mcall , , , lb_dec, + mcall , , , lb_hex, + mcall , , , lb_asci, + mcall , , , lb_scan, + + ; buttons subscriptions + ; charsets change buttons subscriptions + mov ecx, [win_cols.work_button_text] + add ecx, 0xB0000000 + mcall , , , lb_cp6x9 + mcall , , , lb_cp8x16 + mcall , , , lb_utf16 + mcall , , , lb_utf8 + + ; page swap buttons subscriptions + mcall , , , bt_res + mcall , , , bt_dec + mcall , , , bt_inc + + ; character scale buttons subscriptions + mcall , , , bt_smaller + mcall , , , bt_bigger + + cmp [charset], 0x90 + jle .cp_bt_cp + + .cp_bt_utf: + call draw_charpage_buttons + jmp .cp_bt_end + + .cp_bt_cp: + call draw_charpage_delete + + .cp_bt_end: + ret + + +; changable data: current charset, charpage, chars, selection +draw_update_table: + + ; current charset and charpage + mov ecx, [win_cols.work_text] + add ecx, 0xD0000000 + mcall SF_DRAW_TEXT, , , [lb_curr], , [win_cols.work] + + mov esi, [win_cols.work_text] + add esi, 0x50000000 + + mcall SF_DRAW_NUMBER, 0x00020101, page, , , [win_cols.work_light] + + ; 16x16 table of letters + ; background for letters + mcall SF_DRAW_RECT, , , [win_cols.work_light] + + ;different coordinates for 6x9 charset + mov bl, [charset] + cmp bl, 0x80 + jne .char_big + + .char_sm: + mov ebx, 44 shl 16 + 42 + jmp .char_draw + + .char_big: + mov ebx, 42 shl 16 + 39 + + .char_draw: + mov eax, SF_DRAW_TEXT + mov cl, [charset] + shl ecx, 24 + add ecx, [win_cols.work_text] + mov esi, 16 + + ; letters draw loop + .loop_ly: + mov edi, 16 + + .loop_lx: + mov edx, letter + + cmp [charset], 0xB0 + jne .skip_conversion + + ;utf 8 to 16 + xor edx, edx + mov dx, [letter] + push esi + mov esi, letutf + call logic_utf16to8 + pop esi + mov edx, letutf + + .skip_conversion: + + mcall + + mov dx, [letter] + add dx, 0x01 + mov [letter], dx + + add ebx, 24 shl 16 + + dec edi + jnz .loop_lx + + ; start new row of letters + sub ebx, 383 shl 16 + 65512 + + dec esi + jnz .loop_ly + + ; reset letter from 0x0100 to 0x0000 + mov dx, [letter] + dec dh + mov [letter], dx + + ; highlight of current character in table + mov al, [char] + shr al, 4 + mov bl, 24 + mul bl + add ax, 34 + shl eax, 16 + mov al, 0x01 + mov ecx, eax + push ecx + + mov eax, SF_DRAW_RECT + mov ebx, 34 shl 16 + 384 + mov edx, [win_cols.work_button] + + ; skip horizontal lines aligned to table borders + cmp ecx, 34 shl 16 + 65536 + jle .hl_next_hr + mcall + + .hl_next_hr: + + add ecx, 23 shl 16 + cmp ecx, 417 shl 16 + jge .hl_end_hr + mcall + + .hl_end_hr: + + mov al, [char] + and al, 0x0F + mov bl, 24 + mul bl + add ax, 34 + shl eax, 16 + mov al, 0x01 + mov ebx, eax + + mov eax, SF_DRAW_RECT + mov ecx, 34 shl 16 + 384 + mov edx, [win_cols.work_button] + + ; skip vertical lines aligned to table borders + cmp ebx, 34 shl 16 + 65536 + jle .hl_next_vr + mcall + + .hl_next_vr: + add ebx, 23 shl 16 + cmp ebx, 417 shl 16 + jge .hl_end_vr + mcall + + .hl_end_vr: + + pop ecx + add ecx, 23 + sub ebx, 23 * 65535 + mcall + + ; redraw active symbol + shr ecx, 16 + mov bx, cx + add ebx, 8 shl 16 + 5 + + mov cl, [charset] + cmp cl, 0xB0 + jne .check_6x9 + mov cl, 0xA0 + jmp .char_draw_act + + .check_6x9: + cmp cl, 0x80 + jne .char_draw_act + add ebx, 2 shl 16 + 3 + + .char_draw_act: + shl ecx, 24 + add ecx, [win_cols.work_button_text] + mcall SF_DRAW_TEXT, , , char_ascii + + ret + + +; single character big display, it's scale and codes +draw_update_single: + + ; background for single char + mcall SF_DRAW_RECT, , , [win_cols.work_light] + + mov ah, [page] + mov al, [char] + mov [char_ascii], ax + + ; shifting letter position depenging on scale + mov bl, 7 + sub bl, [scale] + mov al, 7 + mul bl + add ax, 136 + push ax + + mov bl, 7 + sub bl, [scale] + mov al, 4 + mul bl + add ax, 516 + + shl eax, 16 + pop ax + mov ebx, eax + + cmp [charset], 0xB0 + jne .not_utf8 + + ;utf 8 to 16 conversion + .utf_8: + xor edx, edx + mov dx, [char_ascii] + push esi + mov esi, char_utf + call logic_utf16to8 + pop esi + + mov cl, 0xF0 + add cl, [scale] + shl ecx, 24 + add ecx, [win_cols.work_text] + + mcall SF_DRAW_TEXT, , , char_utf, 0, [win_cols.work_light] + + jmp .codes + + .not_utf8: + mov cl, [charset] + cmp cl, 0x80 + jne .not_80 + + ; shifting letter position depenging on scale + xor eax, eax + mov al, [scale] + add al, [scale] + shl eax, 16 + add ebx, eax + push ebx + + mov bl, 7 + sub bl, [scale] + mov al, 3 + mul bl + pop ebx + sub bx, ax + add ebx, 0 shl 16 + 25 + + .not_80: + add cl, 0x40 + add cl, [scale] + shl ecx, 24 + add ecx, [win_cols.work_text] + + mcall SF_DRAW_TEXT, , , char_ascii, 1, [win_cols.work_light] + + ; singe character codes + .codes: + + ; character codes copy buttons + mcall SF_DEFINE_BUTTON, , , 0x00000015, [win_cols.work_button] + mcall , , , 0x00000016, + mcall , , , 0x00000017, + mcall , , , 0x00000018, + + ; lines to overlap button's borders + mcall SF_DRAW_RECT, , , + mcall , , , + mcall , , , + mcall , , , + mcall , , , + mcall , , , + + xor ecx, ecx + mov esi, [win_cols.work_button_text] + add esi, 0x10000000 + + mov cx, [char_ascii] + mcall SF_DRAW_NUMBER, 0x00050000, , , + + mov cx, [char_scan] + mcall , , , , + + mov cx, [char_ascii] + mcall , 0x00040100, , , + + mov cx, [char_scan] + mcall , , , , + + ; single character scale + xor ecx, ecx + mov cl, [scale] + inc cl + mov esi, [win_cols.work_text] + add esi, 0x50000000 + mcall SF_DRAW_NUMBER, 0x80010000, , , , [win_cols.work_light] + + ret + + +; redraw keyboard input toggle button +draw_toggle: + + cmp [reading], 0x01 + + je .stop + + mcall SF_DEFINE_BUTTON, , , 0x00000012, [win_cols.work_button] + + mov ecx, [win_cols.work_button_text] + add ecx, 0x90000000 + mcall SF_DRAW_TEXT, , , bt_read + + ret + + .stop: + mov esi, [win_cols.work_button] + or esi, 0x00FF0000 + mcall SF_DEFINE_BUTTON, , , 0x00000012, + + mov ecx, [win_cols.work_button_text] + add ecx, 0x90000000 + mcall SF_DRAW_TEXT, , , bt_stop + + ret + + +; draw charpage change buttons +draw_charpage_buttons: + + mcall SF_DEFINE_BUTTON, , , 0x0000000F, [win_cols.work_button] + mcall , , , 0x00000010, + mcall , , , 0x00000011, + + mov ecx, [win_cols.work_button_text] + add ecx, 0xB0000000 + + ; page swap buttons subscriptions + mcall SF_DRAW_TEXT, , , bt_res + mcall , , , bt_dec + mcall , , , bt_inc + + ret + +; delete charpage change buttons +draw_charpage_delete: + + mcall SF_DEFINE_BUTTON, , , 0x8000000F + mcall , , , 0x80000010 + mcall , , , 0x80000011 + + mcall SF_DRAW_RECT, , , [win_cols.work] + + ret + +; =================================================================== + +WN_RECT RECT 100, 100, 686, 494 ; window + +TB_PAGE RECT 8, 8, 411, 411 ; tables background +TB_SING RECT 427, 8, 242, 411 + +BT_TABL RECT 34, 34, 384, 384 ; button to pick char + +BT_CS_01 RECT 8, 459, 95, 23 ; charsets buttons +BT_CS_02 RECT 113, 459, 95, 23 +BT_CS_03 RECT 218, 459, 95, 23 +BT_CS_04 RECT 323, 459, 95, 23 + +BT_CP_ZR RECT 323, 427, 31, 23 ; charpage buttons +BT_CP_DN RECT 363, 427, 23, 23 +BT_CP_UP RECT 395, 427, 23, 23 + +BT_SC_DN RECT 618, 8, 25, 25 ; char scale buttons +BT_SC_UP RECT 643, 8, 25, 25 + +BT_CP_AD RECT 562, 368, 57, 25 ; char code copy buttons +BT_CP_SD RECT 562, 393, 57, 25 +BT_CP_AH RECT 619, 368, 49, 25 +BT_CP_SH RECT 619, 393, 49, 25 + +BT_RD_ST RECT 427, 459, 241, 23 ; key input read/stop button + +LN_PG_01 RECT 8, 33, 410, 1 ; page table lines +LN_PG_02 RECT 33, 8, 1, 410 + +LN_SN_01 RECT 668, 8, 1, 410 ; singe table lines +LN_SN_02 RECT 427, 8, 242, 1 +LN_SN_03 RECT 427, 33, 242, 1 +LN_SN_04 RECT 427, 343, 242, 1 +LN_SN_05 RECT 427, 368, 242, 1 +LN_SN_06 RECT 427, 393, 242, 1 +LN_SN_07 RECT 562, 343, 1, 75 +LN_SN_08 RECT 619, 343, 1, 75 + +LB_SN_SCL RECT 436, 14, 0, 0 ; single table subscriptions +LB_SN_DEC RECT 579, 349, 0, 0 +LB_SN_HEX RECT 632, 349, 0, 0 +LB_SN_ASC RECT 436, 374, 0, 0 +LB_SN_SCN RECT 436, 399, 0, 0 + +LB_CS_01 RECT 20, 464, 0, 0 ; charsets buttons subscriptions +LB_CS_02 RECT 121, 464, 0, 0 +LB_CS_03 RECT 222, 464, 0, 0 +LB_CS_04 RECT 331, 464, 0, 0 + +LB_CP_ZR RECT 331, 432, 0, 0 ; charpage buttons subscriptions +LB_CP_DN RECT 370, 432, 0, 0 +LB_CP_UP RECT 403, 432, 0, 0 + +LB_SC_DN RECT 627, 13, 0, 0 ; char scale subscriptions +LB_SC_UP RECT 652, 13, 0, 0 + +DT_CD_AD RECT 571, 374, 0, 0 ; char codes +DT_CD_SD RECT 571, 399, 0, 0 +DT_CD_AH RECT 628, 374, 0, 0 +DT_CD_SH RECT 628, 399, 0, 0 +DT_CH_SC RECT 508, 14, 0, 0 ; char scale + +HD_TABL RECT 38, 14, 0, 0 ; char table headers + +; =================================================================== + +if lang eq ru_RU + + title cp866 "╨в╨░╨▒╨╗╨╕╤Ж╤Л ╨б╨╕╨╝╨▓╨╛╨╗╨╛╨▓ 0.4.2", 0 + lb_size cp866 "╨Ь╨░╤Б╤И╤В╨░╨▒:", 0 + lb_asci cp866 "ASCII-╨║╨╛╨┤", 0 + lb_scan cp866 "╨б╨║╨░╨╜-╨║╨╛╨┤", 0 + bt_read cp866 " ╨з╨╕╤В╨░╤В╤М ╨▓╨▓╨╛╨┤ ╤Б ╨║╨╗╨░╨▓╨╕╨░╤В╤Г╤А╤Л ", 0 + bt_stop cp866 " ╨Я╤А╨╡╨║╤А╨░╤В╨╕╤В╤М ╤З╨╕╤В╨░╤В╤М ╨▓╨▓╨╛╨┤ ", 0 + +else if lang eq es_ES + + title db "Tablas de Simbolos 0.4.2", 0 + lb_size db "Escala:", 0 + lb_asci db "Codigo ASCII", 0 + lb_scan db "Codigo scan", 0 + bt_read db " Leer entrada del teclano ", 0 + bt_stop db "Detener entrada de teclano", 0 +else + + title db "Charsets Viewer 0.4.2", 0 + lb_size db "Scale:", 0 + lb_asci db "ASCII-code", 0 + lb_scan db "Scan-code", 0 + bt_read db " Start keyboard input ", 0 + bt_stop db " End keyboard input ", 0 + +endf lb_cp6x9 db "CP866 6x9 ", 0 lb_cp8x16 db "CP866 8x16 ", 0 @@ -623,43 +1180,57 @@ lb_utf8 db "UTF-8 8x16 ", 0 lb_curr dd lb_utf8 -lb_hex db "HEX", 0 -lb_dec db "DEC", 0 -lb_asci db "ASCII-code", 0 -lb_scan db "Scan-code", 0 +lb_hex db "HEX", 0 +lb_dec db "DEC", 0 -bt_res db "00", 0 -bt_dec db "<", 0 -bt_inc db ">", 0 +bt_res db "00", 0 +bt_dec db "<", 0 +bt_inc db ">", 0 -bt_read db "Read keyboard input", 0 -bt_stop db "Stop keyboard input", 0 +bt_smaller db "-", 0 +bt_bigger db "+", 0 -reading db 0x00 +; =================================================================== -header dw 0x302D, 0 ; "-0" symbols -letter dw 0x0000, 0 -letutf dd 0x00000000, 0 +win_cols system_colors -charset db 0xB0 -page db 0x00 -char db 0x00 +; =================================================================== -char_ascii dw 0x0000, 0 -char_scan dw 0x0000, 0 -char_utf dd 0x00000000, 0 +reading db 0x00 -win_stat rd 1 -win_head rd 1 +header dw 0x30FF, 0 ; "-0" symbols +letter dw 0x0000, 0 ; buffer for chars in page table +letutf dd 0x00000000, 0 ; same, but for UTF-8 chars -window_colors system_colors -proc_info process_information +charset db 0xB0 +page db 0x00 +page_utf db 0x00 +char db 0x00 +scale db 0x07 -; ================================================================ +char_ascii dw 0x0000, 0 ; current char ASCII/CP866 code +char_scan dw 0x0000, 0 ; current char SCAN-code +char_utf dd 0x00000000, 0 ; current char UTF-8 code + +char_code_dec: + dd char_code_dec.end - char_code_dec + dd 0 + dd 1 + db '00000' +.end: + +char_code_hex: + dd char_code_hex.end - char_code_hex + dd 0 + dd 1 + db '0000' +.end: + +; =================================================================== I_END: - rb 4096 + rb 512 align 16 STACKTOP: -MEM: +MEM: \ No newline at end of file diff --git a/programs/develop/charsets/hotkeys.txt b/programs/develop/charsets/hotkeys.txt new file mode 100644 index 000000000..521ce3ce2 --- /dev/null +++ b/programs/develop/charsets/hotkeys.txt @@ -0,0 +1,12 @@ +Control hotkeys + +- Navigate inside charpage: + - Arrows + - Num2/4/6/8 + +- Navigation between charpages: + - PgDN, PgUP - previous/next page + - Num0, Home - reset page to zero + +- Change symbol scale: + - Num- and Num+ diff --git a/programs/develop/info3ds/info3ds.asm b/programs/develop/info3ds/info3ds.asm index 839a60de1..2bfa3ce8b 100644 --- a/programs/develop/info3ds/info3ds.asm +++ b/programs/develop/info3ds/info3ds.asm @@ -1082,7 +1082,7 @@ l_libs_start: lib_2 l_libs lib_name_2, file_name, system_dir_2, import_box_lib lib_3 l_libs lib_name_3, file_name, system_dir_3, import_buf2d lib_4 l_libs lib_name_4, file_name, system_dir_4, import_libkmenu - lib_5 l_libs lib_name_5, file_name, system_dir_5, import_lib_tinygl + lib_5 l_libs lib_name_5, file_name, system_dir_5, import_tinygl lib_6 l_libs lib_name_6, file_name, system_dir_6, import_libini l_libs_end: @@ -1287,7 +1287,7 @@ dd 0,0 akmenuitem_draw db 'kmenuitem_draw',0 align 4 -import_lib_tinygl: +import_tinygl: macro E_LIB n { n dd sz_#n @@ -1343,7 +1343,7 @@ buf_1: align 4 el_focus dd tree1 tree1 tree_list size_one_list,300+2, tl_key_no_edit+tl_draw_par_line,\ - 16,16, 0xffffff,0xb0d0ff,0x400040, 5,35,195-16,250, 16,list_offs_text,0,\ + 16,16, 0xffffff,0xb0d0ff,0x10400040, 5,35,195-16,250, 16,list_offs_text,0,\ el_focus,w_scr_t1,0 align 4 @@ -1362,9 +1362,9 @@ white_light dd 0.8, 0.8, 0.8, 1.0 ; lmodel_ambient dd 0.3, 0.3, 0.3, 1.0 ; Параметры фонового освещения if lang eq ru_RU -capt db 'info 3ds версия 29.09.20',0 ;подпись окна +capt db 'info 3ds версия 14.04.25',0 ;подпись окна else ; Default to en_US -capt db 'info 3ds version 29.09.20',0 ;window caption +capt db 'info 3ds version 14.04.25',0 ;window caption end if align 16 diff --git a/programs/develop/info3ds/info3ds_u.asm b/programs/develop/info3ds/info3ds_u.asm index a9d47f951..29fdff4f5 100644 --- a/programs/develop/info3ds/info3ds_u.asm +++ b/programs/develop/info3ds/info3ds_u.asm @@ -1408,7 +1408,7 @@ buf_1: align 4 el_focus dd tree1 tree1 tree_list size_one_list,300+2, tl_key_no_edit+tl_draw_par_line,\ - 16,16, 0xffffff,0xb0d0ff,0x400040, 5,47,195-16,250, 16,list_offs_text,0, el_focus,\ + 16,16, 0xffffff,0xb0d0ff,0x10400040, 5,47,195-16,250, 16,list_offs_text,0, el_focus,\ w_scr_t1,0 align 4 @@ -1427,9 +1427,9 @@ white_light dd 0.8, 0.8, 0.8, 1.0 ; lmodel_ambient dd 0.3, 0.3, 0.3, 1.0 ; Параметры фонового освещения if lang eq ru_RU -capt db 'info 3ds [user] версия 29.09.20',0 ; подпись окна +capt db 'info 3ds [user] версия 14.04.25',0 ; подпись окна else ; Default to en_US -capt db 'info 3ds [user] version 29.09.20',0 ; Window caption +capt db 'info 3ds [user] version 14.04.25',0 ; Window caption end if align 16 diff --git a/programs/develop/info3ds/info_o3d.inc b/programs/develop/info3ds/info_o3d.inc index a576398e6..eb7ac600d 100644 --- a/programs/develop/info3ds/info_o3d.inc +++ b/programs/develop/info3ds/info_o3d.inc @@ -812,9 +812,8 @@ proc draw_3d uses eax ebx ecx edi, o_data:dword @@: stdcall [glDisable],GL_LIGHTING .end_l: - stdcall [glTranslatef], 0.0,0.0,0.5 ;correct for z stdcall [glScalef], [edi+obj_3d.x_scale],[edi+obj_3d.y_scale],[edi+obj_3d.z_scale] - stdcall [glScalef], 1.0,1.0,0.7 ;correct for z + stdcall [glScalef], 1.0,1.0,1.4 ;correct for z stdcall [glRotatef], [angle_z],0.0,0.0,1.0 stdcall [glRotatef], [angle_y],0.0,1.0,0.0 stdcall [glRotatef], [angle_x],1.0,0.0,0.0 diff --git a/programs/develop/libraries/TinyGL/asm_fork/api.asm b/programs/develop/libraries/TinyGL/asm_fork/api.asm index 599a1ae40..17c1a731b 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/api.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/api.asm @@ -951,13 +951,12 @@ endl endp align 4 -proc glClearDepth uses eax, depth:dword +proc glClearDepth uses eax, depth:qword locals p rd 2 endl mov dword[p],OP_ClearDepth - mov eax,[depth] - fld qword[eax] + fld qword[depth] fstp dword[p+4] lea eax,[ebp-8] ;=sizeof(dd)*2 diff --git a/programs/develop/libraries/TinyGL/asm_fork/arrays.asm b/programs/develop/libraries/TinyGL/asm_fork/arrays.asm index 9c62a9f44..2257a725c 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/arrays.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/arrays.asm @@ -23,8 +23,7 @@ endl imul ecx,ebx shl ecx,2 add ecx,[eax+GLContext.color_array] ;ecx = &context.color_array[i] - mov ebx,ebp - sub ebx,20 ;=sizeof(dd)*5 + lea ebx,[ebp-20] ;=sizeof(dd)*5 mov edx,[ecx] mov [ebx+4],edx mov edx,[ecx+4] @@ -48,8 +47,7 @@ endl imul esi,ebx shl esi,2 add esi,[eax+GLContext.normal_array] ;esi = &normal_array[ebx * (3 + c->normal_array_stride)] - mov edi,eax - add edi,GLContext.current_normal + lea edi,[eax+GLContext.current_normal] mov ecx,3 rep movsd mov dword[edi],0.0 @@ -92,8 +90,7 @@ endl imul ecx,ebx shl ecx,2 add ecx,[eax+GLContext.vertex_array] ;ecx = &context.vertex_array[i] - mov ebx,ebp - sub ebx,20 ;=sizeof(dd)*5 + lea ebx,[ebp-20] ;=sizeof(dd)*5 mov edx,[ecx] mov [ebx+4],edx mov edx,[ecx+4] @@ -130,8 +127,7 @@ endl mov eax,[i] mov dword[p+4],eax - mov eax,ebp - sub eax,8 ;=sizeof(dd)*2 + lea eax,[ebp-8] ;=sizeof(dd)*2 stdcall gl_add_op,eax ret endp @@ -139,10 +135,9 @@ endp align 4 proc glopDrawArrays, context:dword, param:dword locals - vi dd ? idx dd ? states dd ? - size dd ? + a_size dd ? p rd 8 ;╤Д╤Г╨╜╨║╤Ж╨╕╤П glopColor ╤В╤А╨╡╨▒╤Г╨╡╤В 8 ╨┐╨░╤А╨░╨╝╨╡╤В╤А╨╛╨▓, ╨┤╤А╤Г╨│╨╕╨╡ ╤Д╤Г╨╜╨║╤Ж╨╕╨╕ ╤В╤А╨╡╨▒╤Г╤О╤В ╨╝╨╡╨╜╤М╤И╨╡, ╨▒╨╡╤А╨╡╨╝ ╨┐╨╛ ╨╝╨░╨║╤Б╨╕╨╝╤Г╨╝╤Г ╤З╤В╨╛-╨▒╤Л ╨╜╨╡ ╨┐╨╛╤А╤В╨╕╤В╤М ╤Б╤В╨╡╨║ endl pushad @@ -155,132 +150,19 @@ pushad mov [idx],eax ;param[2].i mov eax,[ebx+4] mov [p+4],eax ;p[1].i = param[1].i - mov eax,ebp - sub eax,32 ;=sizeof(dd)*8 + lea eax,[ebp-32] ;=sizeof(dd)*8 stdcall glopBegin, edx,eax - mov dword[vi],0 + cmp ecx,1 + jl @f align 4 .cycle_0: ;for (int vi=0; vi],[Up],[Down] - rotate align 4 draw_3d: -stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;╨╛╤З╨╕╤Б╤В╨╕╨╝ ╨▒╤Г╤Д╨╡╤А ╤Ж╨▓╨╡╤В╨░ ╨╕ ╨│╨╗╤Г╨▒╨╕╨╜╤Л +stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;clear the color and depth buffer +mov eax,house_3ds.end-house_3ds +cmp eax,HOUSE_FILE_SIZE +je @f + notify_window_run txt_error_file_size + ret +@@: call [glPushMatrix] - ;╨╝╨░╤Б╤И╤В╨░╨▒ ╨╕ ╨┐╨╛╨▓╨╛╤А╨╛╤В╤Л - stdcall [glTranslatef], 0.0,0.0,0.5 + ;scale and rotations stdcall [glScalef], [scale], [scale], [scale] stdcall [glRotatef], [angle_z],0.0,0.0,1.0 stdcall [glRotatef], [angle_y],0.0,1.0,0.0 stdcall [glRotatef], [angle_x],1.0,0.0,0.0 - ;╤А╨╕╤Б╨╛╨▓╨░╨╜╨╕╨╡ ╤З╨╡╤А╨╡╨╖ ╨╕╨╜╨┤╨╡╨║╤Б╨╜╤Л╨╣ ╨╝╨░╤Б╤Б╨╕╨▓ - mov eax,house_3ds ;╨╜╨░╤З╨░╨╗╨╛ ╨▓╨╜╨╡╨┤╤А╨╡╨╜╨╜╨╛╨│╨╛ ╤Д╨░╨╣╨╗╨░ 3ds - add eax,0xeb ;╤Б╨╝╨╡╤Й╨╡╨╜╨╕╨╡ ╨┐╨╛ ╨║╨╛╤В╨╛╤А╨╛╨╝╤Г ╨╕╨┤╤Г╤В ╨║╨╛╨╛╤А╨┤╨╕╨╜╨░╤В╤Л ╨▓╨╡╤А╤И╨╕╨╜ (╨┐╨╛╨╗╤Г╤З╨╡╨╜╨╛ ╤Б ╨╕╤Б╨┐╨╛╨╗╤М╨╖╨╛╨▓╨░╨╜╨╕╨╡╨╝ ╨┐╤А╨╛╨│╤А╨░╨╝╨╝╤Л info_3ds) - stdcall [glVertexPointer], 3, GL_FLOAT, 0, eax ;╨╖╨░╨┤╨░╨╡╨╝ ╨╝╨░╤Б╤Б╨╕╨▓ ╨┤╨╗╤П ╨▓╨╡╤А╤И╨╕╨╜, 3 - ╤З╨╕╤Б╨╗╨╛ ╨║╨╛╨╛╤А╨┤╨╕╨╜╨░╤В ╨┤╨╗╤П ╨╛╨┤╨╜╨╛╨╣ ╨▓╨╡╤А╤И╨╕╨╜╤Л - stdcall [glEnableClientState], GL_VERTEX_ARRAY ;╨▓╨║╨╗╤О╤З╨░╨╡╨╝ ╤А╨╡╨╢╨╕╨╝ ╤А╨╕╤Б╨╛╨▓╨░╨╜╨╕╤П ╨▓╨╡╤А╤И╨╕╨╜ - stdcall [glDrawElements], GL_TRIANGLES, 0x1a6*3, GL_UNSIGNED_SHORT, Indices ;mode, count, type, *indices - stdcall [glDisableClientState], GL_VERTEX_ARRAY ;╨╛╤В╨║╨╗╤О╤З╨░╨╡╨╝ ╤А╨╡╨╢╨╕╨╝ ╤А╨╕╤Б╨╛╨▓╨░╨╜╨╕╤П ╨▓╨╡╤А╤И╨╕╨╜ + ;drawing via index array + mov eax,house_3ds ;start of embedded 3ds file + add eax,VERTICES_OFFSET + stdcall [glVertexPointer], 3, GL_FLOAT, 0, eax ;we set an array for the vertices, 3 is the number of coordinates for one vertex + stdcall [glEnableClientState], GL_VERTEX_ARRAY ;turn on the vertex drawing mode + stdcall [glDrawElements], GL_TRIANGLES, FACES_COUNT*3, GL_UNSIGNED_SHORT, Indices ;mode, count, type, *indices + stdcall [glDisableClientState], GL_VERTEX_ARRAY ;disable vertex drawing mode call [glPopMatrix] ret align 4 -scale dd 0.0065 ;╨╜╨░╤З╨░╨╗╤М╨╜╤Л╨╣ ╨╝╨░╤Б╤И╤В╨░╨▒ (╨▓ ╨╕╨┤╨╡╨░╨╗╤М╨╜╨╛╨╝ ╤Б╨╗╤Г╤З╨░╨╡ ╨┤╨╛╨╗╨╢╨╡╨╜ ╨▓╤Л╤З╨╕╤Б╨╗╤П╤В╤Б╤П, ╨╜╨╛ ╨┤╨╗╤П ╨┤╨░╨╜╨╛╨│╨╛ ╨┐╤А╨╕╨╝╨╡╤А╨░ ╨┐╨╛╨┤╨╛╨▒╤А╨░╨╜ ╨▓ ╤А╤Г╤З╨╜╤Г╤О ╨╜╨░ ╨│╨╗╨░╨╖) +scale dd 0.07 ;initial scale (ideally should be calculated) delt_sc dd 0.0005 angle_z dd 90.0 angle_y dd 90.0 @@ -170,10 +184,11 @@ angle_x dd 0.0 delt_size dd 3.0 align 4 -house_3ds: ;╨▓╨╜╨╡╨┤╤А╤П╨╡╨╝ ╤Д╨░╨╣╨╗ ╨▓╨╜╤Г╤В╤А╤М ╨┐╤А╨╛╨│╤А╨░╨╝╨╝╤Л (╨▓ ╨╕╨┤╨╡╨░╨╗╤М╨╜╨╛╨╝ ╤Б╨╗╤Г╤З╨░╨╡ ╨┤╨╛╨╗╨╢╨╡╨╜ ╨╛╤В╨║╤А╤Л╨▓╨░╤В╤Б╤П ╤З╨╡╤А╨╡╨╖ ╨╛╨║╨╜╨╛ ╨┤╨╕╨░╨╗╨╛╨│╨░, ╨╜╨╛ ╨┤╨╗╤П ╨╛╨▒╨╗╨╡╨│╤З╨╡╨╜╨╕╤П ╨┐╤А╨╕╨╝╨╡╤А╨░ ╨▓╤И╨╕╤В ╨▓╨╜╤Г╤В╤А╤М) +house_3ds: ;we embed the file inside the program (ideally it should open through a dialog box) file '../../../../../demos/view3ds/3ds_objects/House.3ds' +.end: align 4 -Indices rb 0x1a6*6 ;0x1a6 - ╤З╨╕╤Б╨╗╨╛ ╨│╤А╨░╨╜╨╡╨╣, ╨╜╨░ ╨║╨░╨╢╨┤╤Г╤О ╨│╤А╨░╨╜╤М ╨┐╨╛ 3 ╤В╨╛╤З╨║╨╕, ╨╕╨╜╨┤╨╡╨║╤Б ╤В╨╛╤З╨║╨╕ 2 ╨▒╨░╨╣╤В╨░ +Indices rb FACES_COUNT*6 ;3 points per edge, point index 2 bytes ;-------------------------------------------------- align 4 diff --git a/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu0.asm b/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu0.asm index 1ed52e9a4..89f4bd780 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu0.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu0.asm @@ -36,13 +36,13 @@ red_win: align 16 still: mcall SF_WAIT_EVENT - cmp al,1 - jz red_win - cmp al,2 - jz key - cmp al,3 - jz button - jmp still + cmp al,EV_REDRAW + jz red_win + cmp al,EV_KEY + jz key + cmp al,EV_BUTTON + jz button + jmp still align 4 draw_window: @@ -141,7 +141,6 @@ stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;╨╛╤З╨╕╤Б╤В╨╕╨╝ ╨▒ stdcall [glColor3f], 1.0, 1.0, 0.0 call [glPushMatrix] - stdcall [glTranslatef], 0.0,0.0,0.5 stdcall [glScalef], [scale], [scale], [scale] stdcall [glRotatef], [angle_z],0.0,0.0,1.0 diff --git a/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu1.asm b/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu1.asm index 6e4f95bda..03b809621 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu1.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu1.asm @@ -60,6 +60,7 @@ load_libraries l_libs_start,l_libs_end stdcall [buf2d_convert_text_matrix], buf_1 load_image_file 'toolb_1.png', image_data_toolbar + call SetLight call draw_3d align 4 @@ -69,13 +70,13 @@ red_win: align 4 still: mcall SF_WAIT_EVENT - cmp al,1 - jz red_win - cmp al,2 - jz key - cmp al,3 - jz button - jmp still + cmp al,EV_REDRAW + jz red_win + cmp al,EV_KEY + jz key + cmp al,EV_BUTTON + jz button + jmp still align 4 draw_window: @@ -303,11 +304,7 @@ draw_3d: stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;╨╛╤З╨╕╤Б╤В╨╕╨╝ ╨▒╤Г╤Д╨╡╤А ╤Ж╨▓╨╡╤В╨░ ╨╕ ╨│╨╗╤Г╨▒╨╕╨╜╤Л call [glPushMatrix] - call SetLight - - stdcall [glTranslatef], 0.0,0.0,0.5 stdcall [glScalef], [scale], [scale], [scale] - stdcall [glScalef], 1.0, 1.0, 0.5 stdcall [glColor3f], 1.0, 1.0, 0.0 stdcall [glRotatef], [angle_z],0.0,0.0,1.0 diff --git a/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu2.asm b/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu2.asm index 1acdf9639..64d41205f 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu2.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/examples/test_glu2.asm @@ -60,6 +60,7 @@ load_libraries l_libs_start,l_libs_end stdcall [buf2d_convert_text_matrix], buf_1 load_image_file 'toolb_1.png', image_data_toolbar + call SetLight call draw_3d align 4 @@ -69,13 +70,13 @@ red_win: align 4 still: mcall SF_WAIT_EVENT - cmp al,1 - jz red_win - cmp al,2 - jz key - cmp al,3 - jz button - jmp still + cmp al,EV_REDRAW + jz red_win + cmp al,EV_KEY + jz key + cmp al,EV_BUTTON + jz button + jmp still align 4 draw_window: @@ -296,9 +297,6 @@ draw_3d: stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;╨╛╤З╨╕╤Б╤В╨╕╨╝ ╨▒╤Г╤Д╨╡╤А ╤Ж╨▓╨╡╤В╨░ ╨╕ ╨│╨╗╤Г╨▒╨╕╨╜╤Л call [glPushMatrix] - call SetLight - - stdcall [glTranslatef], 0.0,0.0,0.5 stdcall [glScalef], [scale], [scale], [scale] stdcall [glColor3f], 1.0, 1.0, 0.0 diff --git a/programs/develop/libraries/TinyGL/asm_fork/examples/textures0.asm b/programs/develop/libraries/TinyGL/asm_fork/examples/textures0.asm index 95c76f731..c0e498568 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/examples/textures0.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/examples/textures0.asm @@ -88,13 +88,13 @@ red_win: align 4 still: mcall SF_WAIT_EVENT - cmp al,1 - jz red_win - cmp al,2 - jz key - cmp al,3 - jz button - jmp still + cmp al,EV_REDRAW + jz red_win + cmp al,EV_KEY + jz key + cmp al,EV_BUTTON + jz button + jmp still align 4 draw_window: @@ -295,7 +295,6 @@ draw_3d: stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;╨╛╤З╨╕╤Б╤В╨╕╨╝ ╨▒╤Г╤Д╨╡╤А ╤Ж╨▓╨╡╤В╨░ ╨╕ ╨│╨╗╤Г╨▒╨╕╨╜╤Л call [glPushMatrix] - stdcall [glTranslatef], 0.0,0.0,0.5 stdcall [glScalef], [scale], [scale], [scale] stdcall [glRotatef], [angle_z],0.0,0.0,1.0 stdcall [glRotatef], [angle_y],0.0,1.0,0.0 diff --git a/programs/develop/libraries/TinyGL/asm_fork/examples/textures1.asm b/programs/develop/libraries/TinyGL/asm_fork/examples/textures1.asm index c928d11db..647f81680 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/examples/textures1.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/examples/textures1.asm @@ -88,13 +88,13 @@ red_win: align 4 still: mcall SF_WAIT_EVENT - cmp al,1 - jz red_win - cmp al,2 - jz key - cmp al,3 - jz button - jmp still + cmp al,EV_REDRAW + jz red_win + cmp al,EV_KEY + jz key + cmp al,EV_BUTTON + jz button + jmp still align 4 draw_window: @@ -297,9 +297,8 @@ draw_3d: stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;╨╛╤З╨╕╤Б╤В╨╕╨╝ ╨▒╤Г╤Д╨╡╤А ╤Ж╨▓╨╡╤В╨░ ╨╕ ╨│╨╗╤Г╨▒╨╕╨╜╤Л call [glPushMatrix] - stdcall [glTranslatef], 0.0,0.0,0.5 stdcall [glScalef], [scale], [scale], [scale] - stdcall [glScalef], 1.0, 1.0, 0.1 ;╨┐╤А╨╕╨╢╨╕╨╝╨░╨╡╨╝ ╤Б╤Д╨╡╤А╤Г, ╤З╤В╨╛-╨▒╤Л ╤Б╤А╨░╨╖╤Г ╨╜╨╡ ╨▓╤Л╨╗╨░╨╖╨╕╨╗╨░ ╨┐╤А╨╕ ╤Г╨▓╨╡╨╗╨╕╤З╨╡╨╜╨╕╨╕ + stdcall [glScalef], 1.0, 1.0, 0.2 ;╨┐╤А╨╕╨╢╨╕╨╝╨░╨╡╨╝ ╤Б╤Д╨╡╤А╤Г, ╤З╤В╨╛-╨▒╤Л ╤Б╤А╨░╨╖╤Г ╨╜╨╡ ╨▓╤Л╨╗╨░╨╖╨╕╨╗╨░ ╨┐╤А╨╕ ╤Г╨▓╨╡╨╗╨╕╤З╨╡╨╜╨╕╨╕ stdcall [glRotatef], [angle_y],0.0,1.0,0.0 stdcall [glRotatef], [angle_x],1.0,0.0,0.0 diff --git a/programs/develop/libraries/TinyGL/asm_fork/examples/textures2.asm b/programs/develop/libraries/TinyGL/asm_fork/examples/textures2.asm index 678fc8c94..864a780a1 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/examples/textures2.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/examples/textures2.asm @@ -89,13 +89,13 @@ red_win: align 4 still: mcall SF_WAIT_EVENT - cmp al,1 - jz red_win - cmp al,2 - jz key - cmp al,3 - jz button - jmp still + cmp al,EV_REDRAW + jz red_win + cmp al,EV_KEY + jz key + cmp al,EV_BUTTON + jz button + jmp still align 4 draw_window: @@ -268,8 +268,9 @@ draw_3d: stdcall [glClear], GL_COLOR_BUFFER_BIT + GL_DEPTH_BUFFER_BIT ;╨╛╤З╨╕╤Б╤В╨╕╨╝ ╨▒╤Г╤Д╨╡╤А ╤Ж╨▓╨╡╤В╨░ ╨╕ ╨│╨╗╤Г╨▒╨╕╨╜╤Л call [glPushMatrix] + stdcall [glTranslatef], 0.0,0.0,-1.0 ;╨┤╨▓╨╕╨│╨░╨╡╨╝ ╤Б╤Д╨╡╤А╤Г ╨╜╨░ ╤Б╨╡╨▒╤П, ╤З╤В╨╛-╨▒╤Л ╨╛╤В╤Б╨╡╤З╤М ╨┐╨╡╤А╨╡╨┤╨╜╤О╤О ╤З╨░╤Б╤В╤М stdcall [glScalef], [scale], [scale], [scale] - stdcall [glScalef], 1.0, 1.0, 0.1 ;╨┐╤А╨╕╨╢╨╕╨╝╨░╨╡╨╝ ╤Б╤Д╨╡╤А╤Г, ╤З╤В╨╛-╨▒╤Л ╤Б╤А╨░╨╖╤Г ╨╜╨╡ ╨▓╤Л╨╗╨░╨╖╨╕╨╗╨░ ╨┐╤А╨╕ ╤Г╨▓╨╡╨╗╨╕╤З╨╡╨╜╨╕╨╕ + stdcall [glScalef], 1.0, 1.0, 0.2 ;╨┐╤А╨╕╨╢╨╕╨╝╨░╨╡╨╝ ╤Б╤Д╨╡╤А╤Г, ╤З╤В╨╛-╨▒╤Л ╤Б╤А╨░╨╖╤Г ╨╜╨╡ ╨▓╤Л╨╗╨░╨╖╨╕╨╗╨░ ╨┐╤А╨╕ ╤Г╨▓╨╡╨╗╨╕╤З╨╡╨╜╨╕╨╕ stdcall [glRotatef], [angle_y],0.0,1.0,0.0 stdcall [glRotatef], [angle_x],1.0,0.0,0.0 diff --git a/programs/develop/libraries/TinyGL/asm_fork/light.asm b/programs/develop/libraries/TinyGL/asm_fork/light.asm index 469b1ae94..7d1bc2d75 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/light.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/light.asm @@ -185,7 +185,7 @@ align 4 cmp ecx,GL_SPOT_EXPONENT jne @f mov ecx,[ebx+12] - mov [edi+GLLight.spot_exponent],ecx ;l.spot_exponent=p[3] + mov [edx+GLLight.spot_exponent],ecx ;l.spot_exponent=p[3] jmp .end_f align 4 @@: @@ -193,7 +193,7 @@ align 4 jne .end_spot_c fld dword[ebp+12] ;float a=v.v[0] ; assert(a == 180 || (a>=0 && a<=90)); - fst dword[edi+GLLight.spot_cutoff] ;l.spot_cutoff=a + fst dword[edx+GLLight.spot_cutoff] ;l.spot_cutoff=a fcom dword[an180f] ;if (a != 180) fstsw ax sahf @@ -202,7 +202,7 @@ align 4 fmulp fdiv dword[an180f] fcos - fstp dword[edi+GLLight.cos_spot_cutoff] ;l.cos_spot_cutoff=cos(a * M_PI / 180.0) + fstp dword[edx+GLLight.cos_spot_cutoff] ;l.cos_spot_cutoff=cos(a * M_PI / 180.0) jmp .end_f @@: ffree st0 @@ -213,21 +213,21 @@ align 4 cmp ecx,GL_CONSTANT_ATTENUATION jne @f mov ecx,[ebx+12] - mov [edi+GLLight.attenuation],ecx ;l->attenuation[0]=p[3] + mov [edx+GLLight.attenuation],ecx ;l->attenuation[0]=p[3] jmp .end_f align 4 @@: cmp ecx,GL_LINEAR_ATTENUATION jne @f mov ecx,[ebx+12] - mov [edi+GLLight.attenuation+4],ecx ;l->attenuation[1]=p[3] + mov [edx+GLLight.attenuation+4],ecx ;l->attenuation[1]=p[3] jmp .end_f align 4 @@: cmp ecx,GL_QUADRATIC_ATTENUATION jne @f mov ecx,[ebx+12] - mov [edi+GLLight.attenuation+8],ecx ;l->attenuation[2]=p[3] + mov [edx+GLLight.attenuation+8],ecx ;l->attenuation[2]=p[3] jmp .end_f align 4 @@: ;default: @@ -363,15 +363,14 @@ fl_1e_3 dd 1.0e-3 align 16 proc gl_shade_vertex, context:dword, v:dword locals - R dd ? ;float ebp-96 - G dd ? ;float ebp-92 - B dd ? ;float ebp-88 - A dd ? ;float ebp-84 - s V3 ;ebp-80 - d V3 ;ebp-68 - tmp dd ? ;float ebp-56 - att dd ? ;float ebp-52 - dot_spot dd ? ;float ebp-48 + R dd ? ;float ebp-92 + G dd ? ;float ebp-88 + B dd ? ;float ebp-84 + A dd ? ;float ebp-80 + s V3 ;ebp-76 + d V3 ;ebp-64 + tmp dd ? ;float ebp-52 + att dd ? ;float ebp-48 lR dd ? ;float ebp-44 lB dd ? ;float ebp-40 lG dd ? ;float ebp-36 @@ -563,7 +562,6 @@ align 4 fmul dword[d+offs_Z] faddp fchs - fst dword[dot_spot] cmp dword[twoside],0 ;if (twoside && dot_spot < 0) je @f ftst ;if (dot_spot<0) diff --git a/programs/develop/libraries/TinyGL/asm_fork/list.asm b/programs/develop/libraries/TinyGL/asm_fork/list.asm index cafaf4c48..ac6a76104 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/list.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/list.asm @@ -197,21 +197,24 @@ push edi esi add ebx,4 inc esi - cmp byte[esi],'f' + cmp byte[esi],'f' ;float jne @f fld dword[ebx] fstp qword[Data_Double] call DoubleFloat_to_String stdcall str_cat, edi,Data_String @@: - cmp byte[esi],'d' - jne @f + cmp byte[esi],'C' ;const + je @f + cmp byte[esi],'d' ;integer + je @f + jmp .no_param + @@: stdcall str_len,edi add edi,eax sub ecx,eax mov eax,dword[ebx] stdcall convert_int_to_str,ecx - @@: .no_param: inc esi cmp byte[esi],0 diff --git a/programs/develop/libraries/TinyGL/asm_fork/vertex.asm b/programs/develop/libraries/TinyGL/asm_fork/vertex.asm index 02ff3f3b4..cbd4ae2cc 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/vertex.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/vertex.asm @@ -134,7 +134,7 @@ endl cmp dword[edx+GLContext.lighting_enabled],0 ;if(context.lighting_enabled) jne .if_0 - cmp dword[eax+GLContext.texture_2d_enabled],0 + cmp dword[edx+GLContext.texture_2d_enabled],0 jne .if_0 jmp @f align 4 diff --git a/programs/develop/libraries/TinyGL/asm_fork/zline.asm b/programs/develop/libraries/TinyGL/asm_fork/zline.asm index 264ec53d1..05538dc7e 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/zline.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/zline.asm @@ -17,7 +17,7 @@ proc ZB_plot uses eax ebx ecx edx edi, zb:dword, p:dword mov edi,[ebx+ZBufferPoint.z] shr edi,ZB_POINT_Z_FRAC_BITS cmp di,word[ecx] - jl .end_f + jb .end_f if TGL_FEATURE_RENDER_BITS eq 24 mov eax,[ebx+ZBufferPoint.r] mov byte[edx],ah diff --git a/programs/develop/libraries/TinyGL/asm_fork/zline.inc b/programs/develop/libraries/TinyGL/asm_fork/zline.inc index 3bf0fb51d..b3232d350 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/zline.inc +++ b/programs/develop/libraries/TinyGL/asm_fork/zline.inc @@ -101,7 +101,7 @@ local .end_0 mov [zz],eax mov ebx,[pz] cmp ax,word[ebx] - jl .end_0 + jb .end_0 RGBPIXEL mov eax,dword[zz] mov ebx,[pz] diff --git a/programs/develop/libraries/TinyGL/asm_fork/zline_r.inc b/programs/develop/libraries/TinyGL/asm_fork/zline_r.inc index 62c881cd1..d41717539 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/zline_r.inc +++ b/programs/develop/libraries/TinyGL/asm_fork/zline_r.inc @@ -102,7 +102,7 @@ local .end_0 mov [zz],eax mov ebx,[pz] cmp ax,word[ebx] - jl .end_0 + jb .end_0 RGBPIXEL mov eax,dword[zz] mov ebx,[pz] diff --git a/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm b/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm index 83a562d30..ce8b43c05 100644 --- a/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm +++ b/programs/develop/libraries/TinyGL/asm_fork/ztriangle.asm @@ -58,7 +58,7 @@ end if mov eax,[z] shr eax,ZB_POINT_Z_FRAC_BITS cmp ax,word[esi+2*_a] ;if (zz >= pz[_a]) - jl .end_0 + jb .end_0 ;edi = pp mov word[esi+2*_a],ax ;╨┐╨╕╤И╨╡╨╝ ╨▓ ╨▒╤Г╤Д╨╡╤А ╨│╨╗╤Г╨▒╨╕╨╜╤Л ╨╜╨╛╨▓╨╛╨╡ ╨╖╨╜╨░╤З╨╡╨╜╨╕╨╡ if TGL_FEATURE_RENDER_BITS eq 24 @@ -103,7 +103,7 @@ local .end_0 mov eax,[z] shr eax,ZB_POINT_Z_FRAC_BITS cmp ax,word[esi+2*_a] ;if (zz >= pz[_a]) - jl .end_0 + jb .end_0 ;edi = pp mov word[esi+2*_a],ax ;╨┐╨╕╤И╨╡╨╝ ╨▓ ╨▒╤Г╤Д╨╡╤А ╨│╨╗╤Г╨▒╨╕╨╜╤Л ╨╜╨╛╨▓╨╛╨╡ ╨╖╨╜╨░╤З╨╡╨╜╨╕╨╡ if TGL_FEATURE_RENDER_BITS eq 24 @@ -171,7 +171,7 @@ local .end_0 mov eax,[z] shr eax,ZB_POINT_Z_FRAC_BITS cmp ax,word[esi+2*_a] ;if (zz >= pz[_a]) - jl .end_0 + jb .end_0 ;edi = pp mov word[esi+2*_a],ax ;╨┐╨╕╤И╨╡╨╝ ╨▓ ╨▒╤Г╤Д╨╡╤А ╨│╨╗╤Г╨▒╨╕╨╜╤Л ╨╜╨╛╨▓╨╛╨╡ ╨╖╨╜╨░╤З╨╡╨╜╨╕╨╡ if TGL_FEATURE_RENDER_BITS eq 24 @@ -251,7 +251,7 @@ local .end_0 mov eax,[z] shr eax,ZB_POINT_Z_FRAC_BITS cmp ax,word[esi+2*_a] ;if (zz >= pz[_a]) - jl .end_0 + jb .end_0 ;edi = pp mov word[esi+2*_a],ax ;╨┐╨╕╤И╨╡╨╝ ╨▓ ╨▒╤Г╤Д╨╡╤А ╨│╨╗╤Г╨▒╨╕╨╜╤Л ╨╜╨╛╨▓╨╛╨╡ ╨╖╨╜╨░╤З╨╡╨╜╨╕╨╡ if TGL_FEATURE_RENDER_BITS eq 24 diff --git a/programs/develop/libraries/box_lib/trunk/tree_list.asm b/programs/develop/libraries/box_lib/trunk/tree_list.asm index 99511353f..f5994d04e 100644 --- a/programs/develop/libraries/box_lib/trunk/tree_list.asm +++ b/programs/develop/libraries/box_lib/trunk/tree_list.asm @@ -170,6 +170,7 @@ proc tl_key uses ebx ecx edi, tlist:dword cmp tl_on_press,0 je @f call tl_on_press + jmp .no_edit @@: cmp ah,byte[ecx+1] ;Space jne @f diff --git a/programs/media/voxel_editor/utilites/vox_tgl.asm b/programs/media/voxel_editor/utilites/vox_tgl.asm index e5608bdad..b9d4785e9 100644 --- a/programs/media/voxel_editor/utilites/vox_tgl.asm +++ b/programs/media/voxel_editor/utilites/vox_tgl.asm @@ -16,9 +16,9 @@ include 'lang.inc' ; Language support for locales: ru_RU (CP866), en_US. @use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load if lang eq ru_RU -caption db 'Просмотр вокселей 11.11.20',0 ;подпись окна +caption db 'Просмотр вокселей 14.04.25',0 ;подпись окна else ; Default to en_US -caption db 'Voxel viewer 11.11.20',0 +caption db 'Voxel viewer 14.04.25',0 end if 3d_wnd_l equ 5 ;отступ для tinygl буфера слева @@ -750,12 +750,8 @@ draw_3d: je @f call SetLight @@: - stdcall [glTranslatef], 0.0,0.0,0.5 ;координаты по оси z должны быть в пределах от 0.0 до 1.0, иначе изображение будет отсекаться - ;воксельный объект имеет координаты по осям от -0.5 до 0.5, потому его двигаем на +0.5 - ;но все же при поворотах будут отсекатся края, которые вылезут за пределы плоскостей отсечения - ;в версии opengl под Win координаты идут от -1.0 до 1.0 потому там этого делать не нужно stdcall [glScalef], [scale], [scale], [scale] ;увеличиваем воксельный объект, что-бы не был очень маленьким - stdcall [glScalef], 1.0, 1.0, 0.25 ;что-бы края объекта не вылазили за грани отсечения + stdcall [glScalef], 1.0, 1.0, 0.5 ;что-бы края объекта не вылазили за грани отсечения stdcall [glRotatef], [angle_x],1.0,0.0,0.0 stdcall [glRotatef], [angle_y],0.0,1.0,0.0 stdcall [glRotatef], [angle_z],0.0,0.0,1.0 diff --git a/programs/network/ftpc/console.inc b/programs/network/ftpc/console.inc index e17535cce..d858a8416 100755 --- a/programs/network/ftpc/console.inc +++ b/programs/network/ftpc/console.inc @@ -105,7 +105,6 @@ console: ;////////////////////////////////////////////////////////////////////// mov eax, [esp+36] call write_to_file - @@: popad ret 4 diff --git a/programs/network/ftpc/ftpc.asm b/programs/network/ftpc/ftpc.asm index a77286934..f8b3c185d 100644 --- a/programs/network/ftpc/ftpc.asm +++ b/programs/network/ftpc/ftpc.asm @@ -1,6 +1,6 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; ;; -;; Copyright (C) KolibriOS team 2013-2021. All rights reserved. ;; +;; Copyright (C) KolibriOS team 2013-2025. All rights reserved. ;; ;; Distributed under terms of the GNU General Public License ;; ;; ;; ;; ftpc.asm - FTP client for KolibriOS ;; @@ -36,8 +36,8 @@ use32 dd 1 ; header version dd start ; entry point dd i_end ; initialized size - dd mem+0x1000 ; required memory - dd mem+0x1000 ; stack pointer + dd mem ; required memory + dd stacktop ; stack pointer dd buf_cmd ; parameters dd path ; path @@ -83,12 +83,12 @@ start: ;//////////////////////////////////////////////////////////////////////// ;< none ;; ;;================================================================================================;; ; initialize heap for using dynamic blocks - mcall 68, 11 + mcall SF_SYS_MISC, SSF_HEAP_INIT test eax, eax je exit2 ; disable all events except network event - mcall 40, EV_STACK + mcall SF_SET_EVENTS_MASK, EV_STACK ; load libraries stdcall dll.Load, @IMPORT test eax, eax @@ -125,16 +125,16 @@ start: ;//////////////////////////////////////////////////////////////////////// mov [acti_port_stop], ax invoke ini.get_str, path, str_general, str_dir, buf_buffer1, BUFFERSIZE, 0 - mcall 30, 1, buf_buffer1 ; set working directory + mcall SF_CURRENT_FOLDER, SSF_SET_CF, buf_buffer1 ; set working directory ; initialize log file invoke ini.get_str, path, str_general, str_logfile, log_file, 512, 0 - mov [filestruct2.subfn], 2 + mov [filestruct2.subfn], SSF_CREATE_FILE mov [filestruct2.offset], 0 mov [filestruct2.size], 0 mov [filestruct2.ptr], 0 mov [filestruct2.name], log_file - mcall 70, filestruct2 + mcall SF_FILE, filestruct2 ; Usage: ftpc [-cli] [ftp://username:password@server:port/path] @@ -355,7 +355,7 @@ wait_for_servercommand: ;/////////////////////////////////////////////////////// ; receive socket data with timeout .receive: - mcall 26, 9 + mcall SF_SYSTEM_GET, SSF_TIME_COUNT add eax, TIMEOUT*100 mov [timeout], eax .again: @@ -365,11 +365,11 @@ wait_for_servercommand: ;/////////////////////////////////////////////////////// je .closed cmp ebx, EWOULDBLOCK jne .sock_err - mcall 26, 9 + mcall SF_SYSTEM_GET, SSF_TIME_COUNT mov ebx, [timeout] sub ebx, eax jle .timeout - mcall 23 ; Wait for event with timeout + mcall SF_WAIT_EVENT_TIMEOUT ; Wait for event with timeout jmp .again .sock_err: @@ -524,7 +524,7 @@ transfer_queued: ; Error occured, we reached the end of the buffer before [queued] reached 0 mov [queued], 0 - mcall 68, 13, [ptr_fname] ; free buffer + mcall SF_SYS_MISC, SSF_MEM_FREE, [ptr_fname] ; free buffer test eax, eax jz error_heap jmp wait_for_usercommand @@ -535,7 +535,7 @@ transfer_queued: dec [queued] jnz cmd_retr - mcall 68, 13, [ptr_fname] ; free buffer + mcall SF_SYS_MISC, SSF_MEM_FREE, [ptr_fname] ; free buffer test eax, eax jz error_heap jmp cmd_retr @@ -655,12 +655,12 @@ write_to_file: ;//////////////////////////////////////////////////////////////// mov eax, 0 ret @@: - mov [filestruct2.subfn], 3 + mov [filestruct2.subfn], SSF_WRITE_FILE m2m [filestruct2.offset], [logfile_offset] mov [filestruct2.size], ecx mov [filestruct2.ptr], eax mov [filestruct2.name], log_file - mcall 70, filestruct2 + mcall SF_FILE, filestruct2 test eax, eax jz @f mov [logfile_offset], -1 ; disable logging @@ -754,13 +754,13 @@ wait_for_keypress: exit: mcall close, [controlsocket] exit2: - mcall -1 + mcall SF_TERMINATE_PROCESS ; data str_title db 'FTP client for KolibriOS',0 -str_welcome db 'FTP client for KolibriOS v0.16',10 +str_welcome db 'FTP client for KolibriOS v0.18',10 db 10,0 str_srv_addr db 'Please enter ftp server address.',10,0 @@ -971,6 +971,7 @@ param_path rb 1024 param_port rb 6 sc system_colors -rb 1024 - +align 16 +rb 4096 +stacktop: mem: diff --git a/programs/network/ftpc/ftpc_nod.png b/programs/network/ftpc/ftpc_nod.png deleted file mode 100755 index 09c292a01..000000000 Binary files a/programs/network/ftpc/ftpc_nod.png and /dev/null differ diff --git a/programs/network/ftpc/ftpc_sys.png b/programs/network/ftpc/ftpc_sys.png deleted file mode 100755 index 8081e4e01..000000000 Binary files a/programs/network/ftpc/ftpc_sys.png and /dev/null differ diff --git a/programs/network/ftpc/gui.inc b/programs/network/ftpc/gui.inc index c8b452156..f686d058d 100755 --- a/programs/network/ftpc/gui.inc +++ b/programs/network/ftpc/gui.inc @@ -7,6 +7,9 @@ include '../../load_lib.mac' icon_tl_sys dd 0 icon_tl_nod dd 0 +icon_buttons dd 0 +lbl_after_enter dd 0 +show_log db 0 ; 0 - hide log, 1 - show log TLIST_SZ = 325+16 ;=341. 16 is x-size of scroll bar TLIST1_X = 50 @@ -15,6 +18,9 @@ BT_SZ_X = 40 SYS_COL = 0xe6e6e6 BT_COL = 0xcccccc STR_COL = 0x595959 ;0x000000 +ICON_TOP_B = 2 ; top border +ICON_LEFT_B = 2 ; left border +ICON_SIZE = (18+ICON_LEFT_B)*(18+ICON_TOP_B)*3 ; TODO: automatic resizing of GUI elements on window resizing @@ -45,8 +51,8 @@ gui: ;////////////////////////////////////////////////////////////////////////// test eax, eax jnz .exit - mcall 48, 3, sc, sizeof.system_colors - mcall 40, 0xC0000027 ; set event mask + mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, sizeof.system_colors + mcall SF_SET_EVENTS_MASK, 0xC0000027 ; set event mask ret .server_addr: @@ -73,37 +79,42 @@ gui: ;////////////////////////////////////////////////////////////////////////// ; initialize tree list elements stdcall [tl_data_init], tree1 stdcall [tl_data_init], tree2 - - or dword[tree1.style], 8 ;tl_cursor_pos_limited - restrict cursor move to existing nodes - or dword[tree2.style], 8 ;tl_cursor_pos_limited - - ; read icons - load_image_file 'ftpc_sys.png', icon_tl_sys - mov [filestruct.ptr], eax - mov [filestruct.subfn], 0 - mov [filestruct.offset], 54 - mov [filestruct.size], ecx - mcall 70, filestruct - cmp ebx, 0 - jl @f + or dword[tree1.style], 8 ;tl_cursor_pos_limited - restrict cursor move to existing nodes + or dword[tree2.style], 8 ;tl_cursor_pos_limited + + ; read icons + mcall SF_SYS_MISC, SSF_MEM_OPEN, str_icon_18,, 0 + or eax, eax + jz @f + mov esi, eax + mov ecx, ICON_SIZE*11 + mcall SF_SYS_MISC, SSF_MEM_ALLOC + mov ecx, eax + mov [icon_tl_sys], eax + stdcall copy_icon, eax,esi,31 ;active cursor + add eax, ICON_SIZE*3 ;skip not used icons + stdcall img_to_gray, ecx, eax, ICON_SIZE/3 ;not active cursor + m2m dword[tree1.data_img_sys], dword[icon_tl_sys] m2m dword[tree2.data_img_sys], dword[icon_tl_sys] - @@: ; read nodes icon file - load_image_file 'ftpc_nod.png', icon_tl_nod + mov ecx, ICON_SIZE*2 + mcall SF_SYS_MISC, SSF_MEM_ALLOC + mov [icon_tl_nod], eax + stdcall copy_icon, eax,esi,2 + stdcall copy_icon, eax,esi,0 - mov [filestruct.ptr], eax - ;mov [filestruct.subfn], 0 - ;mov [filestruct.offset], 54 - mov [filestruct.size], ecx - mcall 70, filestruct - cmp ebx, 0 - jl @f m2m dword[tree1.data_img], dword[icon_tl_nod] m2m dword[tree2.data_img], dword[icon_tl_nod] - + + ; initialize icon buttons + mov ecx, 18*18*4*2 + mcall SF_SYS_MISC, SSF_MEM_ALLOC + mov [icon_buttons], eax + stdcall copy_icon_w, eax,esi, 4 ;disconnect + stdcall copy_icon_w, eax,esi,49 ;search @@: call .draw ; create initial tree list for root_dir @@ -117,11 +128,11 @@ gui: ;////////////////////////////////////////////////////////////////////////// jmp cmd_list .redraw: - call .draw + call .draw align 4 .still: - mcall 10 + mcall SF_WAIT_EVENT dec eax jz .redraw @@ -146,65 +157,86 @@ gui: ;////////////////////////////////////////////////////////////////////////// align 4 .draw: - mcall 12, 1 + mcall SF_REDRAW, SSF_BEGIN_DRAW ; main window - mcall 0, <35,830>, <20,555>, 0x34000000+SYS_COL, 0x805080DD, str_title + mcall SF_CREATE_WINDOW, <35,830>, <20,555-160>, 0x34000000+SYS_COL, 0x805080DD, str_title ;------------------------- ; textedit components ;------------------------- - mcall 9, procinfo, -1 + mcall SF_THREAD_INFO, procinfo, -1 mov edi, tedit0 call EvSize movzx ebx,word[procinfo.client_box.width] inc bx - mcall 13, , ted_wnd_t - stdcall [ted_draw], tedit0 + mcall SF_DRAW_RECT, , ted_wnd_t ; draw "disconnect" button - mcall 8, <50,95>, <25,25>, 3, BT_COL + mcall SF_DEFINE_BUTTON, <50,114>, <25,25>, 3, BT_COL + ; icon + mcall SF_PUT_IMAGE_EXT, [icon_buttons], <18, 18>, <54, 29>, 32,, 0 ; string "disconnect" - mcall 4, <50+5,25+5>, 0xb0000000+STR_COL, str_disconnect + mcall SF_DRAW_TEXT, <50+18+10,25+5>, 0xb0000000+STR_COL, str_disconnect + + ; draw "Show|Hide log" button + mcall SF_DEFINE_BUTTON, <50,79>, <326,25>, 10, BT_COL + ; string "Show|Hide log" + cmp [show_log],0 + je @f + stdcall [ted_draw], tedit0 + mov edx, str_hide_log + jmp .end_log_1 + @@: + mov edx, str_show_log + .end_log_1: + mcall SF_DRAW_TEXT, <50+5,326+5>, 0xb0000000+STR_COL + cmp [show_log],0 + je @f ; draw "Copy" button - mcall 8, <50,40>, <326,25>, 4, BT_COL + mcall SF_DEFINE_BUTTON, <129+5,40>, <326,25>, 4, BT_COL ; string "copy" - mcall 4, <50+5,326+5>, 0xb0000000+STR_COL, str_copy + mcall SF_DRAW_TEXT, <129+10,326+5>, 0xb0000000+STR_COL, str_copy + @@: ; draw "Search" button - mcall 8, , <20,25>, 5, BT_COL + mcall SF_DEFINE_BUTTON, , <20,25>, 5, BT_COL + ; icon + mov ebx, [icon_buttons] + add ebx, 18*18*4 + mcall SF_PUT_IMAGE_EXT,, <18, 18>, <730, 24>, 32,, 0 ; string "Search" - mcall 4, , 0xb0000000+STR_COL, str_search + ;mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_search ; draw "LIST" button - mcall 8, , <50,25>, 12, BT_COL + mcall SF_DEFINE_BUTTON, , <50,25>, 12, BT_COL ; string "LIST" - mcall 4, , 0xb0000000+STR_COL, str_list + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_list ; draw "DELE" button - mcall 8, , <50,25>, 7, BT_COL + mcall SF_DEFINE_BUTTON, , <50,25>, 7, BT_COL ; string "DELE" - mcall 4, , 0xb0000000+STR_COL, str_dele + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_dele ; draw "RDIR" button - mcall 8, , <50,25>, 8, BT_COL + mcall SF_DEFINE_BUTTON, , <50,25>, 8, BT_COL ; string "RDIR" - mcall 4, , 0xb0000000+STR_COL, str_rdir + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_rdir ; draw "RMD" button - mcall 8, , <50,25>, 9, BT_COL + mcall SF_DEFINE_BUTTON, , <50,25>, 9, BT_COL ; string "RMD" - mcall 4, , 0xb0000000+STR_COL, str_rmd + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_rmd ; draw "mkd" button - mcall 8, , <80,20>, 6, BT_COL + mcall SF_DEFINE_BUTTON, , <80,20>, 6, BT_COL ; string "mkd" - mcall 4, , 0xb0000000+STR_COL, str_mkd + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_mkd ; draw "cancel" button - ;mcall 8, <555,55>, <308,25>, 10, BT_COL + ;mcall SF_DEFINE_BUTTON, <555,55>, <308,25>, 10, BT_COL ; string "Cancel" - ;mcall 4, <555+5,308+5>, 0xb0000000+STR_COL, str_abort + ;mcall SF_DRAW_TEXT, <555+5,308+5>, 0xb0000000+STR_COL, str_abort ; draw "change volume" button - mcall 8, , <100-20,22>, 11, BT_COL + mcall SF_DEFINE_BUTTON, , <100-20,22>, 11, BT_COL ; string "Change" - mcall 4, , 0xb0000000+STR_COL, str_change + mcall SF_DRAW_TEXT, , 0xb0000000+STR_COL, str_change ;-------------------------- ; tree list components @@ -222,12 +254,12 @@ gui: ;////////////////////////////////////////////////////////////////////////// stdcall [edit_box_draw], edit_volume stdcall [edit_box_draw], edit_search - mcall 12,2 + mcall SF_REDRAW, SSF_END_DRAW ret align 16 .mouse: - mcall 37, 1 + mcall SF_MOUSE_GET, SSF_WINDOW_POSITION cmp word[tedit0.wnd.top], ax jg .no_edit @@ -235,7 +267,7 @@ gui: ;////////////////////////////////////////////////////////////////////////// cmp word[tedit0.wnd.left], ax jg .no_edit - mcall 37, 3 + mcall SF_MOUSE_GET, SSF_BUTTON_EXT bt eax, 24 jnc @f @@ -243,12 +275,19 @@ gui: ;////////////////////////////////////////////////////////////////////////// jmp .still @@: + cmp [show_log],0 + je .still stdcall [ted_mouse], tedit0 jmp .still .no_edit: + mov [lbl_after_enter], 0 stdcall [tl_mouse], tree1 stdcall [tl_mouse], tree2 + cmp [lbl_after_enter], 0 + jz @f + jmp [lbl_after_enter] + @@: stdcall [edit_box_mouse], edit_mkd stdcall [edit_box_mouse], edit_volume stdcall [edit_box_mouse], edit_search @@ -256,9 +295,14 @@ gui: ;////////////////////////////////////////////////////////////////////////// align 16 .key: - mcall 2 + mcall SF_GET_KEY + mov [lbl_after_enter], 0 stdcall [tl_key], tree1 stdcall [tl_key], tree2 + cmp [lbl_after_enter], 0 + jz @f + jmp [lbl_after_enter] + @@: stdcall [edit_box_key], edit_mkd stdcall [edit_box_key], edit_volume stdcall [edit_box_key], edit_search @@ -266,13 +310,19 @@ gui: ;////////////////////////////////////////////////////////////////////////// align 16 .button: - mcall 17 + mcall SF_GET_BUTTON cmp ah, 3 jne @f ijmp eax, interface_addr, interface.server_addr jmp .still + @@: + cmp ah, 10 + jne @f + call show_hide_log + jmp .still + @@: cmp ah, 4 jne @f @@ -310,7 +360,7 @@ gui: ;////////////////////////////////////////////////////////////////////////// @@: cmp ah, 1 je .exit - + jmp .still .print: @@ -327,13 +377,15 @@ gui: ;////////////////////////////////////////////////////////////////////////// cmp byte[esi], 0 jne @b stdcall [ted_text_add], tedit0, tedit_buffer, ecx, ebx + cmp [show_log],0 + je .end_log_2 stdcall [ted_draw], tedit0 + .end_log_2: ; write to log file mov eax, [esp+36] sub ecx, 2 ; 0a0d is not included call write_to_file - @@: popad ret 4 @@ -353,13 +405,16 @@ gui: ;////////////////////////////////////////////////////////////////////////// ;< none ;; ;;================================================================================================;; - push edx - push eax + cmp eax, 1 + jl data_loop + push edx eax ; check if any incomplete entry to be parsed cmp byte[remote_list_buf], 0 je .no_backlog + ; find end of remote_list_buf mov edi, remote_list_buf + mov ecx, 1024 ;buffer size mov al, 0 repne scasb ; copy rest of the incomplete entry to remote_list_buf @@ -424,6 +479,8 @@ gui: ;////////////////////////////////////////////////////////////////////////// mov byte[edi], 0 ; add node to tree list + and dword[tree2.style], not 8 + stdcall [tl_cur_next], tree2 cmp word[node_entry2], 'fi' jne @f stdcall [tl_node_add], tree2, 0, node_entry2 @@ -453,9 +510,9 @@ gui: ;////////////////////////////////////////////////////////////////////////// .store_last_entry: ; find index of the last incomplete entry - mov ecx, -1 mov eax, [esp] lea edi, [buf_buffer2+eax-2] + mov ecx, eax mov al, 0x0a std repne scasb @@ -470,9 +527,10 @@ gui: ;////////////////////////////////////////////////////////////////////////// jne @b .done_parsing: + stdcall [tl_cur_beg], tree2 + or dword[tree2.style], 8 call .draw ; to update tree list immediately in case of "auto_list" - pop eax - pop edx + pop eax edx jmp data_loop ; clear tree list and add ".." node before executing "LIST" @@ -494,7 +552,7 @@ gui: ;////////////////////////////////////////////////////////////////////////// ;;================================================================================================;; ; detect abort - mcall 17 + mcall SF_GET_BUTTON cmp ah, 10 je cmd_abor @@ -578,7 +636,8 @@ fun_on_enter: cmp byte[esi], 0 jne @b mov word[edi], 0x000a - jmp cmd_stor + mov [lbl_after_enter], cmd_stor + ret ; Function to call when you press [Enter] @@ -591,7 +650,8 @@ fun_on_enter2: cmp dword[esi], 0x2E2E jne @f mov [auto_list], 1 - jmp cmd_cdup + mov [lbl_after_enter], cmd_cdup + ret @@: cmp word[eax], 'fo' @@ -610,12 +670,14 @@ fun_on_enter2: ; newline in console code cmp word[eax], 'fo' je @f - jmp cmd_retr + mov [lbl_after_enter], cmd_retr + ret @@: stdcall [tl_info_clear], tree2 mov [auto_list], 1 - jmp cmd_cwd + mov [lbl_after_enter], cmd_cwd + ret ;;================================================================================================;; @@ -641,7 +703,7 @@ populate_local_tree_list: ;///////////////////////////////////////////////////// jne @f ; removes last file name from filestruct.name - mcall 30, 2, filestruct.name,1024 ; get absolute path for cwd + mcall SF_CURRENT_FOLDER, SSF_GET_CF, filestruct.name,1024 ; get absolute path for cwd lea edi, [filestruct.name+eax] ; edi = pointer to the tail of file name mov al, '/' mov ecx, -1 @@ -652,15 +714,15 @@ populate_local_tree_list: ;///////////////////////////////////////////////////// mov ecx, filestruct.name @@: - mcall 30, 1, ; set cwd - mcall 30, 2, filestruct.name, 1024 ; get absolute path for cwd + mcall SF_CURRENT_FOLDER, SSF_SET_CF ; set cwd + mcall SF_CURRENT_FOLDER, SSF_GET_CF, filestruct.name, 1024 ; get absolute path for cwd ; clear all nodes in tree list stdcall [tl_info_clear], tree1 mov [filestruct.offset], 0 ; read 32 blocks .outer: - mcall 70, filestruct + mcall SF_FILE, filestruct ;int3 test eax, eax jz @f @@ -746,6 +808,16 @@ EvSize: ret +; +show_hide_log: + mov esi, 555 + xor [show_log],1 + jnz @f + sub esi, 160 + @@: + mcall SF_CHANGE_WINDOW, -1, -1, -1 + ret + ;;================================================================================================;; filter_remote_list: ;/////////////////////////////////////////////////////////////////////////////;; ;;------------------------------------------------------------------------------------------------;; @@ -861,30 +933,133 @@ search: ;/////////////////////////////////////////////////////////////////////// pop edi esi edx ecx ebx ret + +align 4 +proc copy_icon uses ebx ecx esi edi, buf_d:dword, buf_s:dword, ind:dword +;;------------------------------------------------------------------------------------------------;; +;> buf_d = pointer to destination buffer 24-bit +;> buf_s = pointer to source buffer 32-bit (with icons) +;> ind = icon index +;;------------------------------------------------------------------------------------------------;; +;< eax = pointer to destination buffer + icon size +;;------------------------------------------------------------------------------------------------;; + mov edi, [buf_d] + mov ecx, (18+ICON_LEFT_B)*ICON_TOP_B*3 + mov al, 0xff + rep stosb ; make top border + ; copy icon + mov esi, [ind] + imul esi, 18*18*4 + add esi, [buf_s] + mov ebx, 18 + .cycle0: + mov ecx, ICON_LEFT_B*3 + rep stosb ; make left border + mov ecx, 18 + @@: + movsw + movsb + inc esi ; skip transparent byte + loop @b + dec ebx + jnz .cycle0 + mov eax, edi + ret +endp + + +align 4 +proc img_to_gray, buf_rgb:dword, buf_g24:dword, pixels:dword +;;------------------------------------------------------------------------------------------------;; +; function for generating gray icons +;;------------------------------------------------------------------------------------------------;; +;> buf_rgb - buffer with input 24-bit color image +;> buf_g24 - buffer with output 24-bit gray image +;> pixels - number of pixels in the image +;;------------------------------------------------------------------------------------------------;; +pushad + mov esi, [buf_rgb] + mov edi, [buf_g24] + mov ecx, [pixels] + mov ebx, 3 + @@: + movzx eax, byte[esi] + movzx edx, byte[esi+1] + add eax, edx + movzx edx, byte[esi+2] + add eax, edx + xor edx, edx + div ebx + mov ah, al + mov word[edi], ax + mov byte[edi+2], al + add esi, 3 + add edi, 3 + loop @b +popad + ret +endp + + +align 4 +proc copy_icon_w uses ecx esi edi, buf_d:dword, buf_s:dword, ind:dword +;;------------------------------------------------------------------------------------------------;; +;> buf_d = pointer to destination buffer 32-bit +;> buf_s = pointer to source buffer 32-bit (with icons) +;> ind = icon index +;;------------------------------------------------------------------------------------------------;; +;< eax = pointer to destination buffer + icon size +;;------------------------------------------------------------------------------------------------;; + mov edi, [buf_d] + mov ecx, 18*18 + mov esi, [ind] + imul esi, ecx + shl esi, 2 + add esi, [buf_s] + rep movsd + mov eax, edi + + mov ecx, 18*18 + mov edi, [buf_d] + mov esi, [edi] ;copy transparent color + .cycle0: + cmp [edi], esi + jne @f + mov dword[edi], BT_COL + @@: + add edi, 4 + loop .cycle0 + ret +endp + ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> ;hed db 'FTP Client for KolibriOS',0 str_change db 'Change',0 str_disconnect db 'Disconnect',0 +str_show_log db 'Show log',0 +str_hide_log db 'Hide log',0 str_copy db 'Copy',0 str_mkd db 'MKD',0 str_dele db 'DELE',0 str_rdir db 'RDIR',0 str_rmd db 'RMD',0 str_abort db 'Cancel',0 -str_search db 'Search',0 +;str_search db 'Search',0 str_list db 'LIST',0 str_null db 0 +str_icon_18 db 'ICONS18',0 + ;---------------------- ; tree list elements ;---------------------- -tree1 tree_list 64, 500, tl_list_box_mode, 16, 16, \ - 0xffffff, BT_COL, 0x000000, TLIST1_X, 105, TLIST_SZ-16, 185, 14, 4,\ +tree1 tree_list 64, 500, tl_list_box_mode, 18+ICON_LEFT_B, 18+ICON_TOP_B, \ + 0xffffff, BT_COL, 0x10000000, TLIST1_X, 105, TLIST_SZ-16, 185, 15, 4,\ 0, el_focus, wScr, fun_on_enter -tree2 tree_list 64, 500, tl_list_box_mode, 16, 16, \ - 0xffffff, BT_COL, 0x000000, TLIST2_X, 105, TLIST_SZ-16, 185, 14, 4, \ +tree2 tree_list 64, 500, tl_list_box_mode, 18+ICON_LEFT_B, 18+ICON_TOP_B, \ + 0xffffff, BT_COL, 0x10000000, TLIST2_X, 105, TLIST_SZ-16, 185, 15, 4, \ 0, el_focus, wScr2, fun_on_enter2 ; editbox for mkd @@ -896,7 +1071,7 @@ edit_volume edit_box TLIST_SZ-60, TLIST1_X, 80, 0xffffff, 0x94AECE, 0, \ 0xAABBCC, 0x10000000, 99, root_dir, mouse_dd, 0 ; editbox for search -edit_search edit_box TLIST_SZ-60, TLIST2_X, 22, 0xffffff, 0x94AECE, 0, \ +edit_search edit_box TLIST_SZ-30, TLIST2_X, 22, 0xffffff, 0x94AECE, 0, \ 0xAABBCC, 0x10000000, 99, filter,mouse_dd, 0 ; A subsidiary structure for scrolling diff --git a/programs/network/ftpc/login_gui.inc b/programs/network/ftpc/login_gui.inc index 71c27df6e..388803278 100755 --- a/programs/network/ftpc/login_gui.inc +++ b/programs/network/ftpc/login_gui.inc @@ -27,7 +27,7 @@ login_gui: ;//////////////////////////////////////////////////////////////////// .get_username: ; in case of error when either login_gui.server_addr or ; login_gui.get_username is called, should resize window - mcall 67, WIN_X, WIN_Y, WIN_W, WIN_H ; resize to login gui window size + mcall SF_CHANGE_WINDOW, WIN_X, WIN_Y, WIN_W, WIN_H ; resize to login gui window size .redraw: call .draw @@ -44,22 +44,22 @@ login_gui: ;//////////////////////////////////////////////////////////////////// align 4 .draw: - mcall 12, 1 - mcall 48, 3, sc, 40 + mcall SF_REDRAW, SSF_BEGIN_DRAW + mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, 40 edit_boxes_set_sys_color edit_usr,editboxes_end,sc mov edx, 0x34000000 or edx, [sc.work] - mcall 0, , , , 0x805080DD, str_title + mcall SF_CREATE_WINDOW, , , , 0x805080DD, str_title call .draw_editboxes ; draw "connect" button - mcall 8, <162,65>, <150,25>, 2, [sc.work_button] + mcall SF_DEFINE_BUTTON, <162,65>, <150,25>, 2, [sc.work_button] ; draw strings mov ecx, 0x90000000 or ecx, [sc.work_text] - mcall 4, <3, 8>, , gui_str_usr + mcall SF_DRAW_TEXT, <3, 8>, , gui_str_usr mcall , <3,PAD*1+8>, , gui_str_pass mcall , <3,PAD*2+8>, , gui_str_server mcall , <3,PAD*3+8>, , gui_str_port @@ -74,12 +74,12 @@ login_gui: ;//////////////////////////////////////////////////////////////////// mcall mov [str_error_addr], gui_str_null ; reset error string address - mcall 12, 2 + mcall SF_REDRAW, SSF_END_DRAW ret align 4 .still: - mcall 10 ; wait for event + mcall SF_WAIT_EVENT dec eax jz .redraw dec eax @@ -96,7 +96,7 @@ login_gui: ;//////////////////////////////////////////////////////////////////// jmp .still .button: - mcall 17 + mcall SF_GET_BUTTON dec ah jz .exit @@ -107,7 +107,7 @@ login_gui: ;//////////////////////////////////////////////////////////////////// jmp .still .key: - mcall 2 + mcall SF_GET_KEY cmp ah,13 je .connect @@ -122,12 +122,17 @@ login_gui: ;//////////////////////////////////////////////////////////////////// stdcall [edit_box_key], edit_path jmp .still - + .connect: - mcall 67, 35, 20, 830, 555 ; resize to main gui window's coordinates + mov esi, 555 + or [show_log],0 + jnz @f + sub esi, 160 + @@: + mcall SF_CHANGE_WINDOW, 35, 20, 830 ; resize to main gui window's coordinates cmp [param_server_addr], 0 - jne gui.main - + jne gui.main + mov [str_error_addr], gui_str_no_srvr jmp .redraw diff --git a/programs/network/ftpc/servercommands.inc b/programs/network/ftpc/servercommands.inc index d8275a7f1..607b3ec9e 100644 --- a/programs/network/ftpc/servercommands.inc +++ b/programs/network/ftpc/servercommands.inc @@ -190,10 +190,11 @@ data_loop: mov [filestruct.ptr], buf_buffer2 mov [filestruct.size], eax push eax - mcall 70, filestruct + mcall SF_FILE, filestruct test eax, eax jz @f call error_fs + add esp, 4 ; fix stack jmp close_datacon @@: pop eax @@ -204,7 +205,7 @@ data_loop: ; storing, send all data .stor: - mcall 70, filestruct + mcall SF_FILE, filestruct cmp eax, 6 ; end of file je .last_call test eax, eax ; error @@ -244,7 +245,7 @@ data_loop: mov ecx, eax ; eax is size of buffer received inc ecx add ecx, [size_fname] ; added old size to form new required size - mcall 68, 20, , [ptr_fname] ; realloc + mcall SF_SYS_MISC, SSF_MEM_REALLOC, , [ptr_fname] test eax, eax je error_heap mov [ptr_fname], eax ; eax contains the new block now diff --git a/programs/network/ftpc/usercommands.inc b/programs/network/ftpc/usercommands.inc index 2cba28ddc..28d4422a9 100644 --- a/programs/network/ftpc/usercommands.inc +++ b/programs/network/ftpc/usercommands.inc @@ -82,13 +82,13 @@ cmd_retr: mov ecx, 256-5 call set_filename - mov [filestruct.subfn], 2 ; create/rewrite file + mov [filestruct.subfn], SSF_CREATE_FILE ; create/rewrite file mov [filestruct.offset], 0 mov [filestruct.offset+4], 0 mov [filestruct.size], 0 mov [filestruct.ptr], 0 - mcall 70, filestruct + mcall SF_FILE, filestruct test eax, eax jz @f call error_fs @@ -96,7 +96,7 @@ cmd_retr: @@: ; Prepare to write to the file - mov [filestruct.subfn], 3 ; write to file + mov [filestruct.subfn], SSF_WRITE_FILE mov [operation], OPERATION_RETR ; Request the file from server @@ -138,7 +138,7 @@ cmd_stor: mov [operation], OPERATION_STOR ; get file size - mov [filestruct.subfn], 5 + mov [filestruct.subfn], SSF_GET_INFO mov [filestruct.offset], 0 mov [filestruct.offset+4], 0 mov [filestruct.size], 0 @@ -148,12 +148,12 @@ cmd_stor: mov ecx, 256-5 call set_filename - mcall 70, filestruct + mcall SF_FILE, filestruct mov eax, dword[folder_buf+32] ; supports file size upto 4GB mov [file_size], eax - mov [filestruct.subfn], 0 ; read file + mov [filestruct.subfn], SSF_READ_FILE ; mov [filestruct.offset], 0 ; mov [filestruct.offset+4], 0 mov [filestruct.size], BUFFERSIZE @@ -191,12 +191,12 @@ cmd_lcwd: mov byte[esi-1], 0 ; check whether entered path is valid (folder exists) - mov [filestruct2.subfn], 5 + mov [filestruct2.subfn], SSF_GET_INFO mov [filestruct2.offset], 0 mov [filestruct2.size], 0 mov [filestruct2.ptr], folder_buf mov [filestruct2.name], buf_cmd+5 - mcall 70, filestruct2 + mcall SF_FILE, filestruct2 test eax, eax jz @f cmp eax, 2 @@ -205,10 +205,10 @@ cmd_lcwd: jmp wait_for_usercommand @@: - mcall 30, 1, buf_cmd+5 ; set working directory + mcall SF_CURRENT_FOLDER, SSF_SET_CF, buf_cmd+5 ; set working directory .print: - mcall 30, 2, buf_cmd, 256 ; and read it again + mcall SF_CURRENT_FOLDER, SSF_GET_CF, buf_cmd, 256 ; and read it again icall eax, interface_addr, interface.print, str_lcwd, buf_cmd, str_newline jmp wait_for_usercommand diff --git a/programs/other/calcplus/Tupfile.lua b/programs/other/calcplus/Tupfile.lua index e6cab4f15..6e5ed9a6c 100644 --- a/programs/other/calcplus/Tupfile.lua +++ b/programs/other/calcplus/Tupfile.lua @@ -1,2 +1,5 @@ if tup.getconfig("NO_FASM") ~= "" then return end -tup.rule("calcplus.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "calcplus") +HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR") +tup.include(HELPERDIR .. "/use_fasm.lua") +tup.rule("calcplus.asm", FASM .. " -dlang=" .. tup.getconfig("LANG") .. " %f %o" .. tup.getconfig("KPACK_CMD"), "%B") + diff --git a/programs/other/calcplus/build.bat b/programs/other/calcplus/build.bat deleted file mode 100644 index 47c354cbd..000000000 --- a/programs/other/calcplus/build.bat +++ /dev/null @@ -1,2 +0,0 @@ -@fasm calcplus.asm calc+ -@pause \ No newline at end of file diff --git a/programs/other/calcplus/calcplus.asm b/programs/other/calcplus/calcplus.asm index 8f328163f..eedb40637 100644 --- a/programs/other/calcplus/calcplus.asm +++ b/programs/other/calcplus/calcplus.asm @@ -1,668 +1,728 @@ - VERSION equ "0.5" +; SPDX-License-Identifier: GPL-2.0-only +; +; Calc+ - Multifunctional calculator +; Copyright (C) 2014-2025 KolibriOS team +; +; Contributor eAndrew - Main code +; Contributor Leency - Code refactoring and UX/UI update +; Contributor Burer - Code refactoring and UI update - use32 - org 0 - db 'MENUET01' - dd 1, main, dataend, memory, stacktop, 0, 0 +; ==================================================================== - include "../../proc32.inc" - include "../../macros.inc" - include "../../dll.inc" - include "../../develop/libraries/box_lib/trunk/box_lib.mac" - ; include "../../debug.inc" - include "parser.inc" +use32 +org 0 - ;=============================== +db 'MENUET01' +dd 1 +dd START +dd I_END +dd MEM +dd STACKTOP +dd 0, 0 - LIST_ITEM_SIZE equ 16 - LIST_ITEM_COUNT equ 6 - LIST_SIZE equ LIST_ITEM_SIZE * LIST_ITEM_COUNT - LIST_ITEM_COLOR1 equ dword [scn.btn_face] - LIST_ITEM_COLOR2 equ dword [scn.win_face] - LIST_ITEM_TEXT1 equ dword [scn.btn_text] - LIST_ITEM_TEXT2 equ dword [scn.win_text] - LIST_ITEM_Y equ LIST_ITEM_SIZE / 2 - 3 - - KEYB_SIZE equ 140 - - sz_cont db "Keyboard ", 0x10 - sz_head db "Calc+ v", VERSION, 0 - btn_clr db "" - buttons db "|%^*/-+)(=7894561230" - edb1 edit_box 0, 8, 12, 0, 0, 0, 0, 0, 480, \ - exp, group, ed_always_focus + ed_focus, 0, 0 - - imports: - library gui, "box_lib.obj" - import gui, editbox.draw, "edit_box", \ - editbox.key, "edit_box_key", \ - editbox.mouse, "edit_box_mouse" - - ;=============================== - - main: - mov [ans.buffer], dword "= 0" - mov [ans.size], 3 * 6 + 9 - - mcall 40, 100111b - ; mcall 48, 3, scn, 192 - - - m2m [edb1.color], [scn.gui_face] - m2m [edb1.shift_color], [scn.gui_select] - m2m [edb1.focus_border_color], [scn.gui_face] - m2m [edb1.text_color], [scn.gui_text] - - mcall 68, 11 - stdcall dll.Load, imports - - ;---------------------- - - update: - mcall 23, 5 - - cmp eax, EV_REDRAW - je ev_redraw - cmp eax, EV_KEY - je ev_key - cmp eax, EV_BUTTON - je ev_button - cmp eax, EV_MOUSE - je ev_mouse - - jmp update - - ;---------------------- - - ev_redraw: - mcall 12, 1 - - ; WINDOW - mov edx, [scn.win_face] - or edx, 0x34 shl 24 - mcall 0, <100, 236 + 100 - 50 - 25>, <100, 66 + LIST_SIZE>, , , sz_head - - ; TOOLBAR - mov ebx, 120 shl 16 + 64 - mcall 8, , <-17, 12>, 2 + 1 shl 30 - add ebx, 4 shl 16 - (64 + 14) - mcall 4, , [scn.win_title], sz_cont, 10 - - ; CONTENT - call draw_textbox - call draw_keyb - call draw_list - - mcall 12, 2 - - jmp update - - ;---------------------- - - ev_key: - mcall 2 - cmp ah, 27 - je exit - cmp ah, 13 - je calc - invoke editbox.key, edb1 - jmp update - - ;---------------------- - - ev_button: - mcall 17 - - ; EXIT - cmp ah, 1 - je exit - - ; DELETE - cmp ah, 4 - jne .not_del - cmp [edb1.pos], 0 - je update - mov eax, exp - add eax, [edb1.pos] - dec eax - mov ebx, exp - add ebx, [edb1.size] - inc ebx - @@: - cmp eax, ebx - je @f - mov cl, [eax + 1] - mov [eax], cl - inc eax - jmp @b - @@: - dec [edb1.pos] - dec [edb1.size] - m2m [edb1.shift], [edb1.pos] - jmp .redraw - .not_del: - - ; SHOW/HIDE KEYBOARD - cmp ah, 2 - jne .not_keyb - - cmp [keyb], byte 0 - je .open - - mov [keyb], 0 - mov [sz_cont + 9], byte 0x10 - mcall 67, -1, -1, 286 - 25, -1 - jmp update - - .open: - mov [keyb], 1 - mov [sz_cont + 9], byte 0x11 - mcall 67, -1, -1, 286 - 25 + KEYB_SIZE, -1 - jmp update - .not_keyb: - - ; CALCULATE - cmp ah, 19 - je calc - - ; LIST - cmp ah, 0x60 - jl .not_list - - sub ah, 0x60 - movzx ebx, ah - imul ebx, 512 - add ebx, history - add ebx, 482 - stdcall str_len, ebx - - mov edx, exp - add edx, [edb1.size] - add edx, eax - mov edi, exp - add edi, [edb1.pos] - @@: - cmp edx, edi - je @f - mov esi, edx - sub esi, eax - push eax - mov al, [esi] - mov [edx], al - pop eax - dec edx - jmp @b - @@: - add [edb1.size], eax - - @@: - cmp eax, 0 - je @f - mov cl, [ebx] - mov [edi], cl - inc edi - inc ebx - dec eax - inc [edb1.pos] - jmp @b - @@: - - jmp .redraw - .not_list: - - ; KEYBOARD - cmp ah, 10 - jl update - cmp ah, 50 - jg update - mov dh, ah - - mov ebx, exp - add ebx, [edb1.size] - mov ecx, exp - add ecx, [edb1.pos] - cmp dh, 30 - jl @f - add ebx, 2 - @@: - cmp ebx, ecx - je @f - mov dl, [ebx - 1] - mov [ebx], dl - dec ebx - jmp @b - @@: - - movzx eax, dh - add eax, buttons - sub eax, 10 - mov al, [eax] - - mov [ebx], al - inc [edb1.size] - inc [edb1.pos] - cmp dh, 30 - jl @f - add [edb1.size], 2 - add [edb1.pos], 2 - @@: - .redraw: - call draw_textbox - jmp update - - ;---------------------- - - ev_mouse: - mcall 2 - - invoke editbox.mouse, edb1 - jmp update - - ;---------------------- - - exit: - mcall -1 - - ;---------------------- - - calc: - stdcall parse - cmp [error_n], 0 - jne .error - - mov [ans.buffer], word "= " - - stdcall convert_to_str, eax, ans.buffer + 2 - add eax, 2 - mov edi, eax - imul eax, 6 - add eax, 9 - mov [ans.size], eax - - ; HISTORY - mov ecx, LIST_ITEM_COUNT - 1 - mov eax, history - add eax, (LIST_ITEM_COUNT - 1) * 512 - @@: - mov ebx, eax - sub ebx, 512 - stdcall str_cpy, ebx, eax - add ebx, 480 - add eax, 480 - stdcall str_cpy, ebx, eax - sub ebx, 480 - sub eax, 480 - mov esi, [ebx + 508] - mov [eax + 508], esi - sub eax, 512 - loop @b - - stdcall str_cpy, exp, history - stdcall str_cpy, ans.buffer, history + 480 - mov esi, [ans.size] - mov dword[history + 508], esi - not [his_even] - - ; Check length - mov esi, 37 - sub esi, edi - stdcall str_len, exp - sub esi, eax - cmp esi, 0 - jg .redraw - - mov ebx, history - add ebx, eax - add ebx, esi - mov [ebx], dword ".." - - jmp .redraw - - ; ERRORS - - .error: - cmp [error_n], 1 - je .err_1 - cmp [error_n], 4 - je .err_4 - - mov [ans.buffer + 0], dword "Expe" - mov [ans.buffer + 4], dword "cted" - mov [ans.buffer + 8], dword " ')'" - mov [ans.buffer + 12], byte 0 - mov [ans.size], 81 - - cmp [error_n], 2 - je .redraw - cmp [error_n], 3 - je .err_3 - cmp [error_n], 5 - je .err_5 - .err_1: - mov [ans.buffer + 0], dword "Div." - mov [ans.buffer + 4], dword " by " - mov [ans.buffer + 8], byte "0" - mov [ans.buffer + 9], byte 0 - mov [ans.size], 63 - jmp .redraw - .err_4: - mov [ans.buffer + 0], dword "Inpu" - mov [ans.buffer + 4], dword "t er" - mov [ans.buffer + 8], dword "rror" - mov [ans.buffer + 12], byte 0 - mov [ans.size], 81 - jmp .redraw - .err_3: - mov [ans.buffer + 10], byte "(" - jmp .redraw - .err_5: - mov [ans.buffer + 10], byte "|" - jmp .redraw - - .redraw: - call draw_textbox - call draw_list - jmp update - - ;---------------------- - - proc draw_button, x, y - mcall 8, <[x], 30>, <[y], 21>, [but_id], [but_c] - - mov ebx, [x] - mov esi, [txt_size] - imul esi, 3 - mov edi, 16 - sub edi, esi - add ebx, edi - shl ebx, 16 - add ebx, [y] - add ebx, 7 - mcall 4, , [but_tc], [txt_id], [txt_size] - - mov eax, [txt_size] - add [txt_id], eax - inc dword [but_id] - - ret - endp - - ;---------------------- - - proc draw_textbox - mcall 13, <4, 320 - 50 - 25>, < 8, 23>, [scn.gui_frame] - mov edx, [scn.gui_face] - cmp [error_n], 0 - je @f - mov edx, 0xFFAAAA - @@: - mcall 13, < 5, 318 - 50 - 25>, < 9, 21> - mcall , < 5, 318 - 50 - 25>, < 9, 1>, [scn.3d_face] - mcall , < 5, 1>, < 10, 20> - mcall , < 5, 318 - 50 - 25>, < 31, 1>, [scn.3d_light] - - mov ebx, 328 - 16 - 50 - 25 - sub ebx, [ans.size] - shl ebx, 16 - add ebx, 16 - mov ecx, [scn.gui_intext] - or ecx, 1 shl 31 - mcall 4, , , ans.buffer - - mov ecx, [scn.gui_text] - mcall , <310 - 50 - 25, 16>, , btn_clr, 1 - add ebx, 1 shl 16 - mcall - - mcall 8, <305 - 50 - 25, 17>, <9, 20>, 0x40000004 - - mcall 1, 4, 8, [scn.win_body] - mcall , 323 - 50 - 25 - mcall , , 30, [scn.3d_light] - mcall , 4 - - mov ebx, 318 - 16 - 50 - 25 - sub ebx, [ans.size] - cmp ebx, 24 - jg @f - mov ebx, 24 - @@: - mov [edb1.width], ebx - m2m [edb1.color], [scn.gui_face] - m2m [edb1.focus_border_color], [scn.gui_face] - cmp [error_n], 0 - je @f - mov [edb1.color], 0xFFAAAA - mov [edb1.focus_border_color], 0xFFAAAA - @@: - invoke editbox.draw, edb1 - - ret - endp - - ;---------------------- - - proc draw_keyb - cmp [keyb], byte 0 - je @f - - mov [txt_size], 1 - mov [but_id], 0x0000000A - mov [txt_id], buttons - - mov eax, [scn.win_face] - mov [but_c], eax - mov eax, [scn.win_text] - mov [but_tc], eax - stdcall draw_button, 4 + 278 - 25, 42 - 25 - 8 - stdcall draw_button, 37 + 278 - 25, 42 - 25 - 8 - stdcall draw_button, 70 + 278 - 25, 42 - 25 - 8 - stdcall draw_button, 103 + 278 - 25, 42 - 25 - 8 - stdcall draw_button, 103 + 278 - 25, 66 - 25 - 8 - stdcall draw_button, 103 + 278 - 25, 90 - 25 - 8 - stdcall draw_button, 103 + 278 - 25, 114 - 25 - 8 - stdcall draw_button, 70 + 278 - 25, 139 - 25 - 8 - stdcall draw_button, 37 + 278 - 25, 139 - 25 - 8 - - mov eax, [scn.btn_inface] - mov [but_c], eax - mov eax, [scn.btn_intext] - mov [but_tc], eax - stdcall draw_button, 103 + 278 - 25, 139 - 25 - 8 - - mov eax, [scn.btn_face] - mov [but_c], eax - mov eax, [scn.btn_text] - mov [but_tc], eax - stdcall draw_button, 4 + 278 - 25, 66 - 25 - 8 - stdcall draw_button, 37 + 278 - 25, 66 - 25 - 8 - stdcall draw_button, 70 + 278 - 25, 66 - 25 - 8 - stdcall draw_button, 4 + 278 - 25, 90 - 25 - 8 - stdcall draw_button, 37 + 278 - 25, 90 - 25 - 8 - stdcall draw_button, 70 + 278 - 25, 90 - 25 - 8 - stdcall draw_button, 4 + 278 - 25, 114 - 25 - 8 - stdcall draw_button, 37 + 278 - 25, 114 - 25 - 8 - stdcall draw_button, 70 + 278 - 25, 114 - 25 - 8 - stdcall draw_button, 4 + 278 - 25, 139 - 25 - 8 - - @@: - ret - endp - - ;---------------------- - - proc draw_list - ; BACKGROUND - mov edi, LIST_ITEM_COUNT - mov eax, 13 - mov ebx, 4 shl 16 + 320 - 50 - 25 - mov ecx, 37 shl 16 + LIST_ITEM_SIZE - mov edx, LIST_ITEM_COLOR1 - cmp [his_even], byte 0 - je @f - mov edx, LIST_ITEM_COLOR2 - @@: - mcall - add ecx, LIST_ITEM_SIZE shl 16 - cmp edx, LIST_ITEM_COLOR1 - je .set_color_to_2 - mov edx, LIST_ITEM_COLOR1 - jmp .next - .set_color_to_2: - mov edx, LIST_ITEM_COLOR2 - .next: - dec edi - cmp edi, 0 - jne @b - - ; BUTTONS - mov edi, LIST_ITEM_COUNT - mov eax, 8 - mov ebx, 4 shl 16 + 320 - 50 - 25 - mov ecx, 37 shl 16 + LIST_ITEM_SIZE - mov edx, 0x40000060 - @@: - mcall - add ecx, LIST_ITEM_SIZE shl 16 - inc edx - dec edi - cmp edi, 0 - jne @b - - ; TEXT - mov edi, LIST_ITEM_COUNT - mov eax, 4 - mov ebx, 8 shl 16 + 37 + LIST_ITEM_Y - mov ecx, LIST_ITEM_TEXT1 - cmp [his_even], byte 0 - je @f - mov ecx, LIST_ITEM_TEXT2 - @@: - or ecx, 1 shl 31 - mov edx, history - @@: - mcall - - push ebx - add ebx, (320 - 50 - 25) shl 16 - mov esi, [edx + 508] - shl esi, 16 - sub ebx, esi - add edx, 480 - mcall - pop ebx - - add edx, 32 - add ebx, LIST_ITEM_SIZE - - and ecx, 0xFFFFFF - cmp ecx, LIST_ITEM_TEXT2 - je .set_color_to_2_txt - mov ecx, LIST_ITEM_TEXT2 - jmp .next_txt - .set_color_to_2_txt: - mov ecx, LIST_ITEM_TEXT1 - .next_txt: - or ecx, 1 shl 31 - - dec edi - cmp edi, 0 - jne @b - - ret - endp - - ;---------------------- - - proc str_len uses ebx, str - xor eax, eax - mov ebx, [str] - @@: - cmp [ebx], byte 0 - je @f - inc eax - inc ebx - jmp @b - @@: - - ret - endp - - ;---------------------- - - proc str_cpy uses eax ebx ecx, from, to - mov eax, [from] - mov ebx, [to] - @@: - cmp [eax], byte 0 - je @f - mov cl, [eax] - mov [ebx], cl - inc eax - inc ebx - jmp @b - @@: - mov [ebx], byte 0 - ret - endp - - ;---------------------- - - dataend: - - ;=============================== - - rb 2048 - stacktop: - - exp rb 480 - exp_pos rd 1 - exp_lvl rd 1 - abs_lvl rd 1 - group rd 1 - - ans.buffer:rb 480 - ans.size rd 1 - error_n rd 1 - - timer rd 1 - but_id rd 1 - but_c rd 1 - but_tc rd 1 - txt_id rd 1 - txt_size rd 1 - keyb rb 1 - - his_even rb 1 - history rb 512 * LIST_ITEM_COUNT - rb 512 - -struc system_colors_internal { - .3d_face dd 0xCED0D0 - .3d_dark dd 0xD7D7D7 - .3d_light dd 0xFEFEFE - .win_title dd 0x2F2F2F - .win_body dd 0xE4DFE1 - .btn_face dd 0xEFEBEF - .btn_text dd 0x373C42 - .win_text dd 0x000000 - .panel_frame dd 0x94AECE - .win_face dd 0xE1E1E1 - .win_inface dd 0xE1E1E1 - .win_frame dd 0x204962 - .btn_inface dd 0xEFEBEF - .btn_intext dd 0xD0D9E8 - .btn_fctext dd 0x2D3135 - .gui_shadow dd 0xFFFFFF - .gui_face dd 0xFAF8FA - .gui_inface dd 0xF6F3F6 - .gui_fcface dd 0xFAF8FA - .gui_frame dd 0x7698C0 - .gui_text dd 0x373C42 - .gui_intext dd 0x5F5F5F - .gui_select dd 0xC7C9C9 -} - - scn system_colors_internal - - memory: +; ==================================================================== + +include "../../proc32.inc" +include "../../macros.inc" +include "../../KOSfuncs.inc" +include "../../encoding.inc" +include "../../dll.inc" +include "../../develop/libraries/box_lib/trunk/box_lib.mac" +include "parser.inc" + +imports: + + library gui, "box_lib.obj" + import gui, editbox.draw, "edit_box", \ + editbox.key, "edit_box_key", \ + editbox.mouse, "edit_box_mouse" + +; ==================================================================== + +LIST_X = 8 +LIST_Y = 47 +LIST_ITEM_H = 26 +LIST_ITEM_W = 295 +LIST_ITEM_COUNT = 8 +LIST_H = LIST_ITEM_H * LIST_ITEM_COUNT +LIST_TEXT_Y = LIST_ITEM_H / 2 - 8 + +KEYB_BTN_W = 37 +KEYB_BTN_H = 37 +GAP = 5 + +KEYBOARD_X = LIST_ITEM_W + 16 +KEYBOARD_Y = LIST_Y +KEYBOARD_W = 190 + +LIST_ITEM_TEXT1 equ dword [sc.work_text] +LIST_ITEM_TEXT2 equ dword [sc.work_text] + +WIN_X = 200 +WIN_Y = 200 +WIN_W = LIST_ITEM_W + KEYBOARD_W + 7 +WIN_H = LIST_H + 60 + +sz_head db "Calc+", 0 +btn_clr db "" ; "Enter" symbol, curved arrow in input area +buttons db "|%^*/-+)(=7894561230" +edb1 edit_box 0, 14, 12, 0xFFFFFF, 0x94AECE, 0xFFC90E, 0xCACACA, 0x10000000, \ + 480, exp, group, ed_always_focus + ed_focus, 0, 0 + +; ==================================================================== + +START: + mov [ans.buffer], dword " = 0" + mov [ans.size], 4 * 8 + 9 + + mcall SF_SET_EVENTS_MASK, EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + + m2m [edb1.color], [scn.gui_face] + + mcall SF_SYS_MISC, SSF_HEAP_INIT + stdcall dll.Load, imports + +; ==================================================================== + +update: + mcall SF_WAIT_EVENT_TIMEOUT, 5 + + cmp eax, EV_REDRAW + je ev_redraw + + cmp eax, EV_KEY + je ev_key + + cmp eax, EV_BUTTON + je ev_button + + cmp eax, EV_MOUSE + je ev_mouse + + jmp update + +; ==================================================================== + +ev_redraw: + mcall SF_REDRAW, SSF_BEGIN_DRAW + mcall SF_STYLE_SETTINGS, SSF_GET_COLORS, sc, sizeof.system_colors + + ; WINDOW + mov edx, [sc.work] + or edx, 0x34 shl 24 + + mcall SF_STYLE_SETTINGS, SSF_GET_SKIN_HEIGHT + mov ecx, WIN_Y shl 16 + WIN_H + add ecx, eax + + mcall SF_GET_SCREEN_SIZE + shr eax, 16 + mov ebx, eax + sub ebx, WIN_W + shr ebx, 1 + + mcall 0, , , , , sz_head + + ; CONTENT + call draw_textbox + call draw_keyb + call draw_list + + mcall SF_REDRAW, SSF_END_DRAW + + jmp update + +; ==================================================================== + +ev_key: + mcall SF_GET_KEY + + cmp ah, 27 + je exit + + cmp ah, 13 + je calc + + invoke editbox.key, edb1 + + jmp update + +; ==================================================================== + +ev_button: + mcall SF_GET_BUTTON + + ; EXIT + cmp ah, 1 + je exit + + cmp ah, 250 + jne @f + mcall SF_FILE, f70_calc + jmp update + + ; DELETE + @@: + cmp ah, 4 + jne .not_del + + cmp [edb1.pos], 0 + je update + mov eax, exp + add eax, [edb1.pos] + dec eax + mov ebx, exp + add ebx, [edb1.size] + inc ebx + + @@: + cmp eax, ebx + je @f + mov cl, [eax + 1] + mov [eax], cl + inc eax + jmp @b + + @@: + dec [edb1.pos] + dec [edb1.size] + m2m [edb1.shift], [edb1.pos] + jmp .redraw + + .not_del: + + ; CALCULATE + cmp ah, 19 + je calc + + ; LIST + cmp ah, 0x60 + jl .not_list + + sub ah, 0x60 + movzx ebx, ah + imul ebx, 512 + add ebx, history + add ebx, 482 + stdcall str_len, ebx + + mov edx, exp + add edx, [edb1.size] + add edx, eax + mov edi, exp + add edi, [edb1.pos] + + @@: + cmp edx, edi + je @f + mov esi, edx + sub esi, eax + push eax + mov al, [esi] + mov [edx], al + pop eax + dec edx + jmp @b + + @@: + add [edb1.size], eax + + @@: + cmp eax, 0 + je @f + mov cl, [ebx] + mov [edi], cl + inc edi + inc ebx + dec eax + inc [edb1.pos] + jmp @b + + @@: + jmp .redraw + + .not_list: + + ; KEYBOARD + cmp ah, 10 + jl update + cmp ah, 50 + jg update + mov dh, ah + + mov ebx, exp + add ebx, [edb1.size] + mov ecx, exp + add ecx, [edb1.pos] + cmp dh, 30 + jl @f + add ebx, 2 + + @@: + cmp ebx, ecx + je @f + mov dl, [ebx - 1] + mov [ebx], dl + dec ebx + jmp @b + + @@: + movzx eax, dh + add eax, buttons + sub eax, 10 + mov al, [eax] + + mov [ebx], al + inc [edb1.size] + inc [edb1.pos] + cmp dh, 30 + jl @f + add [edb1.size], 2 + add [edb1.pos], 2 + + @@: + .redraw: + call draw_textbox + jmp update + +; ==================================================================== + +ev_mouse: + mcall SF_GET_KEY + + invoke editbox.mouse, edb1 + jmp update + +; ==================================================================== + +exit: + mcall SF_TERMINATE_PROCESS + +; ==================================================================== + +calc: + stdcall parse + cmp [error_n], 0 + jne .error + + mov [ans.buffer], dword " = " + + stdcall convert_to_str, eax, ans.buffer + 3 + add eax, 3 + mov edi, eax + imul eax, 8 ; char_w + add eax, 9 + mov [ans.size], eax + + ; HISTORY + mov ecx, LIST_ITEM_COUNT - 1 + mov eax, history + add eax, (LIST_ITEM_COUNT - 1) * 512 + + @@: + mov ebx, eax + sub ebx, 512 + stdcall str_cpy, ebx, eax + add ebx, 480 + add eax, 480 + stdcall str_cpy, ebx, eax + sub ebx, 480 + sub eax, 480 + mov esi, [ebx + 508] + mov [eax + 508], esi + sub eax, 512 + loop @b + + stdcall str_cpy, exp, history + stdcall str_cpy, ans.buffer, history + 480 + mov esi, [ans.size] + mov dword[history + 508], esi + + ; Check length + mov esi, 37 + sub esi, edi + stdcall str_len, exp + sub esi, eax + cmp esi, 0 + jg .redraw + + mov ebx, history + add ebx, eax + add ebx, esi + mov [ebx], dword ".." + + jmp .redraw + + ; ERRORS + .error: + cmp [error_n], 1 + je .err_1 + cmp [error_n], 4 + je .err_4 + + mov [ans.buffer + 0], dword "Expe" + mov [ans.buffer + 4], dword "cted" + mov [ans.buffer + 8], dword " ')'" + mov [ans.buffer + 12], byte 0 + mov [ans.size], 105 + + cmp [error_n], 2 + je .redraw + cmp [error_n], 3 + je .err_3 + cmp [error_n], 5 + je .err_5 + + .err_1: + mov [ans.buffer + 0], dword "Div." + mov [ans.buffer + 4], dword " by " + mov [ans.buffer + 8], byte "0" + mov [ans.buffer + 9], byte 0 + mov [ans.size], 81 + jmp .redraw + + .err_4: + mov [ans.buffer + 0], dword "Inpu" + mov [ans.buffer + 4], dword "t er" + mov [ans.buffer + 8], dword "rror" + mov [ans.buffer + 12], byte 0 + mov [ans.size], 105 + jmp .redraw + + .err_3: + mov [ans.buffer + 10], byte "(" + jmp .redraw + + .err_5: + mov [ans.buffer + 10], byte "|" + jmp .redraw + + .redraw: + + call draw_textbox + call draw_list + jmp update + +; ==================================================================== + +proc draw_textbox + + ; border + mcall SF_DRAW_RECT, , < 8, 30>, [sc.work_graph] + + ; background + mov edx, [scn.gui_face] + cmp [error_n], 0 + je @f + mov edx, 0xFFAAAA + + @@: + mcall SF_DRAW_RECT, , < 9, 28> + mcall , , < 9, 1>, [scn.gui_tb_in_shd] + mcall , , < 10, 27> + + mov ebx, LIST_X + LIST_ITEM_W - 12 + sub ebx, [ans.size] + shl ebx, 16 + add ebx, 16 + mov ecx, [scn.gui_intext] + add ecx, 0x10000000 + or ecx, 1 shl 31 + mcall SF_DRAW_TEXT, , , ans.buffer + + mcall , , [scn.gui_intext], btn_clr, 1 + add ebx, 1 shl 16 + mcall + + mcall SF_DEFINE_BUTTON, , <9, 27>, 4 + BT_HIDE + + mov ebx, LIST_ITEM_W - 18 + sub ebx, [ans.size] + cmp ebx, 24 + jg @f + mov ebx, 24 + + @@: + mov [edb1.width], ebx + m2m [edb1.color] , [scn.gui_face] + m2m [edb1.focus_border_color], [scn.gui_face] + cmp [error_n], 0 + je @f + mov [edb1.color] , 0x00FFAAAA + mov [edb1.focus_border_color], 0x00FFAAAA + + @@: + invoke editbox.draw, edb1 + ret + +endp + +; ==================================================================== + +proc draw_button, x, y + + mcall SF_DEFINE_BUTTON, <[x], KEYB_BTN_W>, <[y], KEYB_BTN_H>, [but_id], [but_c] + + mov ebx, [x] + add ebx, KEYB_BTN_W/2-4 + + shl ebx, 16 + add ebx, [y] + add ebx, KEYB_BTN_H/2 - 6 + or [but_tc], 0x01000000 ; use bigger font + mcall SF_DRAW_TEXT, , [but_tc], [txt_id], [txt_size] + + mov eax, [txt_size] + add [txt_id], eax + inc dword [but_id] + + ret + +endp + +; ==================================================================== + +proc draw_keyb + + mcall SF_DEFINE_BUTTON, , <8, 29>, 250, [sc.work_light] + mov ecx, [sc.work_text] + or ecx, 0x10000000 + mcall SF_DRAW_TEXT, <(KEYB_BTN_W + GAP - engineering_len*2)*2 - GAP/2 + KEYBOARD_X, KEYB_BTN_H / 2 - 10 + 8>, , engineering_str, engineering_len + + mov [txt_size], 1 + mov [but_id], 0x0000000A + mov [txt_id], buttons + + m2m [but_c], [sc.work] + m2m [but_tc], [sc.work_text] + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*0, KEYBOARD_Y + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*1, KEYBOARD_Y + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*2, KEYBOARD_Y + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*3, KEYBOARD_Y + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*3, KEYBOARD_Y + (KEYB_BTN_H + GAP)*1 + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*3, KEYBOARD_Y + (KEYB_BTN_H + GAP)*2 + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*3, KEYBOARD_Y + (KEYB_BTN_H + GAP)*3 + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*2, KEYBOARD_Y + (KEYB_BTN_H + GAP)*4 + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*1, KEYBOARD_Y + (KEYB_BTN_H + GAP)*4 + + mov [but_c] , 0x00F0969D + mov [but_tc], 0x00FFFFFF + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*3, KEYBOARD_Y +(KEYB_BTN_H + GAP)*4 + + m2m [but_c] , [sc.work_button] + m2m [but_tc], [sc.work_button_text] + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*0, KEYBOARD_Y + KEYB_BTN_H + GAP + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*1, KEYBOARD_Y + KEYB_BTN_H + GAP + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*2, KEYBOARD_Y + KEYB_BTN_H + GAP + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*0, KEYBOARD_Y + (KEYB_BTN_H + GAP)*2 + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*1, KEYBOARD_Y + (KEYB_BTN_H + GAP)*2 + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*2, KEYBOARD_Y + (KEYB_BTN_H + GAP)*2 + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*0, KEYBOARD_Y + (KEYB_BTN_H + GAP)*3 + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*1, KEYBOARD_Y + (KEYB_BTN_H + GAP)*3 + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*2, KEYBOARD_Y + (KEYB_BTN_H + GAP)*3 + stdcall draw_button, KEYBOARD_X + (KEYB_BTN_W + GAP)*0, KEYBOARD_Y + (KEYB_BTN_H + GAP)*4 + + ret + +endp + +; ==================================================================== + +proc draw_list + + ; BACKGROUND + mov eax, SF_DRAW_RECT + mov ebx, LIST_X shl 16 + LIST_ITEM_W + mov ecx, LIST_Y shl 16 + LIST_ITEM_H + mov edx, [sc.work_light] + mov edi, LIST_ITEM_COUNT + + @@: + mcall + ; draw separator { + push ecx edx + sub ecx, LIST_ITEM_H - 1 + mov edx, [sc.work_dark] + mcall + ; } + pop edx ecx + add ecx, LIST_ITEM_H shl 16 + + .next: + dec edi + cmp edi, 0 + jne @b + + mcall , , , [sc.work_dark] + mcall , , + mcall , , + + ; BUTTONS + mov eax, SF_DEFINE_BUTTON + mov ebx, LIST_X shl 16 + LIST_ITEM_W + mov ecx, 43 shl 16 + LIST_ITEM_H + mov edx, 60 + BT_HIDE + mov edi, LIST_ITEM_COUNT + + @@: + mcall + add ecx, LIST_ITEM_H shl 16 + inc edx + dec edi + cmp edi, 0 + jne @b + + ; TEXT + mov eax, SF_DRAW_TEXT + mov ebx, (LIST_X + LIST_X) shl 16 + LIST_Y + LIST_TEXT_Y + 1 + mov ecx, [sc.work_text] + mov edi, LIST_ITEM_COUNT + + @@: + or ecx, 1 shl 31 + mov edx, history + + @@: + add ecx, 0x10000000 + mcall + + push ebx + add ebx, (LIST_ITEM_W - 8) shl 16 + mov esi, [edx + 508] + shl esi, 16 + sub ebx, esi + add edx, 480 + mcall + pop ebx + + add edx, 32 + add ebx, LIST_ITEM_H + + and ecx, 0xFFFFFF + cmp ecx, LIST_ITEM_TEXT2 + je .set_color_to_2_txt + mov ecx, LIST_ITEM_TEXT2 + jmp .next_txt + + .set_color_to_2_txt: + mov ecx, LIST_ITEM_TEXT1 + + .next_txt: + or ecx, 1 shl 31 + + dec edi + cmp edi, 0 + jne @b + + ret + +endp + +; ==================================================================== + +proc str_len uses ebx, str + + xor eax, eax + mov ebx, [str] + + @@: + cmp [ebx], byte 0 + je @f + inc eax + inc ebx + jmp @b + + @@: + ret + +endp + +; ==================================================================== + +proc str_cpy uses eax ebx ecx, from, to + + mov eax, [from] + mov ebx, [to] + + @@: + cmp [eax], byte 0 + je @f + mov cl, [eax] + mov [ebx], cl + inc eax + inc ebx + jmp @b + + @@: + mov [ebx], byte 0 + ret + +endp + +; ==================================================================== + +if lang eq ru_RU + + engineering_str cp866 "╨Ш╨╜╨╢╨╡╨╜╨╡╤А╨╜╤Л╨╣ ╤А╨╡╨╢╨╕╨╝" + engineering_len = $ - engineering_str + +else if lang eq es_ES + + engineering_str db " Modo ingeniero " + engineering_len = $ - engineering_str +else + + engineering_str db "Engineering calc" + engineering_len = $ - engineering_str + +endf + +; ==================================================================== + +f70_calc: + dd SSF_START_APP + dd 0 + dd 0 + dd 0 + dd 0 + db '/sys/calc', 0 + +; system colors internal +scn: + .gui_tb_in_shd dd 0x00CED0D0 + .gui_face dd 0x00FAF8FA + .gui_text dd 0x10373C42 + .gui_intext dd 0x005F5F5F + .gui_select dd 0x00C7C9C9 + +; ==================================================================== + +I_END: + +rb 2048 + +STACKTOP: + +exp rb 480 +exp_pos rd 1 +exp_lvl rd 1 +abs_lvl rd 1 +group rd 1 + +ans.buffer: rb 480 +ans.size rd 1 +error_n rd 1 + +timer rd 1 +but_id rd 1 +but_c rd 1 +but_tc rd 1 +txt_id rd 1 +txt_size rd 1 + +history rb 512 * LIST_ITEM_COUNT + rb 512 + +sc system_colors + +MEM: