Compare commits
30
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bfb69dd67a | ||
|
|
d6010bc759 | ||
|
|
f022313a49 | ||
|
|
e87eaace4c | ||
|
|
bcd09d2952 | ||
|
|
fc9a2a0fc7 | ||
|
|
e3d744f1b5 | ||
|
|
8ca3758efb | ||
|
|
02916ed0ee | ||
|
|
873d4de379 | ||
|
|
b2f9cc9809 | ||
|
|
298155191d | ||
|
|
49b8cdcd54 | ||
|
|
c121db7a88 | ||
|
|
9527a0f3d1 | ||
|
|
1e05d19c4c | ||
|
|
ecdebae231 | ||
|
|
0150178c90 | ||
|
|
3caf2a7a72 | ||
|
|
019f2629dc | ||
|
|
63ee53f4a3 | ||
|
|
7c8eba2ed4 | ||
|
|
15396a0304 | ||
|
|
0969869ba8 | ||
|
|
dd3af88a30 | ||
|
|
85ae0c8703 | ||
|
|
2ad11d3acc | ||
|
|
450054a86c | ||
|
|
b0055ba472 | ||
|
|
f711f9286b |
No files matched your search
@@ -128,7 +128,8 @@ jobs:
|
||||
fi
|
||||
|
||||
# cache restore resets ctimes; realign tup DB to skip a full rebuild,
|
||||
# but keep files changed since the cache's commit dirty so tup rebuilds them
|
||||
# but keep files changed since the cache's commit dirty so tup rebuilds them.
|
||||
# A submodule bump diffs as a bare gitlink, so expand it to its whole subtree
|
||||
- name: Sync tup DB with filesystem ctime
|
||||
if: steps.check-tup-cache.outputs.cache_restored == 'true'
|
||||
run: |
|
||||
@@ -136,6 +137,10 @@ jobs:
|
||||
BASE=$(cat .tup/build-commit 2>/dev/null || true)
|
||||
if [ -n "$BASE" ] && git cat-file -e "${BASE}^{commit}" 2>/dev/null; then
|
||||
git -c core.quotePath=false diff --name-only "$BASE" HEAD > "$DIRTY"
|
||||
git diff --raw "$BASE" HEAD | awk '$2 == "160000" { print $NF }' |
|
||||
while read -r sub; do
|
||||
git -C "$sub" -c core.quotePath=false ls-files | sed "s|^|$sub/|"
|
||||
done >> "$DIRTY"
|
||||
echo "Cache built at $BASE; $(wc -l < "$DIRTY") changed files kept dirty"
|
||||
python3 .gitea/utils/sync-tup-ctime.py .tup/db "$DIRTY"
|
||||
else
|
||||
|
||||
+21
-19
@@ -41,10 +41,6 @@ img_files = {
|
||||
{"LIB/KMENU.OBJ", "common/lib/kmenu.obj"},
|
||||
{"LIB/PIXLIB.OBJ", "common/lib/pixlib.obj"},
|
||||
{"MEDIA/AC97SND", "common/media/ac97snd"},
|
||||
{"MEDIA/IMGF/IMGF", "common/media/ImgF/ImgF"},
|
||||
{"MEDIA/IMGF/CEDG.OBJ", "common/media/ImgF/cEdg.obj"},
|
||||
{"MEDIA/IMGF/DITHER.OBJ", "common/media/ImgF/dither.obj"},
|
||||
{"MEDIA/IMGF/INVSOL.OBJ", "common/media/ImgF/invSol.obj"},
|
||||
{"NETWORK/FTPC.INI", SRC_PROGS .. "/network/ftpc/ftpc.ini"},
|
||||
{"NETWORK/FTPD.INI", "common/network/ftpd.ini"},
|
||||
{"NETWORK/KNMAP", "common/network/knmap"},
|
||||
@@ -58,8 +54,7 @@ img_files = {
|
||||
{"SETTINGS/FB2READ.INI", "common/settings/fb2read.ini"},
|
||||
{"SETTINGS/HA.CFG", SRC_PROGS .. "/other/ha/SETTINGS/HA.CFG"},
|
||||
{"SETTINGS/ICON.INI", build_type .. "/settings/icon.ini"},
|
||||
{"SETTINGS/KEYMAP.KEY", SRC_PROGS .. "/system/taskbar/KEYMAP.KEY"},
|
||||
{"SETTINGS/KOLIBRI.LBL", build_type .. "/settings/kolibri.lbl"},
|
||||
{"SETTINGS/KEYMAP.KEY", VAR_PROGS .. "/system/taskbar/keymap.key.kpack"},
|
||||
{"SETTINGS/LANG.INI", build_type .. "/settings/lang.ini"},
|
||||
{"SETTINGS/MENU.DAT", build_type .. "/settings/menu.dat"},
|
||||
{"SETTINGS/NETWORK.INI", "common/settings/network.ini"},
|
||||
@@ -273,6 +268,10 @@ extra_files = {
|
||||
{"kolibrios/lib/i915_dri.drv", "common/lib/i915_dri.drv"},
|
||||
{"kolibrios/media/fplay", "common/media/fplay"},
|
||||
{"kolibrios/media/fplay_run", "common/media/fplay_run"},
|
||||
{"kolibrios/media/ImgF/ImgF", "common/media/ImgF/ImgF"},
|
||||
{"kolibrios/media/ImgF/cEdg.obj", "common/media/ImgF/cEdg.obj"},
|
||||
{"kolibrios/media/ImgF/dither.obj", "common/media/ImgF/dither.obj"},
|
||||
{"kolibrios/media/ImgF/invSol.obj", "common/media/ImgF/invSol.obj"},
|
||||
{"kolibrios/media/minimp3", "common/media/minimp3"},
|
||||
{"kolibrios/media/updf", SRC .. "/contrib/media/updf/build/uPDF"},
|
||||
{"kolibrios/media/vttf", "common/media/vttf"},
|
||||
@@ -428,7 +427,6 @@ tup.append_table(img_files, {
|
||||
{"DEFAULT.SKN", VAR_SKINS .. "/../skins/Leency/Shkvorka/Shkvorka.skn"},
|
||||
{"DISPTEST", VAR_PROGS .. "/testing/disptest/disptest"},
|
||||
{"END", VAR_PROGS .. "/system/end/light/end"},
|
||||
{"ESKIN", VAR_PROGS .. "/system/eskin/eskin"},
|
||||
{"GMON", VAR_PROGS .. "/system/gmon/gmon"},
|
||||
{"HDD_INFO", VAR_PROGS .. "/system/hdd_info/hdd_info"},
|
||||
{"KBD", VAR_PROGS .. "/testing/kbd/kbd"},
|
||||
@@ -487,11 +485,6 @@ tup.append_table(img_files, {
|
||||
{"DEVELOP/MTDBG", VAR_PROGS .. "/develop/mtdbg/mtdbg"},
|
||||
{"DEVELOP/MSTATE", VAR_PROGS .. "/develop/mstate/mstate"},
|
||||
{"DEVELOP/SCANCODE", VAR_PROGS .. "/develop/scancode/scancode"},
|
||||
{"DEVELOP/EXAMPLES/CIRCLE", VAR_PROGS .. "/develop/examples/circle/circle"},
|
||||
{"DEVELOP/EXAMPLES/COLORREF", VAR_PROGS .. "/demos/colorref/colorref"},
|
||||
{"DEVELOP/EXAMPLES/CONGET", VAR_PROGS .. "/develop/libraries/console_coff/examples/test_gets"},
|
||||
{"DEVELOP/EXAMPLES/CSLIDE", VAR_PROGS .. "/demos/cslide/cslide"},
|
||||
{"DEVELOP/EXAMPLES/THREAD", VAR_PROGS .. "/develop/examples/thread/thread"},
|
||||
{"File Managers/KFAR", VAR_PROGS .. "/fs/kfar/kfar"},
|
||||
{"File Managers/OPENDIAL", VAR_PROGS .. "/fs/opendial/opendial"},
|
||||
{"LOD", VAR_PROGS .. "/fs/lod/lod"},
|
||||
@@ -598,6 +591,7 @@ tup.append_table(img_files, {
|
||||
{"DRIVERS/VT823X.SYS", VAR_DRVS .. "/audio/vt823x.sys"},
|
||||
{"DRIVERS/SIS.SYS", VAR_DRVS .. "/audio/sis.sys"},
|
||||
{"DRIVERS/SDHCI.SYS", "../drivers/sdhci/sdhci.sys"},
|
||||
{"DRIVERS/I2CHID.SYS", VAR_DRVS .. "/i2chid/i2chid.sys"},
|
||||
})
|
||||
tup.append_table(extra_files, {
|
||||
{"HD_Load/9x2klbr/", VAR_PROGS .. "/hd_load/9x2klbr/9x2klbr.exe"},
|
||||
@@ -651,20 +645,28 @@ tup.append_table(extra_files, {
|
||||
{"kolibrios/3D/blocks/block.bin", VAR_PROGS .. "/bcc32/games/blocks/block.bin"},
|
||||
{"kolibrios/develop/tcc/lib/crt0.o", VAR_PROGS .. "/develop/ktcc/bin/lib/crt0.o", group = "../programs/develop/ktcc/<crt0.o>"},
|
||||
{"kolibrios/develop/tcc/lib/tiny.o", VAR_PROGS .. "/develop/ktcc/bin/lib/tiny.o", group = "../programs/develop/ktcc/<tiny.o>"},
|
||||
{"kolibrios/develop/tcc/lib/libsound.a", VAR_PROGS .. "/develop/ktcc/bin/lib/libsound.a", group = "../programs/develop/ktcc/<libsound.a>"}
|
||||
{"kolibrios/develop/tcc/lib/libsound.a", VAR_PROGS .. "/develop/ktcc/bin/lib/libsound.a", group = "../programs/develop/ktcc/<libsound.a>"},
|
||||
{"kolibrios/develop/examples/circle", VAR_PROGS .. "/develop/examples/circle/circle"},
|
||||
{"kolibrios/develop/examples/colorref", VAR_PROGS .. "/demos/colorref/colorref"},
|
||||
{"kolibrios/develop/examples/conget", VAR_PROGS .. "/develop/libraries/console_coff/examples/test_gets"},
|
||||
{"kolibrios/develop/examples/cslide", VAR_PROGS .. "/demos/cslide/cslide"},
|
||||
{"kolibrios/develop/examples/thread", VAR_PROGS .. "/develop/examples/thread/thread"}
|
||||
})
|
||||
-- For russian build, add russian-only programs.
|
||||
if build_type == "ru_RU" then tup.append_table(img_files, {
|
||||
{"DEVELOP/EXAMPLES/TESTCON2", VAR_PROGS .. "/develop/libraries/console_coff/examples/testcon2_rus"},
|
||||
}) else tup.append_table(img_files, {
|
||||
{"DEVELOP/EXAMPLES/TESTCON2", VAR_PROGS .. "/develop/libraries/console_coff/examples/testcon2_eng"},
|
||||
}) end
|
||||
-- -- For russian build, add russian-only programs.
|
||||
-- if build_type == "ru_RU" then tup.append_table(img_files, {
|
||||
-- {"DEVELOP/EXAMPLES/TESTCON2", VAR_PROGS .. "/develop/libraries/console_coff/examples/testcon2_rus"},
|
||||
-- }) else tup.append_table(img_files, {
|
||||
-- {"DEVELOP/EXAMPLES/TESTCON2", VAR_PROGS .. "/develop/libraries/console_coff/examples/testcon2_eng"},
|
||||
-- }) end
|
||||
|
||||
if build_type == "ru_RU" then tup.append_table(extra_files, {
|
||||
{"kolibrios/develop/examples/testcon2", VAR_PROGS .. "/develop/libraries/console_coff/examples/testcon2_rus"},
|
||||
{"kolibrios/utils/period", VAR_PROGS .. "/other/period/period"},
|
||||
{"kolibrios/games/Dungeons/Dungeons", VAR_PROGS .. "/games/Dungeons/Dungeons"},
|
||||
{"kolibrios/games/klavisha/klavisha", VAR_PROGS .. "/games/klavisha/klavisha"},
|
||||
{"kolibrios/games/klavisha/basekurs.kla", "ru_RU/games/basekurs.kla"},
|
||||
}) else tup.append_table(extra_files, {
|
||||
{"kolibrios/develop/examples/testcon2", VAR_PROGS .. "/develop/libraries/console_coff/examples/testcon2_eng"},
|
||||
}) end
|
||||
|
||||
end -- tup.getconfig('NO_FASM') ~= 'full'
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
#/SYS/CROPFLAT "XS800 YS480" 1 # set limits of screen
|
||||
#/SYS/LOADDRV COMMOUSE 1 # serial mouse driver
|
||||
#/SYS/DEVELOP/BOARD "" 0 # Load DEBUG board
|
||||
#/SYS/LOADDRV RDC 0 # videodriver for RDC M2010/M2012
|
||||
/SYS/SETUP BOOT 0 # Load device settings
|
||||
/SYS/LOADDRV RDC 0 # videodriver for RDC M2010/M2012
|
||||
/SYS/LOADDRV I2CHID 0 # Start I2C touchpad driver
|
||||
/SYS/@TASKBAR "" 0 # Start taskbar
|
||||
/SYS/ESKIN "" 0 # Set style
|
||||
/SYS/@ICON "" 0 # Multithread desktop icons
|
||||
/SYS/TMPDISK A0 0 # Add virtual RAM disk /tmp0/1
|
||||
/SYS/@RESHARE "" 0 # Shared resources
|
||||
|
||||
@@ -3,7 +3,22 @@ language=en
|
||||
font file=/sys/Fonts/Tahoma.kf
|
||||
font smoothing=sbp
|
||||
font height=9
|
||||
speaker mute=off
|
||||
|
||||
[touchpad]
|
||||
speed=100
|
||||
; how far a finger must move before the pointer follows, in pad units;
|
||||
; larger is steadier under a pressing finger, 0 turns the filter off
|
||||
jitter=1
|
||||
; the same, for a finger that landed on the button strip: it is pressing
|
||||
; rather than steering there, so it needs a stricter margin
|
||||
jitter_buttons=45
|
||||
scroll_step=64
|
||||
scroll_invert=0
|
||||
tap_enable=1
|
||||
tap_drag=1
|
||||
right_click=1
|
||||
button_zone=15
|
||||
right_split=50
|
||||
|
||||
[mouse]
|
||||
speed=4
|
||||
@@ -13,6 +28,7 @@ double_click_delay=64
|
||||
[low-level]
|
||||
LBA=off
|
||||
PCI=on
|
||||
speaker=on
|
||||
|
||||
;timeout in minutes
|
||||
;program needs a full path
|
||||
|
||||
@@ -20,7 +20,6 @@ disptest;
|
||||
docpack;Документация / Блок документов;asm;http://git.kolibrios.org/KolibriOS/kolibrios/src/branch/main/programs/system/docpack;;http://wiki.kolibrios.org/wiki/Docpack/ru
|
||||
easyshot;Простой скриншотер;c--;http://git.kolibrios.org/KolibriOS/kolibrios/src/branch/main/programs/cmm/misc/easyshot.c;http://board.kolibrios.org/viewtopic.php?t=3695;
|
||||
end;Программа завершения работы;asm;http://git.kolibrios.org/KolibriOS/kolibrios/src/branch/main/programs/system/end;http://board.kolibrios.org/viewtopic.php?t=2442;http://wiki.kolibrios.org/wiki/End/ru
|
||||
eskin;Установщик фона и скина при старте системы;asm;http://git.kolibrios.org/KolibriOS/kolibrios/src/branch/main/programs/system/eskin;http://board.kolibrios.org/viewtopic.php?t=2424;
|
||||
fb2read;Читалка FB2;oberon07;http://git.kolibrios.org/KolibriOS/kolibrios/src/branch/main/programs/other/fb2reader;http://board.kolibrios.org/viewtopic.php?t=3128;
|
||||
fspeed;Тестирование скорости диска;asm;http://git.kolibrios.org/KolibriOS/kolibrios/src/branch/main/programs/testing/fspeed;http://board.kolibrios.org/viewtopic.php?t=2660;
|
||||
gmon;Информация о загрузке системы;asm;http://git.kolibrios.org/KolibriOS/kolibrios/src/branch/main/programs/system/gmon;http://board.kolibrios.org/viewtopic.php?t=470;http://wiki.kolibrios.org/wiki/Gmon/ru
|
||||
|
||||
|
@@ -40,7 +40,7 @@
|
||||
06 zSea Image Viewer * |/kolibrios/media/zsea/zsea
|
||||
38 Animage |media/animage
|
||||
38 IconEdit |media/iconedit
|
||||
40 Image Filtering |media/imgf/imgf
|
||||
40 Image Filtering * |/kolibrios/media/ImgF/ImgF
|
||||
52 Palitra |media/palitra
|
||||
39 Pipet |develop/pipet
|
||||
#4 **** MULTIMEDIA
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
16 Image viewer KIV |media/kiv
|
||||
16 Image viewer zSea * |/kolibrios/media/zsea/zsea
|
||||
16 Animage |media/animage
|
||||
16 Efectos de imаgenes |media/imgf/imgf
|
||||
16 Efectos de imаgenes * |/kolibrios/media/ImgF/ImgF
|
||||
16 Palitra |media/palitra
|
||||
#4 **** MULTIMEDIA
|
||||
16 Pixie Audioplayer |media/pixie
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
06 Image viewer zSea * |/kolibrios/media/zsea/zsea
|
||||
38 Animage |media/animage
|
||||
38 IconEdit |media/iconedit
|
||||
16 Image Filtering |media/imgf/imgf
|
||||
16 Image Filtering * |/kolibrios/media/ImgF/ImgF
|
||||
52 Palitra |media/palitra
|
||||
39 Pipet |develop/pipet
|
||||
#4 **** MULTIMEDIA ****
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
06 Image viewer zSea * |/kolibrios/media/zsea/zsea
|
||||
38 Animage |media/animage
|
||||
38 IconEdit |media/iconedit
|
||||
40 Image Filtering |media/imgf/imgf
|
||||
40 Image Filtering * |/kolibrios/media/ImgF/ImgF
|
||||
52 Palitra |media/palitra
|
||||
39 Pipet |develop/pipet
|
||||
#4 **** MULTIMEDIA
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
06 Просмотр фото zSea |/kolibrios/media/zsea/zsea
|
||||
38 Редактор Animage |media/animage
|
||||
38 Редактор иконок |media/iconedit
|
||||
40 Наложение фильтров |media/imgf/imgf
|
||||
40 Наложение фильтров * |/kolibrios/media/ImgF/ImgF
|
||||
52 Палитра |media/palitra
|
||||
39 Пипетка |develop/pipet
|
||||
#4 **** Звук и видео
|
||||
|
||||
@@ -273,8 +273,8 @@ RIRB_INT_RESPONSE equ 0x01
|
||||
RIRB_INT_OVERRUN equ 0x04
|
||||
RIRB_INT_MASK equ 0x05
|
||||
|
||||
; STATESTS int mask: SD2,SD1,SD0
|
||||
STATESTS_INT_MASK equ 0x07
|
||||
; STATESTS int mask: SDIWAKE[14:0], a 16-bit register
|
||||
STATESTS_INT_MASK equ 0x7FFF
|
||||
AZX_MAX_CODECS equ 4
|
||||
|
||||
; SD_CTL bits
|
||||
@@ -402,6 +402,7 @@ struc AC_CNTRL ;AC controller base class
|
||||
.response_reset dd 0
|
||||
.polling_mode db 0
|
||||
.poll_count db 0
|
||||
.no_irq db 0 ; no interrupt line: a thread runs hda_irq
|
||||
.posbuf dd ?
|
||||
.start_wallclk dd ? ; start + minimum wallclk
|
||||
.period_wallclk dd ? ; wallclk for period
|
||||
@@ -505,8 +506,6 @@ macro spin_unlock
|
||||
pop ebx eax
|
||||
}
|
||||
|
||||
data fixups
|
||||
end data
|
||||
|
||||
include '../../struct.inc'
|
||||
include '../../macros.inc'
|
||||
@@ -607,9 +606,6 @@ if IRQ_REMAP
|
||||
invoke SysMsgBoardStr
|
||||
end if
|
||||
|
||||
mov ebx, [ctrl.int_line]
|
||||
invoke AttachIntHandler, ebx, hda_irq, dword 0
|
||||
|
||||
;Asper This part is from "azx_probe" proc. [
|
||||
call azx_codec_create
|
||||
cmp eax, 0
|
||||
@@ -858,13 +854,13 @@ end if
|
||||
|
||||
mov edx, ICH6_REG_SD_STS + SDO_OFS
|
||||
call azx_readb
|
||||
mov bl, al
|
||||
mov cl, al
|
||||
|
||||
mov al, SD_INT_MASK
|
||||
mov edx, ICH6_REG_SD_STS + SDO_OFS
|
||||
call azx_writeb
|
||||
|
||||
test bl, SD_INT_COMPLETE
|
||||
test cl, SD_INT_COMPLETE
|
||||
jz @f
|
||||
|
||||
mov eax, [ctrl.civ_val]
|
||||
@@ -901,13 +897,13 @@ end if
|
||||
;if 0
|
||||
; clear state status int
|
||||
mov edx, ICH6_REG_STATESTS
|
||||
call azx_readb
|
||||
test al, 0x04
|
||||
call azx_readw
|
||||
and eax, STATESTS_INT_MASK
|
||||
jz @f
|
||||
|
||||
mov al, 0x04
|
||||
; ack all state-change bits, else the level IRQ line stays asserted
|
||||
mov edx, ICH6_REG_STATESTS
|
||||
call azx_writeb
|
||||
call azx_writew
|
||||
@@:
|
||||
;end if
|
||||
or eax, 1
|
||||
@@ -915,6 +911,24 @@ end if
|
||||
ret
|
||||
endp
|
||||
|
||||
; Stand-in for the interrupt when no interrupt line is available. A thread,
|
||||
; not a TimerHS callback: the kernel calls timer callbacks with the global
|
||||
; timer list lock held, and hda_irq may stall and refill the audio buffer.
|
||||
; hda_irq runs with interrupts off, as it would in IRQ context: it holds
|
||||
; aspinlock, which azx_rirb_get_response waits for with interrupts off, so
|
||||
; a holder that could be preempted would hang the machine.
|
||||
proc hda_poll_thread
|
||||
.loop:
|
||||
pushfd
|
||||
cli
|
||||
call hda_irq
|
||||
popfd
|
||||
mov eax, 5 ; delay, sleeping instead of spinning
|
||||
mov ebx, 1 ; 10 ms; a 16 KB period is ~85 ms at 48 kHz
|
||||
int 0x40
|
||||
jmp .loop
|
||||
endp
|
||||
|
||||
|
||||
align 4
|
||||
proc create_primary_buff
|
||||
@@ -1203,6 +1217,26 @@ end if
|
||||
; allocate CORB/RIRB
|
||||
call azx_alloc_cmd_io
|
||||
|
||||
; attach the IRQ handler BEFORE the controller may raise interrupts:
|
||||
; azx_init_chip enables GIE/CIE and a codec state-change can fire
|
||||
; right away; an unclaimed level IRQ makes the
|
||||
; kernel poll foreign handlers and relink their IRQH nodes onto our
|
||||
; line (see irq_serv .try_other_irqs), corrupting the dispatch list
|
||||
; a warm reboot can leave GIE and a stale completion bit behind, and
|
||||
; civ_val is never resynced, so silence the controller before attaching
|
||||
call azx_int_disable
|
||||
mov ebx, [ctrl.int_line]
|
||||
invoke AttachIntHandler, ebx, hda_irq, dword 0
|
||||
test eax, eax
|
||||
jnz @f
|
||||
; No usable interrupt line (INTLINE=0xFF on boards that route INTx only
|
||||
; through ACPI _PRT or MSI, which the kernel does not parse). The
|
||||
; controller still latches INTSTS/SD_STS, we only lose the wakeup - so
|
||||
; poll the RIRB for codec replies and run the interrupt handler from a
|
||||
; thread. A flag of its own: polling_mode is the timeout recovery state.
|
||||
mov [ctrl.no_irq], 1
|
||||
@@:
|
||||
|
||||
; initialize chip
|
||||
call azx_init_pci
|
||||
|
||||
@@ -1210,6 +1244,32 @@ end if
|
||||
call azx_init_chip
|
||||
;] Asper
|
||||
|
||||
; no IRQ line: let a polling thread stand in for the interrupt.
|
||||
; Started only now - earlier, hda_irq could ack STATESTS in the window
|
||||
; before reset_controller reads it into codec_mask
|
||||
cmp [ctrl.no_irq], 0
|
||||
je @f
|
||||
push esi edi ; CreateThread clobbers them, START needs esi
|
||||
mov ebx, 1
|
||||
mov ecx, hda_poll_thread
|
||||
xor edx, edx
|
||||
invoke CreateThread
|
||||
pop edi esi
|
||||
test eax, eax
|
||||
jns .thread_ok
|
||||
; nothing would ever complete a period and playback would stall,
|
||||
; so fail the init rather than register a service that hangs
|
||||
mov esi, msgNoIrqThread
|
||||
invoke SysMsgBoardStr
|
||||
xor eax, eax
|
||||
ret
|
||||
.thread_ok:
|
||||
if DEBUG
|
||||
mov esi, msgNoIrqPoll
|
||||
invoke SysMsgBoardStr
|
||||
end if
|
||||
@@:
|
||||
|
||||
xor eax, eax
|
||||
inc eax
|
||||
ret
|
||||
@@ -1243,7 +1303,7 @@ endl
|
||||
; clear STATESTS
|
||||
mov eax, STATESTS_INT_MASK
|
||||
mov edx, ICH6_REG_STATESTS
|
||||
call azx_writeb
|
||||
call azx_writew
|
||||
|
||||
; reset controller
|
||||
mov edx, ICH6_REG_GCTL
|
||||
@@ -1454,6 +1514,12 @@ endp
|
||||
|
||||
proc azx_alloc_cmd_io
|
||||
push eax ecx edx
|
||||
; the unsolicited-event ring lives in reserved storage, so its
|
||||
; pointers hold garbage until we clear them here - do it before
|
||||
; reset_controller enables unsolicited responses in GCTL
|
||||
mov [unsol_events.rp], 0
|
||||
mov [unsol_events.wp], 0
|
||||
|
||||
; single page (at least 4096 bytes) must suffice for both ringbuffers
|
||||
invoke KernelAlloc, 4096
|
||||
mov [ctrl.rb], eax
|
||||
@@ -1654,14 +1720,24 @@ endl
|
||||
mov ecx, 1000;+1000
|
||||
.next_try:
|
||||
mov al, [ctrl.polling_mode]
|
||||
test al, al
|
||||
or al, [ctrl.no_irq]
|
||||
jnz .poll
|
||||
mov ah, [do_poll]
|
||||
test ah, ah
|
||||
jz @f
|
||||
.poll:
|
||||
spin_lock_irq
|
||||
; take the lock hda_irq holds so two RIRB readers never overlap
|
||||
push eax ebx
|
||||
mov eax, aspinlock
|
||||
.poll_lock:
|
||||
mov ebx, SPINLOCK_BUSY
|
||||
lock xchg [eax], ebx
|
||||
cmp ebx, SPINLOCK_FREE
|
||||
jnz .poll_lock
|
||||
pop ebx eax
|
||||
call azx_update_rirb
|
||||
mov [aspinlock], SPINLOCK_FREE
|
||||
spin_unlock_irq
|
||||
@@:
|
||||
mov eax, [ctrl.rirb_cmd]
|
||||
@@ -1942,6 +2018,7 @@ proc azx_int_disable
|
||||
mov ebx, ICH6_INT_CTRL_EN or ICH6_INT_GLOBAL_EN
|
||||
xor ebx, -1
|
||||
and eax, ebx
|
||||
mov edx, ICH6_REG_INTCTL ; azx_readl turned edx into the absolute address
|
||||
call azx_writel
|
||||
pop edx ebx eax
|
||||
ret
|
||||
@@ -1957,9 +2034,9 @@ proc azx_int_clear
|
||||
call azx_writeb
|
||||
|
||||
; clear STATESTS
|
||||
mov al, STATESTS_INT_MASK
|
||||
mov ax, STATESTS_INT_MASK
|
||||
mov edx, ICH6_REG_STATESTS
|
||||
call azx_writeb
|
||||
call azx_writew
|
||||
|
||||
; clear rirb status
|
||||
mov al, RIRB_INT_MASK
|
||||
@@ -2696,6 +2773,7 @@ proc snd_hda_queue_unsol_event stdcall, res:dword, res_ex:dword
|
||||
; only carries EBX across iterations and reloads the rest, and TimerHS
|
||||
; preserves EBX too - so by using scratch regs only we need no saves.
|
||||
mov eax, [unsol_events.wp]
|
||||
and eax, HDA_UNSOL_QUEUE_SIZE - 1 ; never index the ring wild
|
||||
lea edx, [eax+1]
|
||||
and edx, HDA_UNSOL_QUEUE_SIZE - 1 ; next write pos (size must be 2^n)
|
||||
cmp edx, [unsol_events.rp]
|
||||
@@ -2998,6 +3076,7 @@ sz_sound_srv db 'SOUND',0
|
||||
|
||||
msgInit db 'detect hardware...',13,10,0
|
||||
msgFail db 'device not found',13,10,0
|
||||
msgNoIrqThread db 'no IRQ line: cannot create polling thread',13,10,0
|
||||
msgAttchIRQ db 'IRQ line not supported', 13,10,0
|
||||
msgInvIRQ db 'IRQ line not assigned or invalid', 13,10,0
|
||||
msgPlay db 'start play', 13,10,0
|
||||
@@ -3067,6 +3146,7 @@ if DEBUG
|
||||
msgTCSEL db 'PCI TCSEL ',0
|
||||
msgTV db 'HDA test version ',TEST_VERSION_NUMBER,13,10,0
|
||||
msgGCap db 'GCAP = ',0
|
||||
msgNoIrqPoll db 'no IRQ line: polling thread',13,10,0
|
||||
end if
|
||||
|
||||
if USE_SINGLE_MODE
|
||||
@@ -3101,6 +3181,11 @@ end if
|
||||
|
||||
;] Asper
|
||||
|
||||
; relocation table lives after all code and initialized data: placed before the
|
||||
; code its size feeds back into every relocation site and fasm may never converge
|
||||
data fixups
|
||||
end data
|
||||
|
||||
aspinlock dd SPINLOCK_FREE
|
||||
|
||||
codec CODEC
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
ROOT = "../.."
|
||||
tup.rule("i2chid.asm", "fasm %f %o " .. tup.getconfig("PESTRIP_CMD") .. tup.getconfig("KPACK_CMD"), "%B.sys")
|
||||
@@ -0,0 +1,438 @@
|
||||
; Synopsys DesignWare I2C master, polled (PIO) mode only.
|
||||
; This is the controller inside Intel LPSS blocks (Skylake and newer, plus
|
||||
; Atom-derived SoCs); the same IP is used by many other vendors.
|
||||
;
|
||||
; The register file is always accessed as dwords. The controller must be
|
||||
; disabled to change IC_TAR, so every transfer disables it, programs the
|
||||
; target address, enables it back and feeds the TX FIFO by hand.
|
||||
|
||||
; ------------------------------ Registers ------------------------------------
|
||||
DwIcCon = 0x00
|
||||
DwIcTar = 0x04
|
||||
DwIcDataCmd = 0x10
|
||||
DwIcSsSclHcnt = 0x14
|
||||
DwIcSsSclLcnt = 0x18
|
||||
DwIcFsSclHcnt = 0x1C
|
||||
DwIcFsSclLcnt = 0x20
|
||||
DwIcIntrStat = 0x2C
|
||||
DwIcIntrMask = 0x30
|
||||
DwIcRawIntrStat = 0x34
|
||||
DwIcRxTl = 0x38
|
||||
DwIcTxTl = 0x3C
|
||||
DwIcClrIntr = 0x40
|
||||
DwIcClrTxAbrt = 0x54
|
||||
DwIcEnable = 0x6C
|
||||
DwIcStatus = 0x70
|
||||
DwIcTxflr = 0x74
|
||||
DwIcRxflr = 0x78
|
||||
DwIcSdaHold = 0x7C
|
||||
DwIcTxAbrtSource = 0x80
|
||||
DwIcEnableStatus = 0x9C
|
||||
DwIcCompParam1 = 0xF4
|
||||
DwIcCompVersion = 0xF8
|
||||
DwIcCompType = 0xFC
|
||||
|
||||
; "DW_apb_i2c" component signature ('DW' + 0x0140).
|
||||
DW_COMP_TYPE_VALUE = 0x44570140
|
||||
|
||||
; IC_CON: master, standard speed (100 kHz), restarts allowed, slave disabled.
|
||||
DW_CON_MASTER = 1 shl 0
|
||||
DW_CON_SPEED_STD = 1 shl 1
|
||||
DW_CON_SPEED_FAST = 2 shl 1
|
||||
DW_CON_RESTART_EN = 1 shl 5
|
||||
DW_CON_SLAVE_DIS = 1 shl 6
|
||||
|
||||
; IC_DATA_CMD bits above the data byte.
|
||||
DW_CMD_READ = 1 shl 8
|
||||
DW_CMD_STOP = 1 shl 9
|
||||
DW_CMD_RESTART = 1 shl 10
|
||||
|
||||
; IC_STATUS bits
|
||||
DW_STAT_TFNF = 1 shl 1 ; TX FIFO not full
|
||||
DW_STAT_TFE = 1 shl 2 ; TX FIFO empty
|
||||
DW_STAT_RFNE = 1 shl 3 ; RX FIFO not empty
|
||||
DW_STAT_MST_ACT = 1 shl 5 ; master FSM busy
|
||||
|
||||
; IC_RAW_INTR_STAT bits
|
||||
DW_INT_TX_ABRT = 1 shl 6
|
||||
|
||||
; SCL timing for standard mode. The LPSS input clock is 100 MHz on the PCH
|
||||
; parts and 133 MHz on the Atom-derived SoCs (Apollo Lake, Gemini Lake), and
|
||||
; nothing in PCI config space says which one this is, so the counts are
|
||||
; picked to satisfy the fast-mode minimums at the fastest of them: at
|
||||
; 133 MHz that is tHIGH = 0.98 us and tLOW = 1.5 us, 400 kHz. On a 100 MHz
|
||||
; part the same counts run the bus at 300 kHz, which is just as legal.
|
||||
; Fast mode rather than standard: HID over I2C requires every device to
|
||||
; support it, that is what Windows drives them at, and a polled host pays
|
||||
; for every byte with busy-waiting - at 100 kHz a 64-byte input read costs
|
||||
; 6 ms, more than a fast pad takes to produce the next report, and the
|
||||
; backlog that builds up plays back as the cursor coasting after the finger
|
||||
; has stopped. SDA hold stays well below tLOW.
|
||||
DW_FS_HCNT = 130
|
||||
DW_FS_LCNT = 200
|
||||
DW_SDA_HOLD = 28
|
||||
; The AMD FCH feeds its DesignWare masters from a 150 MHz reference, so
|
||||
; the same minimums need more counts there: 145/225 give tHIGH = 0.97 us,
|
||||
; tLOW = 1.5 us, again 400 kHz; SDA hold 45 = 300 ns.
|
||||
DW_AMD_FS_HCNT = 145
|
||||
DW_AMD_FS_LCNT = 225
|
||||
DW_AMD_SDA_HOLD = 45
|
||||
|
||||
; A transfer gives up after [XferTimeout] hundredths of a second. The init
|
||||
; value must cover a full report descriptor read: descriptors run up to 2 KB
|
||||
; and the bus may be as slow as 77 kHz, so at 9 SCL cycles per byte a single
|
||||
; transfer takes ~240 ms of wall-clock time. Polling is generous too now that it runs in its own thread
|
||||
; rather than in a timer callback - a wedged bus costs this thread its slice
|
||||
; and nothing else.
|
||||
DW_TIMEOUT_INIT = 60
|
||||
DW_TIMEOUT_POLL = 20
|
||||
|
||||
; Disables the controller and waits until it reports itself disabled.
|
||||
; in: ebx = MMIO base. Clobbers eax, ecx.
|
||||
proc dw_ctrl_disable
|
||||
mov dword [ebx+DwIcEnable], 0
|
||||
mov ecx, 100000
|
||||
@@:
|
||||
test dword [ebx+DwIcEnableStatus], 1
|
||||
jz .done
|
||||
pause
|
||||
loop @b
|
||||
.done:
|
||||
ret
|
||||
endp
|
||||
|
||||
; Aborts a stuck transfer cleanly: the ABORT bit makes the master issue STOP,
|
||||
; flush the TX FIFO and raise TX_ABRT, which releases a slave that is holding
|
||||
; the bus (a clock-stretching touchpad, for instance). Simply disabling the
|
||||
; controller in the middle of a byte would leave SDA held low and every
|
||||
; following transfer would time out too. Older cores without the ABORT bit
|
||||
; just ignore the write and fall through after the wait.
|
||||
; in: ebx = MMIO base. Clobbers eax, ecx.
|
||||
proc dw_ctrl_abort
|
||||
mov dword [ebx+DwIcEnable], 3
|
||||
mov ecx, 100000
|
||||
@@:
|
||||
test dword [ebx+DwIcRawIntrStat], DW_INT_TX_ABRT
|
||||
jnz @f
|
||||
pause
|
||||
loop @b
|
||||
@@:
|
||||
mov eax, [ebx+DwIcClrTxAbrt]
|
||||
call dw_ctrl_disable
|
||||
ret
|
||||
endp
|
||||
|
||||
; One idle step of a transfer wait loop.
|
||||
; A healthy transfer is over within a few milliseconds, well inside the
|
||||
; first two timer ticks, and spins through them: a transfer that yields
|
||||
; its slice is at the scheduler's mercy for the rest of it. Past that the
|
||||
; bus is stuck or crawling, and the wait gives up the CPU a tick at a time
|
||||
; instead of burning a core until XferTimeout.
|
||||
; in: eax = ticks elapsed since the transfer began. Preserves all but eax.
|
||||
DW_SPIN_TICKS = 2
|
||||
|
||||
proc dw_wait_step
|
||||
cmp eax, DW_SPIN_TICKS
|
||||
jae .yield
|
||||
pause
|
||||
ret
|
||||
.yield:
|
||||
push ebx
|
||||
movi ebx, 1
|
||||
invoke Delay ; preserves every register
|
||||
pop ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
; One-time controller setup after mapping.
|
||||
; in: ebx = MMIO base.
|
||||
proc dw_ctrl_init
|
||||
push eax ecx
|
||||
call dw_ctrl_disable
|
||||
mov dword [ebx+DwIcCon], DW_CON_MASTER + DW_CON_SPEED_FAST + \
|
||||
DW_CON_RESTART_EN + DW_CON_SLAVE_DIS
|
||||
; The counts come from variables: they depend on the reference clock, which
|
||||
; is decided by whoever found the controller (PCI LPSS or AMD FCH). The
|
||||
; standard-mode registers get the same values scaled up so that they are
|
||||
; sane should anything ever switch the speed bits back.
|
||||
mov eax, [DwHcnt]
|
||||
mov [ebx+DwIcFsSclHcnt], eax
|
||||
lea eax, [eax*4]
|
||||
mov [ebx+DwIcSsSclHcnt], eax
|
||||
mov eax, [DwLcnt]
|
||||
mov [ebx+DwIcFsSclLcnt], eax
|
||||
lea eax, [eax*4]
|
||||
mov [ebx+DwIcSsSclLcnt], eax
|
||||
mov eax, [DwSdaHold]
|
||||
mov [ebx+DwIcSdaHold], eax
|
||||
mov dword [ebx+DwIcIntrMask], 0
|
||||
mov dword [ebx+DwIcRxTl], 0
|
||||
mov dword [ebx+DwIcTxTl], 0
|
||||
mov eax, [ebx+DwIcClrIntr]
|
||||
pop ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; One combined I2C transaction: optional write phase, then optional read phase
|
||||
; with a repeated START between them. Fully polled.
|
||||
; out: eax = 0 on success, IC_TX_ABRT_SOURCE value on NAK/abort, -1 on timeout.
|
||||
proc dw_xfer stdcall uses ebx esi edi, addr:dword, wbuf:dword, wlen:dword, \
|
||||
rbuf:dword, rlen:dword
|
||||
locals
|
||||
wsent dd ?
|
||||
rqueued dd ?
|
||||
rgot dd ?
|
||||
t0 dd ?
|
||||
endl
|
||||
mov ebx, [I2cMmio]
|
||||
call dw_ctrl_disable
|
||||
mov eax, [addr]
|
||||
mov [ebx+DwIcTar], eax
|
||||
mov eax, [ebx+DwIcClrIntr]
|
||||
mov dword [ebx+DwIcEnable], 1
|
||||
xor eax, eax
|
||||
mov [wsent], eax
|
||||
mov [rqueued], eax
|
||||
mov [rgot], eax
|
||||
invoke GetTimerTicks
|
||||
mov [t0], eax
|
||||
.loop:
|
||||
; Abort (NAK and friends) ends the transfer immediately.
|
||||
test dword [ebx+DwIcRawIntrStat], DW_INT_TX_ABRT
|
||||
jnz .abort
|
||||
; Drain the RX FIFO first so it can never overflow.
|
||||
test dword [ebx+DwIcStatus], DW_STAT_RFNE
|
||||
jz .no_rx
|
||||
mov edx, [rgot]
|
||||
cmp edx, [rlen]
|
||||
jae .no_rx
|
||||
mov eax, [ebx+DwIcDataCmd]
|
||||
mov edi, [rbuf]
|
||||
mov [edi+edx], al
|
||||
inc edx
|
||||
mov [rgot], edx
|
||||
jmp .loop
|
||||
.no_rx:
|
||||
; Feed the write phase.
|
||||
mov eax, [wsent]
|
||||
cmp eax, [wlen]
|
||||
jae .push_reads
|
||||
test dword [ebx+DwIcStatus], DW_STAT_TFNF
|
||||
jz .check_done
|
||||
mov esi, [wbuf]
|
||||
movzx edx, byte [esi+eax]
|
||||
inc eax
|
||||
cmp eax, [wlen]
|
||||
jne @f
|
||||
cmp [rlen], 0
|
||||
jne @f
|
||||
or edx, DW_CMD_STOP ; last byte of a write-only transfer
|
||||
@@:
|
||||
mov [ebx+DwIcDataCmd], edx
|
||||
mov [wsent], eax
|
||||
jmp .loop
|
||||
.push_reads:
|
||||
; Feed read commands, at most 8 outstanding so the RX FIFO keeps up.
|
||||
mov eax, [rqueued]
|
||||
cmp eax, [rlen]
|
||||
jae .check_done
|
||||
mov edx, eax
|
||||
sub edx, [rgot]
|
||||
cmp edx, 8
|
||||
jae .check_done
|
||||
test dword [ebx+DwIcStatus], DW_STAT_TFNF
|
||||
jz .check_done
|
||||
mov edx, DW_CMD_READ
|
||||
test eax, eax
|
||||
jnz @f
|
||||
cmp [wlen], 0
|
||||
je @f
|
||||
or edx, DW_CMD_RESTART ; repeated START after the write phase
|
||||
@@:
|
||||
mov ecx, [rlen]
|
||||
dec ecx
|
||||
cmp eax, ecx
|
||||
jne @f
|
||||
or edx, DW_CMD_STOP
|
||||
@@:
|
||||
mov [ebx+DwIcDataCmd], edx
|
||||
inc eax
|
||||
mov [rqueued], eax
|
||||
jmp .loop
|
||||
.check_done:
|
||||
mov eax, [rgot]
|
||||
cmp eax, [rlen]
|
||||
jne .not_done
|
||||
mov eax, [wsent]
|
||||
cmp eax, [wlen]
|
||||
jne .not_done
|
||||
mov eax, [ebx+DwIcStatus]
|
||||
test eax, DW_STAT_TFE
|
||||
jz .not_done
|
||||
test eax, DW_STAT_MST_ACT
|
||||
jnz .not_done
|
||||
call dw_ctrl_disable
|
||||
xor eax, eax
|
||||
ret
|
||||
.not_done:
|
||||
invoke GetTimerTicks
|
||||
sub eax, [t0]
|
||||
cmp eax, [XferTimeout]
|
||||
jae .timeout
|
||||
call dw_wait_step
|
||||
jmp .loop
|
||||
.abort:
|
||||
mov esi, [ebx+DwIcTxAbrtSource]
|
||||
mov eax, [ebx+DwIcClrTxAbrt]
|
||||
call dw_ctrl_disable
|
||||
mov eax, esi
|
||||
test eax, eax
|
||||
jnz @f
|
||||
or eax, 0x80000000
|
||||
@@:
|
||||
ret
|
||||
.timeout:
|
||||
call dw_ctrl_abort
|
||||
or eax, -1
|
||||
ret
|
||||
endp
|
||||
|
||||
; Reads one HID input report as a single continuous bus transaction, the way
|
||||
; interrupt-driven hosts (Windows, Linux) do it: the optional register-address
|
||||
; write and every read command are queued into the TX FIFO before the bytes
|
||||
; start flowing, so nothing on the wire depends on how fast the host loop
|
||||
; runs. The previous adaptive read (fetch 2 length bytes, decide, fetch the
|
||||
; rest, stop short) was cut down on the wire to 3 bytes for an empty poll -
|
||||
; and the SIPODEV/Hantick touchpad firmwares are exactly the kind of thing
|
||||
; that wedges when an input read is shorter than the frame they prepared.
|
||||
; rlen should not exceed the TX FIFO depth (IC_COMP_PARAM_1 bits 23:16, plus
|
||||
; one) or the queue loop degrades to feeding the FIFO on the fly, which
|
||||
; reintroduces pauses.
|
||||
; in: addr = slave, wlen bytes at wbuf written first (0 = plain read),
|
||||
; rlen bytes read into buf.
|
||||
; out: eax = 0 ok, IC_TX_ABRT_SOURCE on NAK/abort, -1 on timeout.
|
||||
; Timeout check for the dw_read_block wait spots; expands inside the proc so
|
||||
; [t0] and [XferTimeout] resolve in the caller's own frame.
|
||||
macro BLOCK_TICK fail_label {
|
||||
invoke GetTimerTicks
|
||||
sub eax, [t0]
|
||||
cmp eax, [XferTimeout]
|
||||
jae fail_label
|
||||
call dw_wait_step
|
||||
}
|
||||
|
||||
proc dw_read_block stdcall uses ebx esi edi, addr:dword, wbuf:dword, wlen:dword, buf:dword, rlen:dword
|
||||
locals
|
||||
rgot dd ?
|
||||
t0 dd ?
|
||||
endl
|
||||
mov ebx, [I2cMmio]
|
||||
call dw_ctrl_disable
|
||||
mov eax, [addr]
|
||||
mov [ebx+DwIcTar], eax
|
||||
mov eax, [ebx+DwIcClrIntr]
|
||||
mov dword [ebx+DwIcEnable], 1
|
||||
invoke GetTimerTicks
|
||||
mov [t0], eax
|
||||
mov [rgot], 0
|
||||
; Write phase: the register address bytes, no STOP - the read continues the
|
||||
; same transaction after a repeated START.
|
||||
xor ecx, ecx
|
||||
.wr:
|
||||
cmp ecx, [wlen]
|
||||
jae .queue_reads
|
||||
test dword [ebx+DwIcRawIntrStat], DW_INT_TX_ABRT
|
||||
jnz .abort
|
||||
test dword [ebx+DwIcStatus], DW_STAT_TFNF
|
||||
jz .wr_wait
|
||||
mov esi, [wbuf]
|
||||
movzx edx, byte [esi+ecx]
|
||||
mov [ebx+DwIcDataCmd], edx
|
||||
inc ecx
|
||||
jmp .wr
|
||||
.wr_wait:
|
||||
BLOCK_TICK .timeout
|
||||
jmp .wr
|
||||
.queue_reads:
|
||||
xor ecx, ecx
|
||||
.rq:
|
||||
cmp ecx, [rlen]
|
||||
jae .drain
|
||||
test dword [ebx+DwIcRawIntrStat], DW_INT_TX_ABRT
|
||||
jnz .abort
|
||||
test dword [ebx+DwIcStatus], DW_STAT_TFNF
|
||||
jz .rq_wait
|
||||
mov edx, DW_CMD_READ
|
||||
test ecx, ecx
|
||||
jnz .not_first
|
||||
cmp [wlen], 0
|
||||
je .not_first
|
||||
or edx, DW_CMD_RESTART
|
||||
.not_first:
|
||||
mov eax, [rlen]
|
||||
dec eax
|
||||
cmp ecx, eax
|
||||
jne @f
|
||||
or edx, DW_CMD_STOP
|
||||
@@:
|
||||
mov [ebx+DwIcDataCmd], edx
|
||||
inc ecx
|
||||
; Drain opportunistically so a FIFO shallower than rlen cannot deadlock the
|
||||
; queue loop (the RX side fills while the TX side is full).
|
||||
test dword [ebx+DwIcStatus], DW_STAT_RFNE
|
||||
jz .rq
|
||||
call .take_byte
|
||||
jmp .rq
|
||||
.rq_wait:
|
||||
BLOCK_TICK .timeout
|
||||
jmp .rq
|
||||
.drain:
|
||||
test dword [ebx+DwIcRawIntrStat], DW_INT_TX_ABRT
|
||||
jnz .abort
|
||||
test dword [ebx+DwIcStatus], DW_STAT_RFNE
|
||||
jz .chk
|
||||
call .take_byte
|
||||
jmp .drain
|
||||
; Moves one byte from the RX FIFO into the caller's buffer. Exactly rlen
|
||||
; reads are queued into freshly flushed FIFOs, so a byte beyond rlen should
|
||||
; never arrive; if one does anyway it is still taken off the FIFO, so the
|
||||
; drain loop cannot stall on it, but it is dropped rather than written
|
||||
; past the end of the buffer.
|
||||
.take_byte:
|
||||
mov edx, [rgot]
|
||||
mov eax, [ebx+DwIcDataCmd]
|
||||
cmp edx, [rlen]
|
||||
jae @f
|
||||
mov edi, [buf]
|
||||
mov [edi+edx], al
|
||||
inc edx
|
||||
mov [rgot], edx
|
||||
@@:
|
||||
retn
|
||||
.chk:
|
||||
mov eax, [rgot]
|
||||
cmp eax, [rlen]
|
||||
jne .wait
|
||||
test dword [ebx+DwIcStatus], DW_STAT_MST_ACT
|
||||
jnz .wait
|
||||
call dw_ctrl_disable
|
||||
xor eax, eax
|
||||
ret
|
||||
.wait:
|
||||
BLOCK_TICK .timeout
|
||||
jmp .drain
|
||||
.abort:
|
||||
mov esi, [ebx+DwIcTxAbrtSource]
|
||||
mov eax, [ebx+DwIcClrTxAbrt]
|
||||
call dw_ctrl_disable
|
||||
mov eax, esi
|
||||
test eax, eax
|
||||
jnz @f
|
||||
or eax, 0x80000000
|
||||
@@:
|
||||
ret
|
||||
.timeout:
|
||||
call dw_ctrl_abort
|
||||
or eax, -1
|
||||
ret
|
||||
endp
|
||||
@@ -0,0 +1,646 @@
|
||||
; Minimal HID report descriptor parser.
|
||||
;
|
||||
; The goal is not a full HID implementation: the parser walks the descriptor
|
||||
; once and remembers the bit layout of the first input report that contains
|
||||
; relative X and relative Y (Generic Desktop / X, Y) - i.e. the mouse
|
||||
; compatibility collection that every I2C mouse and every Windows Precision
|
||||
; Touchpad exposes. Buttons (Usage Page 9) and a relative wheel found in the
|
||||
; same report are picked up too. Absolute (digitizer) reports are advanced
|
||||
; over but otherwise ignored.
|
||||
;
|
||||
; Report IDs are honoured: bit positions are counted separately per report ID
|
||||
; and the chosen ID is checked in every incoming packet.
|
||||
;
|
||||
; Alongside the mouse report, the parser also maps the touchpad (Windows
|
||||
; Precision Touchpad) report: the report that carries Tip Switch usages.
|
||||
; Each Tip Switch opens a new finger block; the absolute X and Y that follow
|
||||
; it belong to that finger; Contact Count and the Button-page fields of the
|
||||
; same report are recorded too. Once the pad is switched into touchpad mode
|
||||
; those offsets are what the frame decoder reads - every vendor lays the
|
||||
; frame out differently, and only the descriptor knows how.
|
||||
HID_MAX_FINGERS = 5
|
||||
|
||||
HID_MAX_USAGES = 16
|
||||
HID_MAX_REPIDS = 16
|
||||
|
||||
; Returns the pointer to the input bit counter of the current report ID,
|
||||
; allocating a new slot on first use.
|
||||
; out: ebx -> dword bit counter. Clobbers eax, ecx.
|
||||
proc hid_get_bits_slot
|
||||
mov eax, [p_report_id]
|
||||
xor ecx, ecx
|
||||
.scan:
|
||||
cmp ecx, [p_idcnt]
|
||||
jae .add
|
||||
cmp eax, [p_ids+ecx*4]
|
||||
jz .found
|
||||
inc ecx
|
||||
jmp .scan
|
||||
.add:
|
||||
cmp ecx, HID_MAX_REPIDS
|
||||
jb @f
|
||||
dec ecx ; table full: reuse the last slot
|
||||
jmp .found
|
||||
@@:
|
||||
mov [p_ids+ecx*4], eax
|
||||
mov dword [p_bits+ecx*4], 0
|
||||
mov dword [p_fbits+ecx*4], 0
|
||||
inc [p_idcnt]
|
||||
.found:
|
||||
lea ebx, [p_bits+ecx*4]
|
||||
ret
|
||||
endp
|
||||
|
||||
; Handles one Input main item. v_flags = item data (bit 2 = relative).
|
||||
proc hid_process_input
|
||||
push eax ebx ecx edx
|
||||
call hid_get_bits_slot
|
||||
mov eax, [ebx]
|
||||
mov [v_base], eax
|
||||
; Advance the counter over this field right away.
|
||||
mov eax, [p_report_size]
|
||||
imul eax, [p_report_count]
|
||||
add [ebx], eax
|
||||
; Remember the largest logical maximum ever attached to Generic Desktop X
|
||||
; and Y. The mouse collection declares a tiny relative range there while
|
||||
; the touchpad collection declares the real surface extents, so the
|
||||
; maximum over the whole descriptor is the size of the pad - which is what
|
||||
; the button zones are measured against, and it differs per model.
|
||||
cmp [p_usage_cnt], 0
|
||||
je .no_extent
|
||||
xor ecx, ecx
|
||||
.ext_loop:
|
||||
cmp ecx, [p_usage_cnt]
|
||||
jae .no_extent
|
||||
mov eax, [p_usages+ecx*4]
|
||||
cmp eax, 0x00010030
|
||||
jne .ext_y
|
||||
mov eax, [p_log_max]
|
||||
cmp eax, [t_padmaxx]
|
||||
jbe .ext_next
|
||||
mov [t_padmaxx], eax
|
||||
jmp .ext_next
|
||||
.ext_y:
|
||||
cmp eax, 0x00010031
|
||||
jne .ext_next
|
||||
mov eax, [p_log_max]
|
||||
cmp eax, [t_padmaxy]
|
||||
jbe .ext_next
|
||||
mov [t_padmaxy], eax
|
||||
.ext_next:
|
||||
inc ecx
|
||||
jmp .ext_loop
|
||||
.no_extent:
|
||||
; Button-style field: Usage Minimum/Maximum on the Button page.
|
||||
cmp [p_usage_min], -1
|
||||
je .not_buttons
|
||||
cmp [p_usage_max], -1
|
||||
je .not_buttons
|
||||
cmp [p_usage_page], 9
|
||||
jne .not_buttons
|
||||
cmp [p_report_size], 1 ; buttons are always 1-bit fields
|
||||
jne .done
|
||||
mov eax, [v_base]
|
||||
mov ecx, [p_report_count]
|
||||
call hid_note_buttons
|
||||
jmp .done
|
||||
.not_buttons:
|
||||
cmp [p_usage_cnt], 0
|
||||
je .done
|
||||
call hid_note_touchpad
|
||||
; Usage-list field: look for GD/X, GD/Y, GD/Wheel among the usages.
|
||||
test [v_flags], 4 ; only relative fields are interesting
|
||||
jz .done
|
||||
xor ecx, ecx
|
||||
.usage_loop:
|
||||
cmp ecx, [p_report_count]
|
||||
jae .done
|
||||
; usage index = min(field index, usage count - 1): a short usage list
|
||||
; applies its last usage to the remaining fields.
|
||||
mov edx, [p_usage_cnt]
|
||||
dec edx
|
||||
mov eax, ecx
|
||||
cmp eax, edx
|
||||
jbe @f
|
||||
mov eax, edx
|
||||
@@:
|
||||
mov eax, [p_usages+eax*4]
|
||||
cmp eax, 0x00010030
|
||||
je .is_x
|
||||
cmp eax, 0x00010031
|
||||
je .is_y
|
||||
cmp eax, 0x00010038
|
||||
je .is_wheel
|
||||
.next_usage:
|
||||
inc ecx
|
||||
jmp .usage_loop
|
||||
.is_x:
|
||||
test [t_have], 1
|
||||
jnz .next_usage
|
||||
call hid_claim_report_id
|
||||
jc .next_usage
|
||||
call hid_field_offset
|
||||
mov [t_xoff], eax
|
||||
mov eax, [p_report_size]
|
||||
mov [t_xsize], eax
|
||||
or [t_have], 1
|
||||
jmp .next_usage
|
||||
.is_y:
|
||||
test [t_have], 2
|
||||
jnz .next_usage
|
||||
call hid_claim_report_id
|
||||
jc .next_usage
|
||||
call hid_field_offset
|
||||
mov [t_yoff], eax
|
||||
mov eax, [p_report_size]
|
||||
mov [t_ysize], eax
|
||||
or [t_have], 2
|
||||
jmp .next_usage
|
||||
.is_wheel:
|
||||
test [t_have], 8
|
||||
jnz .next_usage
|
||||
mov eax, [t_id]
|
||||
cmp eax, -1 ; wheel never claims a report on its own
|
||||
je .next_usage
|
||||
cmp eax, [p_report_id]
|
||||
jne .next_usage
|
||||
call hid_field_offset
|
||||
mov [t_woff], eax
|
||||
mov eax, [p_report_size]
|
||||
mov [t_wsize], eax
|
||||
or [t_have], 8
|
||||
jmp .next_usage
|
||||
.done:
|
||||
pop edx ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Records a run of 1-bit Button-page fields starting at bit eax, ecx of them.
|
||||
; The mouse decoder wants the buttons of ITS report: an item from some other
|
||||
; report is kept only until a better one turns up, and .eof drops it if it
|
||||
; still does not match. The touchpad report keeps its own copy.
|
||||
proc hid_note_buttons
|
||||
push eax ecx edx
|
||||
cmp ecx, 8
|
||||
jbe @f
|
||||
mov ecx, 8
|
||||
@@:
|
||||
mov edx, [p_report_id]
|
||||
cmp edx, [t_ptp_id]
|
||||
jne .mouse
|
||||
cmp [t_pbtn_cnt], 0
|
||||
jne .mouse
|
||||
mov [t_pbtn_off], eax
|
||||
mov [t_pbtn_cnt], ecx
|
||||
.mouse:
|
||||
cmp [t_btncnt], 0
|
||||
je .take
|
||||
mov edx, [t_btnid]
|
||||
cmp edx, [t_id] ; already the chosen report's: keep
|
||||
je .done
|
||||
mov edx, [p_report_id]
|
||||
cmp edx, [t_btnid] ; a second run in the same report: keep the first
|
||||
je .done
|
||||
.take:
|
||||
mov [t_btnoff], eax
|
||||
mov [t_btncnt], ecx
|
||||
mov eax, [p_report_id]
|
||||
mov [t_btnid], eax
|
||||
.done:
|
||||
pop edx ecx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Walks the usages of the current input item looking for the touchpad
|
||||
; fields. Field k takes usage min(k, count-1), as in the mouse search.
|
||||
proc hid_note_touchpad
|
||||
push eax ebx ecx edx
|
||||
xor ecx, ecx
|
||||
.field:
|
||||
cmp ecx, [p_report_count]
|
||||
jae .done
|
||||
mov edx, [p_usage_cnt]
|
||||
dec edx
|
||||
mov eax, ecx
|
||||
cmp eax, edx
|
||||
jbe @f
|
||||
mov eax, edx
|
||||
@@:
|
||||
mov ebx, [p_usages+eax*4] ; ebx = usage of field ecx
|
||||
call hid_field_offset ; eax = its bit offset
|
||||
cmp ebx, 0x000D0042 ; Tip Switch: a new finger
|
||||
je .tip
|
||||
cmp ebx, 0x000D0054 ; Contact Count
|
||||
je .count
|
||||
cmp ebx, 0x000D0051 ; Contact Identifier
|
||||
je .cid
|
||||
cmp ebx, 0x00010030
|
||||
je .x
|
||||
cmp ebx, 0x00010031
|
||||
je .y
|
||||
shr ebx, 16
|
||||
cmp ebx, 9 ; buttons written as a usage list
|
||||
jne .next
|
||||
push ecx
|
||||
neg ecx
|
||||
add ecx, [p_report_count] ; the fields from here to the end
|
||||
call hid_note_buttons
|
||||
pop ecx
|
||||
jmp .done ; one run per item is enough
|
||||
.tip:
|
||||
cmp [t_ptp_id], -1
|
||||
jne @f
|
||||
mov edx, [p_report_id]
|
||||
mov [t_ptp_id], edx ; the first report with fingers is the one
|
||||
@@:
|
||||
call hid_in_ptp
|
||||
jne .next
|
||||
mov edx, [t_fcount]
|
||||
cmp edx, HID_MAX_FINGERS
|
||||
jae .next
|
||||
mov [t_ftip+edx*4], eax
|
||||
mov dword [t_fxs+edx*4], 0
|
||||
mov dword [t_fys+edx*4], 0
|
||||
mov dword [t_fcids+edx*4], 0
|
||||
inc [t_fcount]
|
||||
jmp .next
|
||||
.cid:
|
||||
call hid_in_ptp
|
||||
jne .next
|
||||
mov edx, [t_fcount]
|
||||
test edx, edx
|
||||
jz .next
|
||||
dec edx
|
||||
cmp dword [t_fcids+edx*4], 0
|
||||
jne .next
|
||||
mov [t_fcid+edx*4], eax
|
||||
mov eax, [p_report_size]
|
||||
mov [t_fcids+edx*4], eax
|
||||
jmp .next
|
||||
.count:
|
||||
call hid_in_ptp
|
||||
jne .next
|
||||
mov [t_ccnt_off], eax
|
||||
mov eax, [p_report_size]
|
||||
mov [t_ccnt_size], eax
|
||||
jmp .next
|
||||
.x:
|
||||
test [v_flags], 4 ; absolute only; relative is the mouse
|
||||
jnz .next
|
||||
call hid_in_ptp
|
||||
jne .next
|
||||
mov edx, [t_fcount]
|
||||
test edx, edx
|
||||
jz .next
|
||||
dec edx
|
||||
cmp dword [t_fxs+edx*4], 0
|
||||
jne .next
|
||||
mov [t_fx+edx*4], eax
|
||||
mov eax, [p_report_size]
|
||||
mov [t_fxs+edx*4], eax
|
||||
jmp .next
|
||||
.y:
|
||||
test [v_flags], 4
|
||||
jnz .next
|
||||
call hid_in_ptp
|
||||
jne .next
|
||||
mov edx, [t_fcount]
|
||||
test edx, edx
|
||||
jz .next
|
||||
dec edx
|
||||
cmp dword [t_fys+edx*4], 0
|
||||
jne .next
|
||||
mov [t_fy+edx*4], eax
|
||||
mov eax, [p_report_size]
|
||||
mov [t_fys+edx*4], eax
|
||||
.next:
|
||||
inc ecx
|
||||
jmp .field
|
||||
.done:
|
||||
pop edx ecx ebx eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; ZF set when the current item belongs to the touchpad report.
|
||||
proc hid_in_ptp
|
||||
push eax
|
||||
mov eax, [p_report_id]
|
||||
cmp eax, [t_ptp_id]
|
||||
pop eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Size in bytes of the feature report with id eax; 0 when the descriptor
|
||||
; never mentioned one.
|
||||
proc hid_feature_bytes
|
||||
push ecx
|
||||
xor ecx, ecx
|
||||
@@:
|
||||
cmp ecx, [p_idcnt]
|
||||
jae .none
|
||||
cmp eax, [p_ids+ecx*4]
|
||||
je .found
|
||||
inc ecx
|
||||
jmp @b
|
||||
.found:
|
||||
mov eax, [p_fbits+ecx*4]
|
||||
add eax, 7
|
||||
shr eax, 3
|
||||
pop ecx
|
||||
ret
|
||||
.none:
|
||||
xor eax, eax
|
||||
pop ecx
|
||||
ret
|
||||
endp
|
||||
|
||||
; Locks the candidate report ID to the current one, or fails (CF=1) when a
|
||||
; different report already holds X/Y.
|
||||
proc hid_claim_report_id
|
||||
mov eax, [t_id]
|
||||
cmp eax, -1
|
||||
jne @f
|
||||
mov eax, [p_report_id]
|
||||
mov [t_id], eax
|
||||
clc
|
||||
ret
|
||||
@@:
|
||||
cmp eax, [p_report_id]
|
||||
jne .taken
|
||||
clc
|
||||
ret
|
||||
.taken:
|
||||
stc
|
||||
ret
|
||||
endp
|
||||
|
||||
; Bit offset of field #ecx of the current item.
|
||||
; in: ecx = field index. out: eax = v_base + ecx * report_size.
|
||||
proc hid_field_offset
|
||||
mov eax, [p_report_size]
|
||||
imul eax, ecx
|
||||
add eax, [v_base]
|
||||
ret
|
||||
endp
|
||||
|
||||
; Parses the report descriptor.
|
||||
; in: esi -> descriptor, ecx = length.
|
||||
; out: eax = 1 and f_* variables filled if a usable report was found.
|
||||
proc hid_parse_report_desc uses ebx esi edi
|
||||
lea edi, [esi+ecx]
|
||||
xor eax, eax
|
||||
mov [p_usage_page], eax
|
||||
mov [p_report_size], eax
|
||||
mov [p_report_count], eax
|
||||
mov [p_report_id], eax
|
||||
mov [p_uses_repid], eax
|
||||
mov [p_usage_cnt], eax
|
||||
mov [p_idcnt], eax
|
||||
mov [p_log_max], eax
|
||||
mov [t_padmaxx], eax
|
||||
mov [t_padmaxy], eax
|
||||
mov [t_have], eax
|
||||
mov [t_btncnt], eax
|
||||
mov [t_wsize], eax
|
||||
mov [p_usage_min], -1
|
||||
mov [p_usage_max], -1
|
||||
mov [t_id], -1
|
||||
mov [t_btnid], -2
|
||||
mov [t_ptp_id], -1
|
||||
mov [t_fcount], eax
|
||||
mov [t_ccnt_size], eax
|
||||
mov [t_pbtn_cnt], eax
|
||||
mov [t_ptp_bytes], eax
|
||||
.loop:
|
||||
cmp esi, edi
|
||||
jae .eof
|
||||
movzx eax, byte [esi]
|
||||
inc esi
|
||||
cmp al, 0xFE
|
||||
je .long_item
|
||||
mov ecx, eax
|
||||
and ecx, 3
|
||||
cmp ecx, 3
|
||||
jne @f
|
||||
inc ecx ; size code 3 means 4 bytes
|
||||
@@:
|
||||
lea ebx, [esi+ecx]
|
||||
cmp ebx, edi
|
||||
ja .eof
|
||||
xor edx, edx
|
||||
jecxz .no_data
|
||||
cmp ecx, 1
|
||||
jne @f
|
||||
movzx edx, byte [esi]
|
||||
jmp .have_data
|
||||
@@:
|
||||
cmp ecx, 2
|
||||
jne @f
|
||||
movzx edx, word [esi]
|
||||
jmp .have_data
|
||||
@@:
|
||||
mov edx, [esi]
|
||||
.have_data:
|
||||
add esi, ecx
|
||||
.no_data:
|
||||
and eax, 0xFC
|
||||
; Global items
|
||||
cmp al, 0x04
|
||||
je .g_usage_page
|
||||
cmp al, 0x84
|
||||
je .g_report_id
|
||||
cmp al, 0x74
|
||||
je .g_report_size
|
||||
cmp al, 0x94
|
||||
je .g_report_count
|
||||
cmp al, 0x24
|
||||
je .g_log_max
|
||||
; Local items
|
||||
cmp al, 0x08
|
||||
je .l_usage
|
||||
cmp al, 0x18
|
||||
je .l_usage_min
|
||||
cmp al, 0x28
|
||||
je .l_usage_max
|
||||
; Main items
|
||||
cmp al, 0x80
|
||||
je .m_input
|
||||
cmp al, 0x90
|
||||
je .m_clear_locals
|
||||
cmp al, 0xB0
|
||||
je .m_feature
|
||||
cmp al, 0xA0
|
||||
je .m_clear_locals
|
||||
cmp al, 0xC0
|
||||
je .m_clear_locals
|
||||
jmp .loop
|
||||
.g_usage_page:
|
||||
and edx, 0xFFFF
|
||||
mov [p_usage_page], edx
|
||||
jmp .loop
|
||||
.g_report_id:
|
||||
mov [p_report_id], edx
|
||||
mov [p_uses_repid], 1
|
||||
jmp .loop
|
||||
.g_report_size:
|
||||
mov [p_report_size], edx
|
||||
jmp .loop
|
||||
.g_report_count:
|
||||
mov [p_report_count], edx
|
||||
jmp .loop
|
||||
.g_log_max:
|
||||
mov [p_log_max], edx
|
||||
jmp .loop
|
||||
.l_usage:
|
||||
mov ebx, [p_usage_cnt]
|
||||
cmp ebx, HID_MAX_USAGES
|
||||
jae .loop
|
||||
cmp ecx, 4 ; 4-byte usage carries its own page
|
||||
je @f
|
||||
mov eax, [p_usage_page]
|
||||
shl eax, 16
|
||||
or edx, eax
|
||||
@@:
|
||||
mov [p_usages+ebx*4], edx
|
||||
inc [p_usage_cnt]
|
||||
jmp .loop
|
||||
.l_usage_min:
|
||||
mov [p_usage_min], edx
|
||||
jmp .loop
|
||||
.l_usage_max:
|
||||
mov [p_usage_max], edx
|
||||
jmp .loop
|
||||
.m_input:
|
||||
mov [v_flags], edx
|
||||
call hid_process_input
|
||||
jmp .m_clear_locals ; input bits are not feature bits
|
||||
.m_feature:
|
||||
; Feature reports are only ever written, never decoded, but writing one
|
||||
; needs its exact size: a SET_REPORT shorter than the report is ignored by
|
||||
; some firmwares (the Elan Input Mode report has two bytes, mode and the
|
||||
; selective-reporting switches - one byte does nothing there).
|
||||
call hid_get_bits_slot
|
||||
mov eax, [p_report_size]
|
||||
imul eax, [p_report_count]
|
||||
add [p_fbits+ecx*4], eax
|
||||
.m_clear_locals:
|
||||
xor eax, eax
|
||||
mov [p_usage_cnt], eax
|
||||
mov [p_usage_min], -1
|
||||
mov [p_usage_max], -1
|
||||
jmp .loop
|
||||
.long_item:
|
||||
cmp esi, edi
|
||||
jae .eof
|
||||
movzx ecx, byte [esi]
|
||||
lea esi, [esi+ecx+2]
|
||||
jmp .loop
|
||||
.eof:
|
||||
; Size of the touchpad report, when there is one.
|
||||
mov eax, [t_ptp_id]
|
||||
cmp eax, -1
|
||||
je .no_ptp
|
||||
xor ecx, ecx
|
||||
@@:
|
||||
cmp ecx, [p_idcnt]
|
||||
jae .no_ptp
|
||||
cmp eax, [p_ids+ecx*4]
|
||||
je @f
|
||||
inc ecx
|
||||
jmp @b
|
||||
@@:
|
||||
mov eax, [p_bits+ecx*4]
|
||||
add eax, 7
|
||||
shr eax, 3
|
||||
mov [t_ptp_bytes], eax
|
||||
.no_ptp:
|
||||
; Success needs relative X and Y in the same report - or, failing that, a
|
||||
; touchpad report with at least one complete finger, which is then the only
|
||||
; thing the device will be driven through.
|
||||
mov eax, [t_have]
|
||||
and eax, 3
|
||||
cmp eax, 3
|
||||
je .have_mouse
|
||||
cmp [t_fcount], 0
|
||||
je .fail
|
||||
cmp dword [t_fxs], 0
|
||||
je .fail
|
||||
cmp dword [t_fys], 0
|
||||
je .fail
|
||||
mov [f_repid], -1 ; no mouse report to match
|
||||
mov [f_bytes], 0
|
||||
mov [t_btncnt], 0
|
||||
movi eax, 1
|
||||
ret
|
||||
.have_mouse:
|
||||
; Keep buttons/wheel only when they live in the chosen report.
|
||||
mov eax, [t_btnid]
|
||||
cmp eax, [t_id]
|
||||
je @f
|
||||
mov [t_btncnt], 0
|
||||
@@:
|
||||
; Final layout.
|
||||
mov eax, [t_id]
|
||||
mov [f_repid], eax
|
||||
xor ecx, ecx
|
||||
@@:
|
||||
cmp ecx, [p_idcnt]
|
||||
jae .no_bits
|
||||
cmp eax, [p_ids+ecx*4]
|
||||
je .got_bits
|
||||
inc ecx
|
||||
jmp @b
|
||||
.got_bits:
|
||||
mov eax, [p_bits+ecx*4]
|
||||
add eax, 7
|
||||
shr eax, 3
|
||||
mov [f_bytes], eax
|
||||
movi eax, 1
|
||||
ret
|
||||
.no_bits:
|
||||
.fail:
|
||||
xor eax, eax
|
||||
ret
|
||||
endp
|
||||
|
||||
; Extracts an unsigned field from an input report.
|
||||
; in: esi -> report data, eax = bit offset, ecx = bit count (1..24).
|
||||
; out: eax = value.
|
||||
proc hid_extract_u
|
||||
push ebx ecx edx
|
||||
mov edx, eax
|
||||
shr edx, 3
|
||||
mov ebx, [esi+edx] ; buffer has spare bytes at the end
|
||||
and eax, 7
|
||||
push ecx
|
||||
mov ecx, eax
|
||||
shr ebx, cl
|
||||
pop ecx
|
||||
neg ecx
|
||||
add ecx, 32
|
||||
shl ebx, cl
|
||||
shr ebx, cl
|
||||
mov eax, ebx
|
||||
pop edx ecx ebx
|
||||
ret
|
||||
endp
|
||||
|
||||
; Same, sign-extended.
|
||||
proc hid_extract_s
|
||||
push ebx ecx edx
|
||||
mov edx, eax
|
||||
shr edx, 3
|
||||
mov ebx, [esi+edx]
|
||||
and eax, 7
|
||||
push ecx
|
||||
mov ecx, eax
|
||||
shr ebx, cl
|
||||
pop ecx
|
||||
neg ecx
|
||||
add ecx, 32
|
||||
shl ebx, cl
|
||||
sar ebx, cl
|
||||
mov eax, ebx
|
||||
pop edx ecx ebx
|
||||
ret
|
||||
endp
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,26 @@
|
||||
[touchpad]
|
||||
; pointer speed in percent of the driver's default (on top of the [mouse]
|
||||
; speed above; pads differ in resolution)
|
||||
speed=100
|
||||
; how far a finger must move before the pointer follows, in pad units;
|
||||
; larger is steadier under a pressing finger, 0 turns the filter off
|
||||
jitter=1
|
||||
; the same, for a finger that landed on the button strip: it is pressing
|
||||
; rather than steering there, so it needs a stricter margin
|
||||
jitter_buttons=45
|
||||
; pad units of two-finger travel per wheel step, and the direction
|
||||
scroll_step=64
|
||||
scroll_invert=0
|
||||
; turn a short, still touch into a click: one finger left, two right,
|
||||
; three middle
|
||||
tap_enable=1
|
||||
; tap, then touch again at once and move: the button stays down for that
|
||||
; second touch - this is how text is selected and how one draws
|
||||
tap_drag=1
|
||||
; right click: 0 never, 1 bottom-right corner, 2 by finger count (two
|
||||
; fingers right, three middle), 3 either
|
||||
right_click=1
|
||||
; button strip along the bottom edge, in percent of the surface: its
|
||||
; height, and where its left half ends
|
||||
button_zone=15
|
||||
right_split=50
|
||||
@@ -0,0 +1,72 @@
|
||||
; Asks the I2C touchpad driver to read its settings again.
|
||||
;
|
||||
; The driver takes everything it can be tuned with from the [touchpad] section
|
||||
; of /sys/settings/system.ini, and it reads that file once while loading. This
|
||||
; tells it to read the file again, so editing a setting takes effect straight
|
||||
; away instead of at the next boot.
|
||||
;
|
||||
; There is no window: the outcome goes to the debug board, the way the driver
|
||||
; reports everything else.
|
||||
|
||||
format binary as ""
|
||||
use32
|
||||
db 'MENUET01'
|
||||
dd 1, start, i_end, mem, mem, 0, 0
|
||||
|
||||
include '../../programs/macros.inc'
|
||||
|
||||
SRV_RELOAD_CONF = 1
|
||||
|
||||
start:
|
||||
; 1. Find the driver's service by name.
|
||||
mcall 68, 16, srv_name
|
||||
test eax, eax
|
||||
jz .no_driver
|
||||
mov [ioctl.handle], eax
|
||||
; 2. Ask it to reload. No data travels either way: the driver reads the file
|
||||
; itself, so the settings file stays the only place they are written down.
|
||||
mcall 68, 17, ioctl
|
||||
test eax, eax
|
||||
jnz .refused
|
||||
mov esi, msg_ok
|
||||
jmp .say
|
||||
.no_driver:
|
||||
mov esi, msg_no_driver
|
||||
jmp .say
|
||||
.refused:
|
||||
mov esi, msg_refused
|
||||
.say:
|
||||
call board_str
|
||||
or eax, -1
|
||||
mcall
|
||||
|
||||
; Writes a zero-terminated string to the debug board.
|
||||
; in: esi -> string
|
||||
board_str:
|
||||
lodsb
|
||||
test al, al
|
||||
jz .done
|
||||
mov cl, al
|
||||
mcall 63, 1
|
||||
jmp board_str
|
||||
.done:
|
||||
ret
|
||||
|
||||
srv_name db 'I2CHID', 0
|
||||
|
||||
align 4
|
||||
ioctl:
|
||||
.handle dd 0
|
||||
.io_code dd SRV_RELOAD_CONF
|
||||
.input dd 0
|
||||
.inp_size dd 0
|
||||
.output dd 0
|
||||
.out_size dd 0
|
||||
|
||||
msg_ok db 'tpreload: touchpad settings reloaded', 13, 10, 0
|
||||
msg_no_driver db 'tpreload: the I2C touchpad driver is not loaded', 13, 10, 0
|
||||
msg_refused db 'tpreload: the driver refused the request', 13, 10, 0
|
||||
|
||||
i_end:
|
||||
rb 1024
|
||||
mem:
|
||||
@@ -139,6 +139,7 @@ import core,\
|
||||
RegKeyboard,\
|
||||
DelKeyboard,\
|
||||
Sleep,\
|
||||
Delay,\
|
||||
GetTimerTicks,\
|
||||
\
|
||||
strncat,\
|
||||
|
||||
@@ -842,8 +842,7 @@ disk_scan_partitions:
|
||||
cmp ebx, mbr_buffer
|
||||
jz .release_partition_buffer
|
||||
; 15b. If we have allocated it, free it.
|
||||
xchg eax, ebx
|
||||
call free
|
||||
stdcall kernel_free, ebx
|
||||
jmp .nothing
|
||||
; 15c. Otherwise, release reference.
|
||||
.release_partition_buffer:
|
||||
|
||||
@@ -183,6 +183,8 @@ EFLAGS_ID = 0x200000 ; id flag
|
||||
IRQ_PIC = 0
|
||||
IRQ_APIC = 1
|
||||
|
||||
IO_MAP_SIZE = 65536/8 ; 8192 or 2 PAGE_SIZE
|
||||
|
||||
struct TSS
|
||||
_back rw 2
|
||||
_esp0 rd 1
|
||||
@@ -290,6 +292,9 @@ sys_proc = OS_BASE + 0x008E000
|
||||
|
||||
SLOT_BASE = OS_BASE + 0x0090000
|
||||
|
||||
APPDATA_IDLE_THREAD = SLOT_BASE + sizeof.APPDATA*1 ; poiner to IDLE thread
|
||||
APPDATA_OS_THREAD = SLOT_BASE + sizeof.APPDATA*2 ; poiner to OS thread
|
||||
|
||||
VGABasePtr = OS_BASE + 0x00A0000
|
||||
|
||||
virtual at OS_BASE + 0x05FFF80
|
||||
@@ -570,7 +575,7 @@ struct APPDATA
|
||||
ipc_start dd ? ;+160
|
||||
ipc_size dd ? ;+164
|
||||
occurred_events dd ? ;+168 ; mask which accumulates occurred events
|
||||
debugger_slot dd ? ;+172 ; index in SLOT_BASE array
|
||||
debugger_thread dd ? ;+172 ; pointer to APPDATA or 0
|
||||
terminate_protection dd ? ;+176
|
||||
keyboard_mode db ? ;+180
|
||||
rb 3
|
||||
|
||||
+41
-77
@@ -8,8 +8,8 @@
|
||||
|
||||
; diamond, 2006
|
||||
sys_debug_services:
|
||||
cmp ebx, 9
|
||||
ja @f
|
||||
cmp ebx, sys_debug_services_table.count
|
||||
jae @f
|
||||
jmp dword [sys_debug_services_table + ebx*4]
|
||||
@@:
|
||||
ret
|
||||
@@ -26,7 +26,9 @@ sys_debug_services_table:
|
||||
dd debug_write_process_memory
|
||||
dd debug_terminate
|
||||
dd debug_set_drx
|
||||
.count = ($ - sys_debug_services_table)/4
|
||||
endg
|
||||
|
||||
debug_set_event_data:
|
||||
; in: ecx = pointer
|
||||
; destroys eax
|
||||
@@ -34,22 +36,20 @@ debug_set_event_data:
|
||||
mov [eax + APPDATA.dbg_event_mem], ecx
|
||||
ret
|
||||
|
||||
get_debuggee_slot:
|
||||
get_debuggee_thread:
|
||||
; in: ecx=PID
|
||||
; out: CF=1 if error
|
||||
; CF=0 and eax=slot*0x20 if ok
|
||||
; CF=0 and eax = pointer to APPDATA if ok
|
||||
; out: interrupts disabled
|
||||
cli
|
||||
mov eax, ecx
|
||||
call pid_to_slot
|
||||
;call pid_to_appdata
|
||||
call pid_to_thread
|
||||
test eax, eax
|
||||
jz .ret_bad
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
|
||||
push ebx
|
||||
mov ebx, [current_slot_idx]
|
||||
cmp [SLOT_BASE + eax + APPDATA.debugger_slot], ebx
|
||||
;cmp [eax + APPDATA.debugger_slot], ebx
|
||||
mov ebx, [current_slot]
|
||||
cmp [eax + APPDATA.debugger_thread], ebx
|
||||
pop ebx
|
||||
jnz .ret_bad
|
||||
; clc ; automatically
|
||||
@@ -61,10 +61,9 @@ get_debuggee_slot:
|
||||
debug_detach:
|
||||
; in: ecx=pid
|
||||
; destroys eax,ebx
|
||||
call get_debuggee_slot
|
||||
call get_debuggee_thread
|
||||
jc .ret
|
||||
and dword [eax + SLOT_BASE + APPDATA.debugger_slot], 0
|
||||
;and dword [eax + APPDATA.debugger_slot], 0
|
||||
and dword [eax + APPDATA.debugger_thread], 0
|
||||
call do_resume
|
||||
.ret:
|
||||
sti
|
||||
@@ -72,40 +71,27 @@ debug_detach:
|
||||
|
||||
debug_terminate:
|
||||
; in: ecx=pid
|
||||
call get_debuggee_slot
|
||||
call get_debuggee_thread
|
||||
jc debug_detach.ret
|
||||
mov ecx, eax
|
||||
|
||||
shr ecx, BSF sizeof.APPDATA
|
||||
;movzx ecx, ch ; del when sysfn_term... will using APPDATA
|
||||
|
||||
; push 2
|
||||
; pop ebx
|
||||
mov edx, esi ; what?
|
||||
movzx ecx, ch ; del when sysfn_term... will using APPDATA
|
||||
jmp sysfn_terminate
|
||||
|
||||
debug_suspend:
|
||||
; in: ecx=pid
|
||||
; destroys eax,ecx
|
||||
; { Patch by Coldy (rev. 7125), reason: http://board.kolibrios.org/viewtopic.php?f=1&t=1712&p=75957#p75957
|
||||
; cli
|
||||
; mov eax, ecx
|
||||
; call pid_to_slot
|
||||
; shl eax, 5
|
||||
; jz .ret
|
||||
call get_debuggee_slot
|
||||
call get_debuggee_thread
|
||||
jc .ret
|
||||
; } End patch
|
||||
mov cl, [SLOT_BASE + eax + APPDATA.state] ; process state
|
||||
;mov cl, [eax + APPDATA.state] ; process state
|
||||
|
||||
mov cl, [eax + APPDATA.state] ; process state
|
||||
test cl, cl
|
||||
jz .1
|
||||
cmp cl, TSTATE_WAITING
|
||||
jnz .ret
|
||||
mov cl, TSTATE_WAIT_SUSPENDED
|
||||
.2:
|
||||
mov [SLOT_BASE + eax + APPDATA.state], cl
|
||||
;mov [eax + APPDATA.state], cl
|
||||
mov [eax + APPDATA.state], cl
|
||||
.ret:
|
||||
sti
|
||||
ret
|
||||
@@ -114,16 +100,14 @@ debug_suspend:
|
||||
jmp .2
|
||||
|
||||
do_resume:
|
||||
mov cl, [SLOT_BASE + eax + APPDATA.state]
|
||||
;mov cl, [eax + APPDATA.state]
|
||||
mov cl, [eax + APPDATA.state]
|
||||
cmp cl, TSTATE_RUN_SUSPENDED
|
||||
jz .1
|
||||
cmp cl, TSTATE_WAIT_SUSPENDED
|
||||
jnz .ret
|
||||
mov cl, TSTATE_WAITING
|
||||
.2:
|
||||
mov [SLOT_BASE + eax + APPDATA.state], cl
|
||||
;mov [eax + APPDATA.state], cl
|
||||
mov [eax + APPDATA.state], cl
|
||||
.ret:
|
||||
ret
|
||||
.1:
|
||||
@@ -133,11 +117,9 @@ do_resume:
|
||||
debug_resume:
|
||||
; in: ecx=pid
|
||||
; destroys eax,ebx
|
||||
cli
|
||||
mov eax, ecx
|
||||
call pid_to_slot
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
jz .ret
|
||||
call get_debuggee_thread
|
||||
jc .ret
|
||||
|
||||
call do_resume
|
||||
.ret:
|
||||
sti
|
||||
@@ -160,21 +142,15 @@ debug_getcontext:
|
||||
inc ebx ; 1 - get sse context
|
||||
; TODO legacy 32-bit FPU/MMX context
|
||||
.std_ctx:
|
||||
call get_debuggee_slot
|
||||
call get_debuggee_thread
|
||||
jc .ret
|
||||
|
||||
shr eax, BSF sizeof.APPDATA
|
||||
;movzx ebp, ah
|
||||
|
||||
cmp eax, [fpu_owner]
|
||||
;cmp ebp, [fpu_owner]
|
||||
jne @f
|
||||
inc bh ; set swap context flag
|
||||
@@:
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
mov edi, esi
|
||||
mov eax, [SLOT_BASE + eax + APPDATA.pl0_stack]
|
||||
;mov eax, [eax + APPDATA.pl0_stack]
|
||||
mov eax, [eax + APPDATA.pl0_stack]
|
||||
lea esi, [eax + RING0_STACK_SIZE]
|
||||
|
||||
.ring0:
|
||||
@@ -240,11 +216,10 @@ debug_setcontext:
|
||||
cmp edx, 28h
|
||||
jnz .ret
|
||||
|
||||
call get_debuggee_slot
|
||||
call get_debuggee_thread
|
||||
jc .stiret
|
||||
; mov esi, edx
|
||||
mov eax, [eax + SLOT_BASE+APPDATA.pl0_stack]
|
||||
;mov eax, [eax + APPDATA.pl0_stack]
|
||||
|
||||
mov eax, [eax + APPDATA.pl0_stack]
|
||||
lea edi, [eax + RING0_STACK_SIZE]
|
||||
|
||||
.ring0:
|
||||
@@ -277,15 +252,16 @@ debug_setcontext:
|
||||
ret
|
||||
|
||||
debug_set_drx:
|
||||
call get_debuggee_slot
|
||||
call get_debuggee_thread
|
||||
jc .errret
|
||||
|
||||
mov ebp, eax
|
||||
lea eax, [eax + SLOT_BASE + APPDATA.dbg_regs]
|
||||
;lea eax, [eax + APPDATA.dbg_regs]
|
||||
lea eax, [eax + APPDATA.dbg_regs]
|
||||
; [eax]=dr0, [eax+4]=dr1, [eax+8]=dr2, [eax+C]=dr3
|
||||
; [eax+10]=dr7
|
||||
cmp esi, OS_BASE
|
||||
jae .errret
|
||||
|
||||
cmp dl, 3
|
||||
ja .errret
|
||||
mov ecx, dr7
|
||||
@@ -306,10 +282,7 @@ debug_set_drx:
|
||||
btr dword [eax + 10h], edx ; clear L<i> bit
|
||||
test byte [eax + 10h], 55h
|
||||
jnz .okret
|
||||
; imul eax, ebp, tss_step/32
|
||||
; and byte [eax + tss_data + TSS._trap], not 1
|
||||
and [SLOT_BASE + ebp + APPDATA.dbg_state], not 1
|
||||
;and [ebp + APPDATA.dbg_state], not 1
|
||||
and [ebp + APPDATA.dbg_state], not 1
|
||||
.okret:
|
||||
and dword [esp + SYSCALL_STACK.eax], 0
|
||||
sti
|
||||
@@ -354,10 +327,7 @@ debug_set_drx:
|
||||
not ebx
|
||||
and [eax + 10h+2], bx
|
||||
or [eax + 10h+2], dx ; set R/W and LEN fields
|
||||
; imul eax, ebp, tss_step/32
|
||||
; or byte [eax + tss_data + TSS._trap], 1
|
||||
or [SLOT_BASE + ebp + APPDATA.dbg_state], 1
|
||||
;or [ebp + APPDATA.dbg_state], 1
|
||||
or [ebp + APPDATA.dbg_state], 1
|
||||
jmp .okret
|
||||
|
||||
debug_read_process_memory:
|
||||
@@ -368,10 +338,9 @@ debug_read_process_memory:
|
||||
; esi=address in debuggee
|
||||
; out: [esp+36]=sizeof(read)
|
||||
; destroys all
|
||||
call get_debuggee_slot
|
||||
call get_debuggee_thread
|
||||
jc .err
|
||||
shr eax, BSF sizeof.APPDATA
|
||||
;movzx eax,ah
|
||||
|
||||
mov ecx, edi
|
||||
call read_process_memory
|
||||
sti
|
||||
@@ -389,10 +358,9 @@ debug_write_process_memory:
|
||||
; esi=address in debuggee
|
||||
; out: [esp+36]=sizeof(write)
|
||||
; destroys all
|
||||
call get_debuggee_slot
|
||||
call get_debuggee_thread
|
||||
jc debug_read_process_memory.err
|
||||
shr eax, BSF sizeof.APPDATA
|
||||
;movzx eax,ah
|
||||
|
||||
mov ecx, edi
|
||||
call write_process_memory
|
||||
sti
|
||||
@@ -400,7 +368,7 @@ debug_write_process_memory:
|
||||
ret
|
||||
|
||||
debugger_notify:
|
||||
; in: eax=debugger slot
|
||||
; in: eax=debugger thread
|
||||
; ecx=size of debug message
|
||||
; [esp+4]..[esp+4+ecx]=message
|
||||
; interrupts must be disabled!
|
||||
@@ -410,9 +378,7 @@ debugger_notify:
|
||||
mov edi, [timer_ticks]
|
||||
add edi, 500 ; 5 sec timeout
|
||||
.1:
|
||||
mov eax, ebp
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
mov esi, [SLOT_BASE + eax + APPDATA.dbg_event_mem]
|
||||
mov esi, [ebp + APPDATA.dbg_event_mem]
|
||||
test esi, esi
|
||||
jz .ret
|
||||
; read buffer header
|
||||
@@ -466,8 +432,6 @@ debugger_notify:
|
||||
pop edx
|
||||
call write_process_memory
|
||||
; new debug event
|
||||
mov eax, ebp
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
or [SLOT_BASE + eax + APPDATA.occurred_events], EVENT_DEBUG
|
||||
or [ebp + APPDATA.occurred_events], EVENT_DEBUG
|
||||
.ret:
|
||||
ret
|
||||
+49
-37
@@ -150,10 +150,10 @@ init_avx512:
|
||||
|
||||
ret
|
||||
|
||||
; param
|
||||
; eax= 512 bytes memory area aligned on a 16-byte boundary
|
||||
|
||||
align 4
|
||||
; @brief Export function - Save FPU context in buffer
|
||||
; @param eax - 512 bytes memory area aligned on a 16-byte boundary
|
||||
; @return not return
|
||||
fpu_save:
|
||||
push ecx
|
||||
push esi
|
||||
@@ -166,7 +166,7 @@ fpu_save:
|
||||
mov edi, eax
|
||||
|
||||
mov ecx, [fpu_owner]
|
||||
mov esi, [current_slot_idx]
|
||||
mov esi, [current_slot]
|
||||
cmp ecx, esi
|
||||
jne .save
|
||||
|
||||
@@ -175,14 +175,11 @@ fpu_save:
|
||||
.save:
|
||||
mov [fpu_owner], esi
|
||||
|
||||
shl ecx, BSF sizeof.APPDATA
|
||||
mov eax, [SLOT_BASE + ecx + APPDATA.fpu_state]
|
||||
|
||||
mov eax, [ecx + APPDATA.fpu_state]
|
||||
call save_context
|
||||
|
||||
; first 512 bytes of XSAVE area have the same format as FXSAVE
|
||||
shl esi, BSF sizeof.APPDATA
|
||||
mov esi, [SLOT_BASE + esi + APPDATA.fpu_state]
|
||||
mov esi, [esi + APPDATA.fpu_state]
|
||||
mov ecx, 512/4
|
||||
cld
|
||||
rep movsd
|
||||
@@ -194,14 +191,16 @@ fpu_save:
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
; @brief Export function - Get size from AVX context
|
||||
; @return size of buffer
|
||||
avx_save_size:
|
||||
mov eax, [xsave_area_size]
|
||||
ret
|
||||
|
||||
; param
|
||||
; eax= avx_save_size() bytes memory area aligned on a 64-byte boundary
|
||||
|
||||
align 4
|
||||
; @brief Export function - Save AVX context in buffer
|
||||
; @param eax - avx_save_size() bytes memory area aligned on a 64-byte boundary
|
||||
; @return not return
|
||||
avx_save:
|
||||
push ecx
|
||||
push esi
|
||||
@@ -214,7 +213,7 @@ avx_save:
|
||||
mov edi, eax
|
||||
|
||||
mov ecx, [fpu_owner]
|
||||
mov esi, [current_slot_idx]
|
||||
mov esi, [current_slot]
|
||||
cmp ecx, esi
|
||||
jne .save
|
||||
|
||||
@@ -223,13 +222,10 @@ avx_save:
|
||||
.save:
|
||||
mov [fpu_owner], esi
|
||||
|
||||
shl ecx, BSF sizeof.APPDATA
|
||||
mov eax, [SLOT_BASE + ecx + APPDATA.fpu_state]
|
||||
|
||||
mov eax, [ecx + APPDATA.fpu_state]
|
||||
call save_context
|
||||
|
||||
shl esi, BSF sizeof.APPDATA
|
||||
mov esi, [SLOT_BASE + esi + APPDATA.fpu_state]
|
||||
mov esi, [esi + APPDATA.fpu_state]
|
||||
mov ecx, [xsave_area_size]
|
||||
add ecx, 3
|
||||
shr ecx, 2
|
||||
@@ -264,9 +260,13 @@ save_fpu_context:
|
||||
|
||||
|
||||
align 4
|
||||
; @brief Export function - Restore FPU context
|
||||
; @param eax - 512 bytes memory area aligned on a 16-byte boundary
|
||||
; @return not return
|
||||
fpu_restore:
|
||||
push ecx
|
||||
push esi
|
||||
push edi
|
||||
|
||||
mov esi, eax
|
||||
|
||||
@@ -274,7 +274,7 @@ fpu_restore:
|
||||
cli
|
||||
|
||||
mov ecx, [fpu_owner]
|
||||
mov eax, [current_slot_idx]
|
||||
mov eax, [current_slot]
|
||||
cmp ecx, eax
|
||||
jne .copy
|
||||
|
||||
@@ -284,6 +284,8 @@ fpu_restore:
|
||||
|
||||
fxrstor [esi]
|
||||
popfd
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
pop ecx
|
||||
ret
|
||||
@@ -291,24 +293,31 @@ fpu_restore:
|
||||
fnclex ;fix possible problems
|
||||
frstor [esi]
|
||||
popfd
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
pop ecx
|
||||
ret
|
||||
.copy:
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
mov edi, [SLOT_BASE + eax + APPDATA.fpu_state]
|
||||
mov edi, [eax + APPDATA.fpu_state]
|
||||
mov ecx, 512/4
|
||||
cld
|
||||
rep movsd
|
||||
popfd
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
pop ecx
|
||||
ret
|
||||
|
||||
align 4
|
||||
; @brief Export function - Restore AVX context
|
||||
; @param eax - avx_save_size() bytes memory area aligned on a 64-byte boundary
|
||||
; @return not return
|
||||
avx_restore:
|
||||
push ecx
|
||||
push esi
|
||||
push edi
|
||||
|
||||
mov esi, eax
|
||||
|
||||
@@ -316,7 +325,7 @@ avx_restore:
|
||||
cli
|
||||
|
||||
mov ecx, [fpu_owner]
|
||||
mov eax, [current_slot_idx]
|
||||
mov eax, [current_slot]
|
||||
cmp ecx, eax
|
||||
jne .copy
|
||||
|
||||
@@ -329,6 +338,8 @@ avx_restore:
|
||||
xrstor [esi]
|
||||
pop edx
|
||||
popfd
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
pop ecx
|
||||
ret
|
||||
@@ -338,6 +349,8 @@ avx_restore:
|
||||
|
||||
fxrstor [esi]
|
||||
popfd
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
pop ecx
|
||||
ret
|
||||
@@ -345,18 +358,21 @@ avx_restore:
|
||||
fnclex ;fix possible problems
|
||||
frstor [esi]
|
||||
popfd
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
pop ecx
|
||||
ret
|
||||
.copy:
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
mov edi, [SLOT_BASE + eax + APPDATA.fpu_state]
|
||||
mov edi, [eax + APPDATA.fpu_state]
|
||||
mov ecx, [xsave_area_size]
|
||||
add ecx, 3
|
||||
shr ecx, 2
|
||||
cld
|
||||
rep movsd
|
||||
popfd
|
||||
|
||||
pop edi
|
||||
pop esi
|
||||
pop ecx
|
||||
ret
|
||||
@@ -370,21 +386,19 @@ except_7: ;#NM exception handler
|
||||
mov es, ax
|
||||
|
||||
mov ebx, [fpu_owner]
|
||||
cmp ebx, [current_slot_idx]
|
||||
cmp ebx, [current_slot]
|
||||
je .exit
|
||||
|
||||
shl ebx, BSF sizeof.APPDATA
|
||||
mov eax, [SLOT_BASE + ebx + APPDATA.fpu_state]
|
||||
mov eax, [ebx + APPDATA.fpu_state]
|
||||
bt [cpu_caps + (CAPS_OSXSAVE/32)*4], CAPS_OSXSAVE mod 32
|
||||
jnc .no_xsave
|
||||
mov ecx, eax
|
||||
mov eax, [xsave_eax]
|
||||
mov edx, [xsave_edx]
|
||||
xsave [ecx]
|
||||
mov ebx, [current_slot_idx]
|
||||
mov ebx, [current_slot]
|
||||
mov [fpu_owner], ebx
|
||||
shl ebx, BSF sizeof.APPDATA
|
||||
mov ecx, [SLOT_BASE + ebx + APPDATA.fpu_state]
|
||||
mov ecx, [ebx + APPDATA.fpu_state]
|
||||
xrstor [ecx]
|
||||
.exit:
|
||||
restore_ring3_context
|
||||
@@ -394,24 +408,22 @@ except_7: ;#NM exception handler
|
||||
jnc .no_SSE
|
||||
|
||||
fxsave [eax]
|
||||
mov ebx, [current_slot_idx]
|
||||
mov ebx, [current_slot]
|
||||
mov [fpu_owner], ebx
|
||||
shl ebx, BSF sizeof.APPDATA
|
||||
mov eax, [SLOT_BASE + ebx + APPDATA.fpu_state]
|
||||
mov eax, [ebx + APPDATA.fpu_state]
|
||||
fxrstor [eax]
|
||||
restore_ring3_context
|
||||
iret
|
||||
|
||||
.no_SSE:
|
||||
fnsave [eax]
|
||||
mov ebx, [current_slot_idx]
|
||||
mov ebx, [current_slot]
|
||||
mov [fpu_owner], ebx
|
||||
shl ebx, BSF sizeof.APPDATA
|
||||
mov eax, [SLOT_BASE + ebx + APPDATA.fpu_state]
|
||||
mov eax, [ebx + APPDATA.fpu_state]
|
||||
frstor [eax]
|
||||
restore_ring3_context
|
||||
iret
|
||||
|
||||
iglobal
|
||||
fpu_owner dd 2
|
||||
fpu_owner dd APPDATA_OS_THREAD
|
||||
endg
|
||||
@@ -605,7 +605,7 @@ proc page_fault_handler
|
||||
|
||||
mov edi, [.err_addr]
|
||||
and edi, -PAGE_SIZE
|
||||
mov ecx, 1024
|
||||
mov ecx, PAGE_SIZE/4
|
||||
xor eax, eax
|
||||
;cld ;caller is duty for this
|
||||
rep stosd
|
||||
@@ -664,7 +664,7 @@ proc page_fault_handler
|
||||
cmp ebx, tss._io_map_0
|
||||
jb .fail
|
||||
|
||||
cmp ebx, tss._io_map_0+8192
|
||||
cmp ebx, tss._io_map_0 + IO_MAP_SIZE
|
||||
jae .fail
|
||||
|
||||
; io permission map
|
||||
@@ -695,7 +695,7 @@ proc page_fault_handler
|
||||
endp
|
||||
|
||||
; returns number of mapped bytes
|
||||
proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\
|
||||
proc map_mem_ipc stdcall, lin_addr:dword,thread:dword,\
|
||||
ofs:dword,buf_size:dword,req_access:dword
|
||||
locals
|
||||
count dd ?
|
||||
@@ -706,9 +706,8 @@ proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\
|
||||
cmp [buf_size], 0
|
||||
jz .exit
|
||||
|
||||
mov eax, [slot]
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
mov eax, [SLOT_BASE + eax + APPDATA.process]
|
||||
mov eax, [thread]
|
||||
mov eax, [eax + APPDATA.process]
|
||||
test eax, eax
|
||||
jz .exit
|
||||
|
||||
@@ -732,7 +731,7 @@ proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\
|
||||
shr edx, 12
|
||||
and edx, 0x3FF
|
||||
.map:
|
||||
stdcall safe_map_page, [slot], [req_access], [ofs]
|
||||
stdcall safe_map_page, [process], [req_access], [ofs]
|
||||
jnc .exit
|
||||
add [count], PAGE_SIZE
|
||||
add [ofs], PAGE_SIZE
|
||||
@@ -758,7 +757,7 @@ proc map_mem_ipc stdcall, lin_addr:dword,slot:dword,\
|
||||
ret
|
||||
endp
|
||||
|
||||
proc map_memEx stdcall, lin_addr:dword,slot:dword,\
|
||||
proc map_memEx stdcall, lin_addr:dword,thread:dword,\
|
||||
ofs:dword,buf_size:dword,req_access:dword
|
||||
locals
|
||||
count dd ?
|
||||
@@ -769,9 +768,8 @@ proc map_memEx stdcall, lin_addr:dword,slot:dword,\
|
||||
cmp [buf_size], 0
|
||||
jz .exit
|
||||
|
||||
mov eax, [slot]
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
mov eax, [SLOT_BASE + eax + APPDATA.process]
|
||||
mov eax, [thread]
|
||||
mov eax, [eax + APPDATA.process]
|
||||
test eax, eax
|
||||
jz .exit
|
||||
|
||||
@@ -795,7 +793,7 @@ proc map_memEx stdcall, lin_addr:dword,slot:dword,\
|
||||
shr edx, 12
|
||||
and edx, 0x3FF
|
||||
.map:
|
||||
stdcall safe_map_page, [slot], [req_access], [ofs]
|
||||
stdcall safe_map_page, [process], [req_access], [ofs]
|
||||
jnc .exit
|
||||
add [count], PAGE_SIZE
|
||||
add [ofs], PAGE_SIZE
|
||||
@@ -826,7 +824,7 @@ endp
|
||||
; in: edi = linear address to map
|
||||
; out: CF cleared <=> failed
|
||||
; destroys: only eax
|
||||
proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword
|
||||
proc safe_map_page stdcall, process:dword, req_access:dword, ofs:dword
|
||||
mov eax, [esi + edx*4]
|
||||
test al, PG_READ
|
||||
jz .not_present
|
||||
@@ -861,9 +859,7 @@ proc safe_map_page stdcall, slot:dword, req_access:dword, ofs:dword
|
||||
cli
|
||||
cld
|
||||
push ebx ecx
|
||||
mov eax, [slot]
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
mov eax, [SLOT_BASE + eax + APPDATA.process]
|
||||
mov eax, [process]
|
||||
mov eax, [eax + PROC.dlls_list_ptr]
|
||||
test eax, eax
|
||||
jz .no_hdll
|
||||
@@ -953,7 +949,7 @@ sys_IPC:
|
||||
|
||||
proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
|
||||
locals
|
||||
dst_slot dd ?
|
||||
dst_thread dd ?
|
||||
dst_offset dd ?
|
||||
buf_size dd ?
|
||||
used_buf dd ?
|
||||
@@ -963,13 +959,12 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
|
||||
cli
|
||||
|
||||
mov eax, [PID]
|
||||
call pid_to_slot
|
||||
call pid_to_thread
|
||||
test eax, eax
|
||||
jz .no_pid
|
||||
|
||||
mov [dst_slot], eax
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
mov edi, [SLOT_BASE + eax + APPDATA.ipc_start] ;is ipc area defined?
|
||||
mov [dst_thread], eax
|
||||
mov edi, [eax + APPDATA.ipc_start] ;is ipc area defined?
|
||||
test edi, edi
|
||||
jz .no_ipc_area
|
||||
|
||||
@@ -977,7 +972,7 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
|
||||
and ebx, 0xFFF
|
||||
mov [dst_offset], ebx
|
||||
|
||||
mov esi, [SLOT_BASE + eax + APPDATA.ipc_size]
|
||||
mov esi, [eax + APPDATA.ipc_size]
|
||||
mov [buf_size], esi
|
||||
|
||||
mov ecx, [ipc_tmp]
|
||||
@@ -990,7 +985,7 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
|
||||
pop edi esi
|
||||
@@:
|
||||
mov [used_buf], ecx
|
||||
stdcall map_mem_ipc, ecx, [dst_slot], \
|
||||
stdcall map_mem_ipc, ecx, [dst_thread], \
|
||||
edi, esi, PG_SWR
|
||||
|
||||
mov edi, [dst_offset]
|
||||
@@ -1039,9 +1034,8 @@ proc sys_ipc_send stdcall, PID:dword, msg_addr:dword, msg_size:dword
|
||||
mov [page_tabs + ebx*4], eax
|
||||
invlpg [edx]
|
||||
|
||||
mov eax, [dst_slot]
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
or [SLOT_BASE + eax + APPDATA.occurred_events], EVENT_IPC
|
||||
mov eax, [dst_thread]
|
||||
or [eax + APPDATA.occurred_events], EVENT_IPC
|
||||
push 0
|
||||
jmp .ret
|
||||
.no_pid:
|
||||
|
||||
@@ -139,14 +139,13 @@ do_change_task:
|
||||
mov eax, [xsave_eax]
|
||||
mov edx, [xsave_edx]
|
||||
xsave [ecx]
|
||||
mov ecx, [current_slot_idx]
|
||||
mov [fpu_owner], ecx
|
||||
mov ecx, [current_slot]
|
||||
mov [fpu_owner], ecx
|
||||
mov ecx, [ecx + APPDATA.fpu_state]
|
||||
xrstor [ecx]
|
||||
.no_xsave:
|
||||
; set CR0.TS
|
||||
cmp bh, byte[fpu_owner] ;bh == incoming task (new)
|
||||
cmp ebx, [fpu_owner] ;ebx == incoming task (new)
|
||||
clts ;clear a task switch flag
|
||||
je @f
|
||||
mov eax, cr0 ;and set it again if the owner
|
||||
|
||||
+19
-16
@@ -165,7 +165,7 @@ exc_c: ; exceptions (all but 7th - #NM)
|
||||
jnz IRetToUserHook
|
||||
@@:
|
||||
cli
|
||||
mov eax, [esi + APPDATA.debugger_slot]
|
||||
mov eax, [esi + APPDATA.debugger_thread]
|
||||
test eax, eax
|
||||
jnz .debug
|
||||
; not debuggee => say error and terminate
|
||||
@@ -514,28 +514,30 @@ destroy_thread:
|
||||
@@:
|
||||
mov eax, [esi + APPOBJ.fd]
|
||||
test eax, eax
|
||||
jz @F
|
||||
jz @f
|
||||
|
||||
cmp eax, esi
|
||||
je @F
|
||||
je @f
|
||||
|
||||
push esi
|
||||
call [eax + APPOBJ.destroy]
|
||||
DEBUGF 1,"%s",msg_obj_destroy
|
||||
pop esi
|
||||
jmp @B
|
||||
jmp @b
|
||||
@@:
|
||||
mov esi, [.slot]
|
||||
shl esi, BSF sizeof.APPDATA
|
||||
add esi, SLOT_BASE
|
||||
cmp [fpu_owner], esi ; if user fpu last -> fpu user = 2
|
||||
jne @F
|
||||
jne @f
|
||||
|
||||
mov [fpu_owner], 2
|
||||
mov eax, [SLOT_BASE + sizeof.APPDATA*2 + APPDATA.fpu_state]
|
||||
mov [fpu_owner], APPDATA_OS_THREAD
|
||||
mov eax, [APPDATA_OS_THREAD + APPDATA.fpu_state]
|
||||
clts
|
||||
bt [cpu_caps], CAPS_SSE
|
||||
jnc .no_SSE
|
||||
fxrstor [eax]
|
||||
jmp @F
|
||||
jmp @f
|
||||
.no_SSE:
|
||||
fnclex
|
||||
frstor [eax]
|
||||
@@ -544,8 +546,8 @@ destroy_thread:
|
||||
mov [KEY_COUNT], byte 0 ; empty keyboard buffer
|
||||
mov [BTN_COUNT], byte 0 ; empty button buffer
|
||||
|
||||
|
||||
; remove defined hotkeys
|
||||
mov esi, [.slot]
|
||||
mov eax, hotkey_list
|
||||
.loop:
|
||||
cmp [eax+8], esi
|
||||
@@ -638,7 +640,7 @@ destroy_thread:
|
||||
pushad
|
||||
mov edi, esi
|
||||
shl edi, BSF sizeof.APPDATA
|
||||
mov eax, [SLOT_BASE + edi + APPDATA.debugger_slot]
|
||||
mov eax, [SLOT_BASE + edi + APPDATA.debugger_thread]
|
||||
test eax, eax
|
||||
jz .nodebug
|
||||
movi ecx, 8
|
||||
@@ -666,12 +668,12 @@ destroy_thread:
|
||||
add edi, SLOT_BASE
|
||||
|
||||
mov eax, [edi + APPDATA.io_map]
|
||||
cmp eax, [SLOT_BASE + sizeof.APPDATA+APPDATA.io_map]
|
||||
cmp eax, [APPDATA_IDLE_THREAD + APPDATA.io_map]
|
||||
je @F
|
||||
call free_page
|
||||
@@:
|
||||
mov eax, [edi+APPDATA.io_map+4]
|
||||
cmp eax, [SLOT_BASE+sizeof.APPDATA+APPDATA.io_map+4]
|
||||
cmp eax, [APPDATA_IDLE_THREAD + APPDATA.io_map+4]
|
||||
je @F
|
||||
call free_page
|
||||
@@:
|
||||
@@ -712,12 +714,12 @@ destroy_thread:
|
||||
call free_cd_channel
|
||||
and [cd_status], 0
|
||||
@@:
|
||||
pop esi
|
||||
cmp [bgrlockpid], esi
|
||||
jnz @f
|
||||
and [bgrlockpid], 0
|
||||
and [bgrlock], 0
|
||||
@@:
|
||||
pop esi
|
||||
|
||||
pusha ; remove all port reservations
|
||||
mov edx, esi
|
||||
@@ -778,14 +780,15 @@ destroy_thread:
|
||||
|
||||
mov edi, esi ; do not run this process slot
|
||||
shl edi, BSF sizeof.APPDATA
|
||||
mov [SLOT_BASE + edi + APPDATA.state], TSTATE_FREE
|
||||
add edi, SLOT_BASE
|
||||
mov [edi + APPDATA.state], TSTATE_FREE
|
||||
; debugger test - terminate all debuggees
|
||||
mov eax, 2
|
||||
mov ecx, SLOT_BASE + 2*sizeof.APPDATA + APPDATA.debugger_slot
|
||||
mov ecx, APPDATA_OS_THREAD + APPDATA.debugger_thread
|
||||
.xd0:
|
||||
cmp eax, [thread_count]
|
||||
ja .xd1
|
||||
cmp dword [ecx], esi
|
||||
cmp dword [ecx], edi
|
||||
jnz @f
|
||||
and dword [ecx], 0
|
||||
pushad
|
||||
|
||||
@@ -537,21 +537,21 @@ pid_to_slot:
|
||||
align 4
|
||||
proc read_process_memory
|
||||
;Input:
|
||||
; eax - process slot
|
||||
; eax - process thread
|
||||
; ecx - buffer address
|
||||
; edx - buffer size
|
||||
; esi - start address in other process
|
||||
;Output:
|
||||
; eax - number of bytes read.
|
||||
locals
|
||||
slot dd ?
|
||||
thread dd ?
|
||||
buff dd ?
|
||||
r_count dd ?
|
||||
offset dd ?
|
||||
tmp_r_cnt dd ?
|
||||
endl
|
||||
|
||||
mov [slot], eax
|
||||
mov [thread], eax
|
||||
mov [buff], ecx
|
||||
and [r_count], 0
|
||||
mov [tmp_r_cnt], edx
|
||||
@@ -577,7 +577,7 @@ proc read_process_memory
|
||||
|
||||
push ecx
|
||||
stdcall map_memEx, [proc_mem_map], \
|
||||
[slot], ebx, ecx, PG_READ
|
||||
[thread], ebx, ecx, PG_READ
|
||||
pop ecx
|
||||
|
||||
mov esi, [offset]
|
||||
@@ -607,7 +607,7 @@ endp
|
||||
align 4
|
||||
proc write_process_memory
|
||||
;Input:
|
||||
; eax - process slot
|
||||
; eax - process thread
|
||||
; ecx - buffer address
|
||||
; edx - buffer size
|
||||
; esi - start address in other process
|
||||
@@ -615,14 +615,14 @@ proc write_process_memory
|
||||
; eax - number of bytes written
|
||||
|
||||
locals
|
||||
slot dd ?
|
||||
thread dd ?
|
||||
buff dd ?
|
||||
w_count dd ?
|
||||
offset dd ?
|
||||
tmp_w_cnt dd ?
|
||||
endl
|
||||
|
||||
mov [slot], eax
|
||||
mov [thread], eax
|
||||
mov [buff], ecx
|
||||
and [w_count], 0
|
||||
mov [tmp_w_cnt], edx
|
||||
@@ -647,7 +647,7 @@ proc write_process_memory
|
||||
mov ebx, [offset]
|
||||
push ecx
|
||||
stdcall map_memEx, [proc_mem_map], \
|
||||
[slot], ebx, ecx, PG_SWR
|
||||
[thread], ebx, ecx, PG_SWR
|
||||
pop ecx
|
||||
|
||||
mov edi, [offset]
|
||||
@@ -906,7 +906,7 @@ common_app_entry:
|
||||
stdcall free_kernel_space, [ebp+APP_HDR.img_base]
|
||||
stdcall kernel_free, ebp
|
||||
mov ebx, [current_slot]
|
||||
cmp [ebx + APPDATA.debugger_slot], 0
|
||||
cmp [ebx + APPDATA.debugger_thread], 0
|
||||
je .exit
|
||||
mov [ebx + APPDATA.state], TSTATE_RUN_SUSPENDED
|
||||
mov [ebx + APPDATA.state], TSTATE_RUN_SUSPENDED
|
||||
@@ -1054,8 +1054,8 @@ proc set_app_params stdcall,slot:dword, params:dword, flags:dword
|
||||
; set if debuggee
|
||||
test byte [flags], 1
|
||||
jz .no_debug
|
||||
mov eax, [current_slot_idx]
|
||||
mov [SLOT_BASE + ebx + APPDATA.debugger_slot], eax
|
||||
mov eax, [current_slot]
|
||||
mov [SLOT_BASE + ebx + APPDATA.debugger_thread], eax
|
||||
.no_debug:
|
||||
mov [SLOT_BASE + ebx + APPDATA.state], dl
|
||||
lea edx, [SLOT_BASE + ebx]
|
||||
@@ -1074,27 +1074,24 @@ get_curr_slot:
|
||||
mov eax, [current_slot]
|
||||
ret
|
||||
|
||||
pid_to_appdata:
|
||||
;Input:
|
||||
; eax - pid of process
|
||||
;Output:
|
||||
; eax - 0 - not found or pointer on APPDATA
|
||||
; @brief Get pointer to APPDATA by PID
|
||||
; @param eax - TID of thread
|
||||
; @return eax - 0 - not found or pointer on APPDATA
|
||||
pid_to_thread:
|
||||
push ebx
|
||||
push ecx
|
||||
mov ebx, [thread_count]
|
||||
shl ebx, BSF sizeof.APPDATA ; multiply by size
|
||||
; skip first process in the task table
|
||||
mov ecx, SLOT_BASE
|
||||
add ebx, ecx
|
||||
mov ecx, APPDATA_IDLE_THREAD
|
||||
.loop:
|
||||
add ecx, sizeof.APPDATA
|
||||
cmp [ecx + APPDATA.state], TSTATE_FREE
|
||||
jz @f ;skip empty slots
|
||||
cmp [ecx + APPDATA.tid], eax
|
||||
jz .pid_found
|
||||
@@:
|
||||
cmp ecx, ebx
|
||||
jb .loop
|
||||
add ecx, sizeof.APPDATA
|
||||
dec ebx
|
||||
jnz .loop
|
||||
|
||||
pop ecx
|
||||
pop ebx
|
||||
|
||||
@@ -48,7 +48,7 @@ endg
|
||||
|
||||
; This internal function acquires the lock for the global list.
|
||||
lock_timer_list:
|
||||
mov edx, [current_slot_idx]
|
||||
mov edx, [current_slot]
|
||||
@@:
|
||||
xor eax, eax
|
||||
lock cmpxchg [timer_list_owner], edx
|
||||
|
||||
@@ -4148,6 +4148,7 @@ Structure of block of data for folder entry (BDFE):
|
||||
and after archiving this bit is cleared - it can be useful
|
||||
for automatically creating of backup-archives as at writing
|
||||
this bit is usually set
|
||||
* bit 6 (mask 0x40): this is a symbolic link (currently only set by the ext driver).
|
||||
* +4: dword: encoding, equals to field +8 in the information structure
|
||||
* +8: 4*byte: time of file creation
|
||||
* +12 = +0xC: 4*byte: date of file creation
|
||||
|
||||
@@ -212,6 +212,7 @@ DIR_DIRECTORY = 2
|
||||
DIR_SYMLINK = 7
|
||||
KOS_HIDDEN = 2
|
||||
KOS_DIRECTORY = 10h
|
||||
KOS_SYMLINK = 40h
|
||||
READ_ONLY = 1
|
||||
SYMLINK_MAX_DEPTH = 40
|
||||
FAST_SYMLINK_MAX_SIZE = 60
|
||||
@@ -3392,6 +3393,11 @@ ext_ReadFolder:
|
||||
stosd
|
||||
mov eax, [esi+INODE.fileSizeHigh]
|
||||
stosd
|
||||
movzx eax, [esi+INODE.accessMode]
|
||||
and eax, TYPE_MASK
|
||||
cmp eax, FLAG_SYMLINK
|
||||
jne @f
|
||||
or dword [edx], KOS_SYMLINK
|
||||
@@:
|
||||
mov esi, [esp+12]
|
||||
movzx ecx, [esi+DIRENTRY.nameLength]
|
||||
|
||||
@@ -193,7 +193,8 @@ align 4
|
||||
;--------------------------------------
|
||||
align 4
|
||||
@@:
|
||||
mov eax, [current_slot_idx]
|
||||
mov eax, [current_slot]
|
||||
mov eax, [eax + APPDATA.tid]
|
||||
mov [bgrlockpid], eax
|
||||
cmp [img_background], static_background_data
|
||||
jz .nomem
|
||||
@@ -241,7 +242,8 @@ nosb6:
|
||||
jnz nosb7
|
||||
cmp [bgrlock], 0
|
||||
jz .err
|
||||
mov eax, [current_slot_idx]
|
||||
mov eax, [current_slot]
|
||||
mov eax, [eax + APPDATA.tid]
|
||||
cmp [bgrlockpid], eax
|
||||
jnz .err
|
||||
mov eax, ecx
|
||||
|
||||
@@ -1997,6 +1997,8 @@ align 4
|
||||
; esi - slot
|
||||
push eax ecx edx esi
|
||||
xchg eax, esi
|
||||
shl eax, BSF sizeof.APPDATA
|
||||
add eax, SLOT_BASE
|
||||
lea ecx, [esp + 12]
|
||||
mov edx, 1
|
||||
call read_process_memory
|
||||
|
||||
+17
-18
@@ -55,7 +55,6 @@ launcher_start db 1
|
||||
endg
|
||||
|
||||
max_processes = 255
|
||||
tss_step = 128 + 8192 ; tss & i/o - 65535 ports, * 256=557056*4
|
||||
|
||||
os_stack = os_data_l - gdts ; GDTs
|
||||
os_code = os_code_l - gdts
|
||||
@@ -389,7 +388,7 @@ high_code:
|
||||
mov edi, tss._io_map_0
|
||||
xor eax, eax
|
||||
not eax
|
||||
mov ecx, 8192/4
|
||||
mov ecx, IO_MAP_SIZE/4
|
||||
rep stosd ; access to 4096*8=65536 ports
|
||||
|
||||
mov ax, tss0
|
||||
@@ -410,7 +409,7 @@ high_code:
|
||||
stdcall alloc_kernel_space, 0x50000 ; FIXME check size
|
||||
mov [default_io_map], eax
|
||||
|
||||
add eax, 0x2000
|
||||
add eax, IO_MAP_SIZE
|
||||
mov [ipc_tmp], eax
|
||||
mov ebx, 0x1000
|
||||
|
||||
@@ -535,7 +534,7 @@ high_code:
|
||||
dec ecx
|
||||
jns @b
|
||||
|
||||
mov edx, SLOT_BASE + sizeof.APPDATA*1
|
||||
mov edx, APPDATA_IDLE_THREAD
|
||||
mov ebx, [os_stack_seg]
|
||||
add ebx, RING0_STACK_SIZE
|
||||
add ebx, [xsave_area_size]
|
||||
@@ -547,7 +546,7 @@ high_code:
|
||||
mov ecx, IDLE_PRIORITY
|
||||
call scheduler_add_thread
|
||||
|
||||
mov edx, SLOT_BASE + sizeof.APPDATA*2
|
||||
mov edx, APPDATA_OS_THREAD
|
||||
mov ebx, [os_stack_seg]
|
||||
call setup_os_slot
|
||||
mov dword [edx], 'OS'
|
||||
@@ -556,7 +555,7 @@ high_code:
|
||||
|
||||
mov [current_slot_idx], 2
|
||||
mov [thread_count], 2
|
||||
mov [current_slot], SLOT_BASE + sizeof.APPDATA*2
|
||||
mov [current_slot], APPDATA_OS_THREAD
|
||||
|
||||
; Move other CPUs to deep sleep, if it is useful
|
||||
uglobal
|
||||
@@ -848,15 +847,15 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code
|
||||
call reserve_irqs_ports
|
||||
|
||||
mov [SLOT_BASE + APPDATA.window], window_data
|
||||
mov [SLOT_BASE + sizeof.APPDATA + APPDATA.window], window_data + sizeof.WDATA
|
||||
mov [SLOT_BASE + sizeof.APPDATA*2 + APPDATA.window], window_data + sizeof.WDATA*2
|
||||
mov [APPDATA_IDLE_THREAD + APPDATA.window], background_window
|
||||
mov [APPDATA_OS_THREAD + APPDATA.window], window_data + sizeof.WDATA*2
|
||||
mov [window_data + WDATA.thread], SLOT_BASE
|
||||
mov [window_data + sizeof.WDATA + WDATA.thread], SLOT_BASE + sizeof.APPDATA
|
||||
mov [window_data + sizeof.WDATA*2 + WDATA.thread], SLOT_BASE + sizeof.APPDATA*2
|
||||
mov [background_window + WDATA.thread], APPDATA_IDLE_THREAD
|
||||
mov [window_data + sizeof.WDATA*2 + WDATA.thread], APPDATA_OS_THREAD
|
||||
|
||||
call init_display
|
||||
mov eax, [def_cursor]
|
||||
mov [window_data + sizeof.WDATA + WDATA.cursor], eax
|
||||
mov [background_window + WDATA.cursor], eax
|
||||
mov [window_data + sizeof.WDATA*2 + WDATA.cursor], eax
|
||||
|
||||
; PRINT CPU FREQUENCY
|
||||
@@ -953,14 +952,14 @@ include "detect/vortex86.inc" ; Vortex86 SoC detection code
|
||||
; Protect I/O permission map
|
||||
|
||||
mov esi, [default_io_map]
|
||||
stdcall map_page, esi, [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map], PG_READ
|
||||
stdcall map_page, esi, [APPDATA_IDLE_THREAD + APPDATA.io_map], PG_READ
|
||||
add esi, 0x1000
|
||||
stdcall map_page, esi, [SLOT_BASE + sizeof.APPDATA + APPDATA.io_map + 4], PG_READ
|
||||
stdcall map_page, esi, [APPDATA_IDLE_THREAD + APPDATA.io_map + 4], PG_READ
|
||||
|
||||
stdcall map_page, tss._io_map_0, \
|
||||
[SLOT_BASE + sizeof.APPDATA + APPDATA.io_map], PG_READ
|
||||
[APPDATA_IDLE_THREAD + APPDATA.io_map], PG_READ
|
||||
stdcall map_page, tss._io_map_1, \
|
||||
[SLOT_BASE + sizeof.APPDATA + APPDATA.io_map + 4], PG_READ
|
||||
[APPDATA_IDLE_THREAD + APPDATA.io_map + 4], PG_READ
|
||||
|
||||
; SET KEYBOARD PARAMETERS
|
||||
mov al, 0xf6 ; reset keyboard, scan enabled
|
||||
@@ -1865,7 +1864,7 @@ sysfn_shutdown: ; 18.9 = system shutdown
|
||||
; out: Z/z -- is/not kernel thread
|
||||
is_kernel_thread:
|
||||
mov eax, [eax + APPDATA.process]
|
||||
cmp eax, [SLOT_BASE + 2*sizeof.APPDATA + APPDATA.process] ; OS
|
||||
cmp eax, [APPDATA_OS_THREAD + APPDATA.process] ; OS
|
||||
ret
|
||||
;------------------------------------------------------------------------------
|
||||
sysfn_terminate: ; 18.2 = TERMINATE
|
||||
@@ -2065,7 +2064,7 @@ sysfn_zmodif:
|
||||
|
||||
;------------------------------------------------------------------------------
|
||||
sysfn_getidletime: ; 18.4 = GET IDLETIME
|
||||
mov eax, [SLOT_BASE + sizeof.APPDATA + APPDATA.cpu_usage]
|
||||
mov eax, [APPDATA_IDLE_THREAD + APPDATA.cpu_usage]
|
||||
mov [esp + SYSCALL_STACK.eax], eax
|
||||
ret
|
||||
;------------------------------------------------------------------------------
|
||||
@@ -2825,7 +2824,7 @@ no_mark_system_shutdown:
|
||||
align 4
|
||||
noshutdown:
|
||||
mov eax, [thread_count] ; termination
|
||||
mov ebx, SLOT_BASE + sizeof.APPDATA + APPDATA.state
|
||||
mov ebx, APPDATA_IDLE_THREAD + APPDATA.state
|
||||
mov esi, 1
|
||||
;--------------------------------------
|
||||
align 4
|
||||
|
||||
@@ -148,9 +148,10 @@ ReadNoteByte:
|
||||
push esi
|
||||
|
||||
mov eax, [pidProcessNote]
|
||||
call pid_to_slot
|
||||
call pid_to_thread
|
||||
test eax, eax
|
||||
jz .failed
|
||||
|
||||
lea ecx, [esp+12]
|
||||
mov edx, 1
|
||||
mov esi, [memAdrNote]
|
||||
|
||||
+1
-1
Submodule programs/cmm updated: 4678e1605d...86b0211da7.
@@ -238,7 +238,6 @@ BEGIN
|
||||
m.active := FALSE;
|
||||
resetTimer;
|
||||
m.tid := 0;
|
||||
G.destroy(m.canvas);
|
||||
K.Exit
|
||||
END exit;
|
||||
|
||||
@@ -250,7 +249,6 @@ BEGIN
|
||||
resetTimer
|
||||
END;
|
||||
m.tid := 0;
|
||||
G.destroy(m.canvas);
|
||||
K.Exit
|
||||
END escape;
|
||||
|
||||
@@ -356,7 +354,6 @@ BEGIN
|
||||
END;
|
||||
temp := m.tid;
|
||||
m.tid := 0;
|
||||
G.destroy(m.canvas);
|
||||
K.ExitID(temp);
|
||||
m.active := FALSE
|
||||
END
|
||||
@@ -512,7 +509,6 @@ BEGIN
|
||||
IF m.parent # NIL THEN
|
||||
temp := m.parent.tid;
|
||||
m.parent.tid := 0;
|
||||
G.destroy(m.parent.canvas);
|
||||
K.ExitID(temp)
|
||||
END;
|
||||
exit(m)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <shell_api.h>
|
||||
|
||||
char shell_getc()
|
||||
int shell_getc()
|
||||
{
|
||||
__shell_init();
|
||||
|
||||
@@ -9,7 +9,7 @@ char shell_getc()
|
||||
__shell_shm->cmd = SHELL_GETC;
|
||||
__SHELL_WAIT();
|
||||
|
||||
return __shell_shm->data[0];
|
||||
return *((int*)__shell_shm->data);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,15 +1,28 @@
|
||||
#include <shell_api.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
void shell_gets(char *str, int n)
|
||||
char *shell_gets(char *str, int n)
|
||||
{
|
||||
__shell_init();
|
||||
|
||||
char *ptr = NULL;
|
||||
if (__shell_is_init == __SHELL_INIT_OK)
|
||||
{
|
||||
__shell_shm->cmd = SHELL_GETS;
|
||||
__SHELL_WAIT();
|
||||
|
||||
strncpy(str, __shell_shm->data, n);
|
||||
|
||||
if (__shell_shm->return_value.str == EOF || !__shell_shm->return_value.str)
|
||||
{
|
||||
ptr = __shell_shm->return_value.str;
|
||||
}
|
||||
else
|
||||
{
|
||||
ptr = str;
|
||||
}
|
||||
}
|
||||
|
||||
return ptr;
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
#include <shell_api.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void shell_printf(const char *format, ...)
|
||||
int shell_printf(const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, format);
|
||||
vsnprintf(__shell_shm->data, sizeof(__shell_shm->data), format, ap);
|
||||
int val = vsnprintf(__shell_shm->data, sizeof(__shell_shm->data), format, ap);
|
||||
__shell_shm->cmd = SHELL_PUTS;
|
||||
va_end(ap);
|
||||
__SHELL_WAIT();
|
||||
return val;
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
#include <shell_api.h>
|
||||
#include <string.h>
|
||||
|
||||
void shell_puts(const char *str)
|
||||
size_t shell_puts(const char *str)
|
||||
{
|
||||
shell_write_string(str, strlen(str));
|
||||
return shell_write_string(str, strlen(str));
|
||||
}
|
||||
@@ -1,22 +1,27 @@
|
||||
#include <shell_api.h>
|
||||
#include <string.h>
|
||||
|
||||
void shell_write_string(const char *s, size_t len)
|
||||
size_t shell_write_string(const char *s, size_t len)
|
||||
{
|
||||
__shell_init();
|
||||
if (__shell_is_init == __SHELL_INIT_OK)
|
||||
{
|
||||
size_t written_bytes = 0;
|
||||
if (len > sizeof(__shell_shm->data) - 1)
|
||||
{
|
||||
shell_write_string(s, sizeof(__shell_shm->data) - 1); // Outputs as much as it can.
|
||||
shell_write_string(s + (sizeof(__shell_shm->data) - 1), len - (sizeof(__shell_shm->data) - 1)); // Outputs the rest.
|
||||
written_bytes += shell_write_string(s, sizeof(__shell_shm->data) - 1); // Outputs as much as it can.
|
||||
written_bytes += shell_write_string(s + (sizeof(__shell_shm->data) - 1), len - (sizeof(__shell_shm->data) - 1)); // Outputs the rest.
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(__shell_shm->data, 0, sizeof(__shell_shm->data)); // without int shell show \t, \n, lose chars and other trash
|
||||
memcpy(__shell_shm->data, s, len);
|
||||
memset(__shell_shm->data, 0, sizeof(__shell_shm->data)); // without int shell show \t, \n, lose chars and other trash
|
||||
memcpy(__shell_shm->data, s, len);
|
||||
__shell_shm->cmd = SHELL_PUTS;
|
||||
__SHELL_WAIT();
|
||||
written_bytes += __shell_shm->return_value.written_bytes;
|
||||
}
|
||||
|
||||
return written_bytes;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -31,9 +31,15 @@ enum __SHELL_INIT_STATE {
|
||||
};
|
||||
|
||||
#pragma pack(push, 1)
|
||||
struct return_value {
|
||||
size_t written_bytes;
|
||||
char* str;
|
||||
};
|
||||
|
||||
struct shell_shm_buffer {
|
||||
uint8_t cmd;
|
||||
char data[SHELL_SHM_MAX - sizeof(((struct shell_shm_buffer*)NULL)->cmd)];
|
||||
char data[SHELL_SHM_MAX - sizeof(((struct shell_shm_buffer*)NULL)->cmd) - sizeof(struct return_value)];
|
||||
struct return_value return_value;
|
||||
};
|
||||
#pragma pack(pop)
|
||||
|
||||
@@ -51,14 +57,14 @@ __EXTERN int shell_ping();
|
||||
__EXTERN unsigned shell_get_pid();
|
||||
__EXTERN void shell_exit();
|
||||
|
||||
__EXTERN char shell_getc();
|
||||
__EXTERN void shell_gets(char* str, int n);
|
||||
__EXTERN int shell_getc();
|
||||
__EXTERN char* shell_gets(char* str, int n);
|
||||
|
||||
__EXTERN void shell_putc(char c);
|
||||
__EXTERN void shell_puts(const char* str);
|
||||
__EXTERN void shell_printf(const char* format, ...);
|
||||
__EXTERN size_t shell_puts(const char* str);
|
||||
__EXTERN int shell_printf(const char* format, ...);
|
||||
|
||||
__EXTERN void shell_write_string(const char* s, size_t len);
|
||||
__EXTERN size_t shell_write_string(const char* s, size_t len);
|
||||
|
||||
__EXTERN void shell_cls();
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
DLLAPI int puts(const char* str);
|
||||
DLLAPI int printf(const char* format, ...);
|
||||
@@ -50,15 +52,23 @@ typedef size_t fpos_t;
|
||||
#define _FILEMODE_R 1 << 0 // Read
|
||||
#define _FILEMODE_W 1 << 1 // Write
|
||||
#define _FILEMODE_A 1 << 2 // Append
|
||||
#define _FILEMODE_PLUS 1 << 3 // Plus
|
||||
#define _FILEFLAG_ERR 1 << 3 // Error
|
||||
#define _FILEFLAG_EOF 1 << 4 // EOF
|
||||
|
||||
typedef struct FILE_s {
|
||||
char* name;
|
||||
fpos_t position;
|
||||
int error;
|
||||
int eof;
|
||||
int mode; // flags _FILEMODE_*
|
||||
int __ungetc_emu_buff; // Uses __ungetc_emu (temporary solution!)
|
||||
union {
|
||||
struct {
|
||||
bool read : 1;
|
||||
bool write : 1;
|
||||
bool append : 1;
|
||||
bool error : 1;
|
||||
bool eof : 1;
|
||||
};
|
||||
uint32_t val; // exist just because tcc won't optimize bitfields
|
||||
} flags;
|
||||
} FILE;
|
||||
|
||||
#define _IOFBF 0
|
||||
@@ -82,7 +92,7 @@ typedef struct FILE_s {
|
||||
#define TMP_MAX FOPEN_MAX
|
||||
|
||||
#define stderr (FILE*)3
|
||||
#define stdin (FILE*)1
|
||||
#define stdin (FILE*)1
|
||||
#define stdout (FILE*)2
|
||||
|
||||
DLLAPI int fgetc(FILE*);
|
||||
|
||||
@@ -61,6 +61,8 @@
|
||||
/* strntold() is used by vsscanf() below; include its definition first */
|
||||
#include "stdlib/strntold.c"
|
||||
#include "stdio/vsscanf.c"
|
||||
#include "stdio/fclose_r.c"
|
||||
#include "stdio/fopen_r.c"
|
||||
|
||||
#include "string/memccpy.c"
|
||||
#include "string/memchr.c"
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#ifndef __LIBC_STDIO_H
|
||||
#define __LIBC_STDIO_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
int fclose_r(FILE* stream);
|
||||
FILE* fopen_r(const char* restrict name, const char* restrict mode, FILE* restrict stream);
|
||||
|
||||
#endif // __LIBC_STDIO_H
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
void clearerr(FILE *stream) {
|
||||
stream->error = 0;
|
||||
stream->eof = 0;
|
||||
void clearerr(FILE* stream)
|
||||
{
|
||||
stream->flags.val &= ~(_FILEFLAG_ERR | _FILEFLAG_EOF);
|
||||
}
|
||||
@@ -1,8 +1,15 @@
|
||||
#include "stddef.h"
|
||||
#include "_stdio.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
int fclose(FILE *stream) {
|
||||
int fclose(FILE* stream)
|
||||
{
|
||||
int err = fclose_r(stream);
|
||||
|
||||
if (err) {
|
||||
return err;
|
||||
}
|
||||
|
||||
free(stream);
|
||||
stream = NULL;
|
||||
return 0;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "_stdio.h"
|
||||
|
||||
int fclose_r(FILE* stream)
|
||||
{
|
||||
if (stream->name) {
|
||||
free(stream->name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int feof(FILE *stream) {
|
||||
return stream->eof;
|
||||
int feof(FILE* stream)
|
||||
{
|
||||
return stream->flags.eof;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int ferror(FILE *stream) {
|
||||
return stream->error;
|
||||
int ferror(FILE* stream)
|
||||
{
|
||||
return stream->flags.error;
|
||||
}
|
||||
@@ -1,7 +1,22 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include "_stdio.h"
|
||||
|
||||
FILE *fopen(const char *restrict _name, const char *restrict _mode) {
|
||||
FILE *out = malloc(sizeof(FILE));
|
||||
return freopen(_name, _mode, out);
|
||||
FILE* fopen(const char* restrict _name, const char* restrict _mode)
|
||||
{
|
||||
FILE* stream = malloc(sizeof(FILE));
|
||||
|
||||
if (stream == NULL) {
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FILE* out = fopen_r(_name, _mode, stream);
|
||||
|
||||
if (out == NULL) {
|
||||
free(stream);
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
#include "_stdio.h"
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/ksys.h>
|
||||
#include <sys/dirent.h>
|
||||
|
||||
/*
|
||||
Open new file
|
||||
*/
|
||||
FILE* fopen_r(const char* restrict _name, const char* restrict _mode, FILE* restrict out)
|
||||
{
|
||||
if (!_name || !_mode || !out) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
bool file_not_exits = false;
|
||||
ksys_bdfe_t info;
|
||||
{
|
||||
int err = _ksys_file_get_info(_name, &info);
|
||||
|
||||
switch (err) {
|
||||
case KSYS_FS_ERR_SUCCESS:
|
||||
|
||||
if (info.attributes & IS_FOLDER) {
|
||||
errno = EISDIR;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
break;
|
||||
case KSYS_FS_ERR_5:
|
||||
file_not_exits = true;
|
||||
break;
|
||||
default:
|
||||
errno = err;
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out->flags.val = 0;
|
||||
out->position = 0;
|
||||
out->name = strdup(_name);
|
||||
|
||||
if (strchr(_mode, 'r')) {
|
||||
out->flags.read = true;
|
||||
|
||||
if (file_not_exits) {
|
||||
errno = ENOENT;
|
||||
free(out->name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
if (strchr(_mode, 'w')) {
|
||||
out->flags.write = true;
|
||||
}
|
||||
if (strchr(_mode, 'a')) {
|
||||
out->flags.val |= _FILEMODE_W | _FILEMODE_A;
|
||||
}
|
||||
if (strchr(_mode, '+')) {
|
||||
out->flags.val |= _FILEMODE_R | _FILEMODE_W;
|
||||
}
|
||||
|
||||
if (out->flags.write) {
|
||||
if (file_not_exits) {
|
||||
int err = _ksys_file_create(_name);
|
||||
if (err != KSYS_FS_ERR_SUCCESS) {
|
||||
errno = err;
|
||||
free(out->name);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (out->flags.append) {
|
||||
out->position = info.size;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -14,7 +14,7 @@ size_t fread(void *restrict ptr, size_t size, size_t nmemb, FILE *restrict strea
|
||||
|
||||
if(size<=0 || nmemb<=0){
|
||||
errno = EINVAL;
|
||||
stream->error=errno;
|
||||
stream->flags.error = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ size_t fread(void *restrict ptr, size_t size, size_t nmemb, FILE *restrict strea
|
||||
return nmemb;
|
||||
}
|
||||
|
||||
if(stream->mode != _FILEMODE_W && stream->mode != _FILEMODE_A){
|
||||
if(stream->flags.read){
|
||||
if(!stream->__ungetc_emu_buff){
|
||||
((char*) ptr)[0]=(char)stream->__ungetc_emu_buff;
|
||||
//debug_printf("Ungetc: %x\n", ((char*) ptr)[0]);
|
||||
@@ -31,10 +31,10 @@ size_t fread(void *restrict ptr, size_t size, size_t nmemb, FILE *restrict strea
|
||||
unsigned status = _ksys_file_read_file(stream->name, stream->position, bytes_count, ptr , &bytes_read);
|
||||
if (status != KSYS_FS_ERR_SUCCESS) {
|
||||
if(status == KSYS_FS_ERR_EOF){
|
||||
stream->eof=1;
|
||||
stream->flags.eof = true;
|
||||
}else{
|
||||
errno = EIO;
|
||||
stream->error = errno;
|
||||
stream->flags.error = true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,62 +1,14 @@
|
||||
#include <stddef.h>
|
||||
#include <sys/ksys.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/dirent.h>
|
||||
#include "_stdio.h"
|
||||
|
||||
FILE* freopen(const char* restrict _name, const char* restrict _mode, FILE* restrict out)
|
||||
{
|
||||
fclose_r(out);
|
||||
|
||||
static FILE* _set_errno(FILE *out, int err){
|
||||
errno = err;
|
||||
if(out){
|
||||
free(out->name);
|
||||
free(out);
|
||||
if (_name == NULL) {
|
||||
_name = out->name;
|
||||
}
|
||||
out = NULL;
|
||||
return out;
|
||||
|
||||
return fopen_r(_name, _mode, out);
|
||||
}
|
||||
|
||||
static void _create_file(char *name, FILE *out){
|
||||
if(_ksys_file_create(name)){
|
||||
_set_errno(out, EIO);
|
||||
}
|
||||
}
|
||||
|
||||
FILE *freopen(const char *restrict _name, const char *restrict _mode, FILE *restrict out) {
|
||||
if(!_name || !_mode || !out){
|
||||
return _set_errno(out, EINVAL);
|
||||
}
|
||||
|
||||
ksys_bdfe_t info;
|
||||
int no_file = _ksys_file_get_info(_name, &info);
|
||||
if(!no_file && info.attributes & IS_FOLDER){
|
||||
return _set_errno(out, EISDIR);
|
||||
}
|
||||
|
||||
out->eof=0;
|
||||
out->error=0;
|
||||
out->position=0;
|
||||
out->name = strdup(_name);
|
||||
|
||||
if (strchr(_mode, 'r')) { out->mode = _FILEMODE_R; }
|
||||
if (strchr(_mode, 'w')) { out->mode = _FILEMODE_W; }
|
||||
if (strchr(_mode, 'a')) { out->mode = _FILEMODE_A; }
|
||||
if (strchr(_mode, '+')) { out->mode |= _FILEMODE_PLUS; }
|
||||
|
||||
if(out->mode & _FILEMODE_A){
|
||||
if(no_file){
|
||||
_create_file(out->name, out);
|
||||
}
|
||||
out->position = info.size;
|
||||
}else if(out->mode & _FILEMODE_W){
|
||||
_create_file(out->name, out);
|
||||
}else if((out->mode & _FILEMODE_R)){
|
||||
if(no_file){
|
||||
_set_errno(out, ENOENT);
|
||||
}
|
||||
}else{
|
||||
_set_errno(out, EINVAL);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
@@ -1,18 +1,19 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/ksys.h>
|
||||
|
||||
int fseek(FILE *stream, long int offset, int whence) {
|
||||
if (whence == SEEK_SET) {
|
||||
stream->position = offset;
|
||||
} else if (whence == SEEK_CUR) {
|
||||
stream->position += offset;
|
||||
} else if (whence == SEEK_END) {
|
||||
ksys_bdfe_t info;
|
||||
if (_ksys_file_get_info(stream->name, &info)) {
|
||||
return -1;
|
||||
}
|
||||
stream->position = info.size + offset;
|
||||
}
|
||||
stream->eof = 0;
|
||||
int fseek(FILE* stream, long int offset, int whence)
|
||||
{
|
||||
if (whence == SEEK_SET) {
|
||||
stream->position = offset;
|
||||
} else if (whence == SEEK_CUR) {
|
||||
stream->position += offset;
|
||||
} else if (whence == SEEK_END) {
|
||||
ksys_bdfe_t info;
|
||||
if (_ksys_file_get_info(stream->name, &info)) {
|
||||
return -1;
|
||||
}
|
||||
stream->position = info.size + offset;
|
||||
}
|
||||
stream->flags.eof = false;
|
||||
return 0;
|
||||
}
|
||||
@@ -1,7 +1,8 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int fsetpos(FILE *stream, const fpos_t *pos) {
|
||||
int fsetpos(FILE* stream, const fpos_t* pos)
|
||||
{
|
||||
stream->position = *pos;
|
||||
stream->eof = 0;
|
||||
stream->flags.eof = false;
|
||||
return 0;
|
||||
}
|
||||
@@ -16,7 +16,7 @@ size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb, FILE* restric
|
||||
|
||||
if (size <= 0 || nmemb <= 0) {
|
||||
errno = EINVAL;
|
||||
stream->error = errno;
|
||||
stream->flags.error = true;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -33,11 +33,11 @@ size_t fwrite(const void* restrict ptr, size_t size, size_t nmemb, FILE* restric
|
||||
return nmemb;
|
||||
}
|
||||
|
||||
if (stream->mode != _FILEMODE_R) {
|
||||
if (stream->flags.write) {
|
||||
unsigned status = _ksys_file_write_file(stream->name, stream->position, bytes_count, ptr, &bytes_written);
|
||||
if (status != KSYS_FS_ERR_SUCCESS) {
|
||||
errno = EIO;
|
||||
stream->error = errno;
|
||||
stream->flags.error = true;
|
||||
return 0;
|
||||
}
|
||||
stream->position += bytes_written;
|
||||
|
||||
@@ -6,22 +6,21 @@ int ungetc(int c, FILE* file)
|
||||
{
|
||||
int res;
|
||||
|
||||
if(!file){
|
||||
errno = EBADF;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if (file->mode != _FILEMODE_R){
|
||||
errno = EACCES;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if (file->position == 0 || c == EOF)
|
||||
{
|
||||
errno = EOF;
|
||||
if (!file) {
|
||||
errno = EBADF;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
|
||||
if (!file->flags.read) {
|
||||
errno = EACCES;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if (file->position == 0 || c == EOF) {
|
||||
errno = EOF;
|
||||
return EOF;
|
||||
}
|
||||
|
||||
file->__ungetc_emu_buff = c;
|
||||
file->position--;
|
||||
return c;
|
||||
|
||||
@@ -3,6 +3,7 @@ public EXPORTS
|
||||
section '.flat' code readable align 16
|
||||
|
||||
include '../../../macros.inc'
|
||||
include '../../../KOSfuncs.inc'
|
||||
include 'strlen.inc'
|
||||
|
||||
MB_FIRST_BUT_ID equ 3 ;идентификатор 1-й кнопки на сообщении
|
||||
@@ -18,14 +19,8 @@ MB_TEXT_OFFSET equ 2 ;ᬥ饭
|
||||
|
||||
align 4
|
||||
start:
|
||||
mov eax,48
|
||||
mov ebx,3
|
||||
mov ecx,sc
|
||||
mov edx,sizeof.system_colors
|
||||
mcall
|
||||
mov eax,40
|
||||
mov ebx,0x27
|
||||
mcall
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_COLORS,sc,sizeof.system_colors
|
||||
mcall SF_SET_EVENTS_MASK, EVM_MOUSE + EVM_BUTTON + EVM_KEY + EVM_REDRAW
|
||||
|
||||
;-- clear id pressed button ---
|
||||
mov ebx,[mb_text]
|
||||
@@ -39,9 +34,7 @@ start:
|
||||
|
||||
align 4
|
||||
red_win:
|
||||
mov eax,12
|
||||
mov ebx,1
|
||||
mcall
|
||||
mcall SF_REDRAW,SSF_BEGIN_DRAW
|
||||
|
||||
xor eax,eax
|
||||
mov bx,word[mb_left]
|
||||
@@ -56,7 +49,7 @@ red_win:
|
||||
add edi,MB_TEXT_OFFSET ;Caption
|
||||
mcall
|
||||
|
||||
mcall 9,mb_procinfo,-1
|
||||
mcall SF_THREAD_INFO,mb_procinfo,-1
|
||||
mov eax,dword[mb_procinfo.client_box.width]
|
||||
|
||||
sub eax,[but_width]
|
||||
@@ -64,7 +57,6 @@ red_win:
|
||||
add eax,MB_BUT_OTX_1
|
||||
mov [ot_left],eax
|
||||
|
||||
mov eax,4 ;рисование текста
|
||||
mov bx,MB_BUT_OTX_1
|
||||
shl ebx,16
|
||||
mov bx,MB_BUT_OTY_1
|
||||
@@ -76,13 +68,12 @@ red_win:
|
||||
call strlen
|
||||
call linlen
|
||||
|
||||
cmp eax,0
|
||||
je @f
|
||||
or eax,eax
|
||||
jz @f
|
||||
|
||||
mov esi,eax
|
||||
push eax
|
||||
mov eax,4
|
||||
int 0x40
|
||||
mcall SF_DRAW_TEXT
|
||||
pop eax
|
||||
|
||||
add edx,eax
|
||||
@@ -95,25 +86,24 @@ red_win:
|
||||
@@:
|
||||
|
||||
call MsgBoxDrawAllBut
|
||||
mcall 12,2
|
||||
mcall SF_REDRAW,SSF_END_DRAW
|
||||
|
||||
align 4
|
||||
still:
|
||||
mov eax,10
|
||||
mcall
|
||||
mcall SF_WAIT_EVENT
|
||||
|
||||
cmp al,1 ;изм. положение окна
|
||||
cmp al,EV_REDRAW
|
||||
jz red_win
|
||||
cmp al,2
|
||||
cmp al,EV_KEY
|
||||
jz key
|
||||
cmp al,3
|
||||
cmp al,EV_BUTTON
|
||||
jz button
|
||||
|
||||
jmp still
|
||||
|
||||
align 4
|
||||
key:
|
||||
mcall 2
|
||||
mcall SF_GET_KEY
|
||||
cmp ah,13
|
||||
jne @f
|
||||
mov ah,[mb_key_foc]
|
||||
@@ -153,7 +143,7 @@ key:
|
||||
|
||||
align 4
|
||||
button:
|
||||
mcall 17 ;получить код нажатой кнопки
|
||||
mcall SF_GET_BUTTON
|
||||
cmp ah,MB_FIRST_BUT_ID
|
||||
jge close
|
||||
cmp ah,1
|
||||
@@ -169,8 +159,8 @@ close:
|
||||
mov byte[ebx],ah
|
||||
|
||||
;*** call msgbox functions ***
|
||||
cmp ah,0
|
||||
je @f
|
||||
or ah,ah
|
||||
jz @f
|
||||
cmp dword[mb_funct],0
|
||||
je @f
|
||||
xor ebx,ebx
|
||||
@@ -182,7 +172,7 @@ close:
|
||||
je @f
|
||||
call dword[ebx]
|
||||
@@:
|
||||
mcall -1 ;выход из программы
|
||||
mcall SF_TERMINATE_PROCESS
|
||||
|
||||
align 4
|
||||
MsgBoxDrawAllBut:
|
||||
@@ -202,8 +192,8 @@ MsgBoxDrawAllBut:
|
||||
mov esi,edx
|
||||
call strlen
|
||||
|
||||
cmp eax,0
|
||||
je @f
|
||||
or eax,eax
|
||||
jz @f
|
||||
|
||||
call MsgBoxDrawButton
|
||||
inc ecx
|
||||
@@ -253,8 +243,7 @@ MsgBoxDrawButton:
|
||||
ror ebx,16
|
||||
mov bx,ax
|
||||
|
||||
mov eax,8
|
||||
int 0x40
|
||||
mcall SF_DEFINE_BUTTON
|
||||
pop edx ebx eax
|
||||
|
||||
;caption
|
||||
@@ -264,8 +253,7 @@ MsgBoxDrawButton:
|
||||
mov ecx,[sc.work_button]
|
||||
@@:
|
||||
mov esi,eax
|
||||
mov eax,4
|
||||
int 0x40
|
||||
mcall SF_DRAW_TEXT
|
||||
|
||||
pop ecx
|
||||
ret
|
||||
@@ -284,6 +272,25 @@ MsgBoxReInit:
|
||||
add esi,eax ;add len of caption
|
||||
mov [txtMsg],esi
|
||||
|
||||
;--- calc window width ---
|
||||
push eax ebx esi
|
||||
.cycle:
|
||||
call strlen
|
||||
mov ebx,eax
|
||||
call linlen
|
||||
add esi,eax
|
||||
sub ebx,eax
|
||||
imul eax,6
|
||||
add eax,10+2*SF_DRAW_TEXT
|
||||
cmp [mb_width],ax
|
||||
jge @f
|
||||
mov [mb_width],ax
|
||||
@@:
|
||||
inc esi
|
||||
cmp ebx,5 ;length of the remaining text
|
||||
jg .cycle
|
||||
pop esi ebx eax
|
||||
|
||||
;--- go to first button text --- buttons 1...MB_MAX_BUT
|
||||
mov ebx,txtBut
|
||||
mov cx,MB_MAX_BUT
|
||||
@@ -320,12 +327,11 @@ MsgBoxReInit:
|
||||
add eax,MB_BUT_HEIGHT
|
||||
add ax,5 ;height of border
|
||||
mov [mb_height],ax
|
||||
mcall 48,4 ;skin height
|
||||
mcall SF_STYLE_SETTINGS,SSF_GET_SKIN_HEIGHT
|
||||
add [mb_height],ax
|
||||
|
||||
;--- calc window top ---
|
||||
mov eax,14
|
||||
int 0x40
|
||||
mcall SF_GET_SCREEN_SIZE
|
||||
mov word[mb_top],ax
|
||||
mov ax,word[mb_height]
|
||||
sub word[mb_top],ax
|
||||
@@ -367,6 +373,7 @@ MsgBoxReInit:
|
||||
|
||||
;input:
|
||||
; [esp+8] = pointer to msgbox text
|
||||
; [esp+12] = thread stack
|
||||
align 4
|
||||
MsgBoxCreate:
|
||||
push ebp
|
||||
@@ -374,11 +381,7 @@ MsgBoxCreate:
|
||||
m2m dword[mb_text],dword[ebp+8]
|
||||
push eax ebx ecx edx
|
||||
|
||||
mov eax,51
|
||||
mov ebx,1
|
||||
mov ecx,start
|
||||
mov edx,dword[ebp+12];thread
|
||||
int 0x40
|
||||
mcall SF_THREAD_CONTROL,SSF_CREATE_THREAD,start,[ebp+12]
|
||||
|
||||
mov dword[mb_funct],0
|
||||
pop edx ecx ebx eax
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
format MS COFF
|
||||
public EXPORTS
|
||||
include '../../../KOSfuncs.inc'
|
||||
section '.flat' code readable align 16
|
||||
; void __stdcall START(dword state);
|
||||
DLL_ENTRY equ 1
|
||||
@@ -60,6 +61,7 @@ START:
|
||||
; SORT_BY_ACCESSED = 12, SORT_BY_ACCESSED_REV = 13 };
|
||||
; int __stdcall sort_dir(BDFE* folder_data, unsigned num_folder_entries, sort_mode mode);
|
||||
; return: 0 = ok, 1 = error
|
||||
align 4
|
||||
sort_dir:
|
||||
cmp dword [esp+12], num_compare_fns
|
||||
jae .error
|
||||
@@ -73,9 +75,9 @@ sort_dir:
|
||||
jz .done
|
||||
cmp eax, ecx
|
||||
jae .memok
|
||||
push 68
|
||||
push SF_SYS_MISC
|
||||
pop eax
|
||||
push 12
|
||||
push SSF_MEM_ALLOC
|
||||
pop ebx
|
||||
int 0x40
|
||||
test eax, eax
|
||||
@@ -103,6 +105,8 @@ sort_dir:
|
||||
pop ecx
|
||||
mov ebx, edx
|
||||
sub esp, 304
|
||||
cld
|
||||
align 4
|
||||
.moveloop:
|
||||
mov esi, [ebx]
|
||||
test esi, esi
|
||||
@@ -139,9 +143,9 @@ sort_dir:
|
||||
.done_free:
|
||||
cmp edx, ptr_table
|
||||
jz .done
|
||||
push 68
|
||||
push SF_SYS_MISC
|
||||
pop eax
|
||||
push 13
|
||||
push SSF_MEM_FREE
|
||||
pop ebx
|
||||
mov ecx, edx
|
||||
int 0x40
|
||||
@@ -269,6 +273,7 @@ compare_name_rev:
|
||||
stc
|
||||
ret
|
||||
|
||||
align 4
|
||||
strcmpi:
|
||||
push eax
|
||||
@@:
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
|
||||
HISTORY:
|
||||
|
||||
4.1.1 (18/09/2026, Leency)
|
||||
bug-fixes:
|
||||
- fixed crash on deleting the whole text (Ctrl+A, Del)
|
||||
|
||||
4.1 (17/07/2015, Pathoswithin)
|
||||
- various fixes
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
; project name: TINYPAD
|
||||
; compiler: flat assembler 1.67.21
|
||||
; memory to compile: 3.0/9.0 MBytes (without/with size optimizations)
|
||||
; version: SVN (4.1)
|
||||
; last update: 2015-07-17 (Jul 17, 2015)
|
||||
; version: SVN (4.1.1)
|
||||
; last update: 2026-09-18 (Sep 18, 2026)
|
||||
; minimal kernel: revision #4199 (https://git.kolibrios.org/KolibriOS/kolibrios/src/branch/main/kernel/trunk)
|
||||
;-----------------------------------------------------------------------------
|
||||
; originally by: Ville Michael Turjanmaa >> villemt@aton.co.jyu.fi
|
||||
@@ -40,7 +40,7 @@ include 'tinypad.inc'
|
||||
|
||||
__header '01',1,@CODE,TINYPAD_END,STATIC_MEM_END,MAIN_STACK,@PARAMS,ini_path
|
||||
|
||||
APP_VERSION equ '4.1'
|
||||
APP_VERSION equ '4.1.1'
|
||||
|
||||
TRUE = 1
|
||||
FALSE = 0
|
||||
|
||||
@@ -355,7 +355,7 @@ proc line_add_spaces ;////////////////////////////////////////////////////////
|
||||
; ESI = line offset
|
||||
; ECX = needed line length
|
||||
; Output:
|
||||
; EAX = delta
|
||||
; EAX = delta, CF = 1 on failure
|
||||
;-----------------------------------------------------------------------------
|
||||
xor eax,eax
|
||||
pushad
|
||||
@@ -365,6 +365,7 @@ proc line_add_spaces ;////////////////////////////////////////////////////////
|
||||
sub ecx,edx
|
||||
lea eax,[ecx+sizeof.EDITOR_LINE_DATA]
|
||||
call editor_realloc_lines
|
||||
jc .failed
|
||||
mov [esp+4*7],eax
|
||||
add esi,eax
|
||||
push ecx
|
||||
@@ -388,6 +389,26 @@ proc line_add_spaces ;////////////////////////////////////////////////////////
|
||||
rep stosb
|
||||
.exit:
|
||||
popad
|
||||
clc
|
||||
ret
|
||||
.failed:
|
||||
popad
|
||||
stc
|
||||
ret
|
||||
endp
|
||||
|
||||
;-----------------------------------------------------------------------------
|
||||
proc set_lines_terminator ;///////////////////////////////////////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; Lines buffer is terminated by a line header with zero Size, restore it after
|
||||
; the data has been compacted (line count decreased)
|
||||
;-----------------------------------------------------------------------------
|
||||
push ecx esi
|
||||
mov ecx,[cur_editor.Lines.Count]
|
||||
call get_line_offset
|
||||
mov [esi+EDITOR_LINE_DATA.Size],0
|
||||
mov [esi+EDITOR_LINE_DATA.Flags],0
|
||||
pop esi ecx
|
||||
ret
|
||||
endp
|
||||
|
||||
@@ -408,6 +429,7 @@ proc delete_selection ;///////////////////////////////////////////////////////
|
||||
or [esi+EDITOR_LINE_DATA.Flags],EDITOR_LINE_FLAG_MOFIFIED
|
||||
mov ecx,[sel.begin.x]
|
||||
call line_add_spaces
|
||||
jc .abort
|
||||
add esi,eax
|
||||
lea edi,[esi+sizeof.EDITOR_LINE_DATA]
|
||||
mov ecx,[sel.end.y]
|
||||
@@ -456,6 +478,8 @@ proc delete_selection ;///////////////////////////////////////////////////////
|
||||
rep movsb
|
||||
|
||||
.exit:
|
||||
call set_lines_terminator
|
||||
|
||||
mov eax,[sel.begin.x]
|
||||
mov [cur_editor.Caret.X],eax
|
||||
mov [cur_editor.SelStart.X],eax
|
||||
@@ -478,6 +502,11 @@ proc delete_selection ;///////////////////////////////////////////////////////
|
||||
clc
|
||||
ret
|
||||
|
||||
.abort:
|
||||
popad
|
||||
clc
|
||||
ret
|
||||
|
||||
.exit.2:
|
||||
stc
|
||||
ret
|
||||
|
||||
@@ -993,17 +993,30 @@ endp
|
||||
proc editor_realloc_lines ;///// ADD $DELTA$ TO LINES SIZE ///////////////////
|
||||
;-----------------------------------------------------------------------------
|
||||
; EAX = delta
|
||||
; Output:
|
||||
; EAX = buffer displacement, CF = 1 on failure (buffer left untouched)
|
||||
;-----------------------------------------------------------------------------
|
||||
push ebx ecx
|
||||
mov ebx,[cur_editor.Lines.Size]
|
||||
push ebx
|
||||
add ebx,eax
|
||||
mov eax,[cur_editor.Lines]
|
||||
mov [cur_editor.Lines.Size],ebx
|
||||
mov ecx,eax
|
||||
stdcall mem.ReAlloc,eax,ebx
|
||||
test eax,eax
|
||||
jz .failed
|
||||
add esp,4
|
||||
mov [cur_editor.Lines],eax
|
||||
sub eax,ecx
|
||||
pop ecx ebx
|
||||
clc
|
||||
ret
|
||||
.failed:
|
||||
pop [cur_editor.Lines.Size]
|
||||
xor eax,eax
|
||||
pop ecx ebx
|
||||
stc
|
||||
ret
|
||||
endp
|
||||
|
||||
|
||||
@@ -237,6 +237,7 @@ proc load_from_memory ;///////////////////////////////////////////////////////
|
||||
lea edx,[ebx+ecx]
|
||||
imul ebx,eax,16
|
||||
add ebx,edx
|
||||
add ebx,sizeof.EDITOR_LINE_DATA
|
||||
mov [ebp+EDITOR.Lines.Size],ebx
|
||||
stdcall mem.ReAlloc,[ebp+EDITOR.Lines],ebx
|
||||
mov [ebp+EDITOR.Lines],eax
|
||||
|
||||
@@ -591,10 +591,12 @@ proc key.ctrl_v ;///// PASTE ///////////////////////////////////
|
||||
mov eax,[copy_size]
|
||||
sub eax,sizeof.EDITOR_LINE_DATA
|
||||
call editor_realloc_lines
|
||||
jc .exit_1
|
||||
mov ecx,[cur_editor.Caret.Y]
|
||||
call get_line_offset
|
||||
mov ecx,[cur_editor.Caret.X]
|
||||
call line_add_spaces
|
||||
jc .exit_1
|
||||
pushd [esi+EDITOR_LINE_DATA.Size]
|
||||
push esi
|
||||
lea eax,[esi+ecx+sizeof.EDITOR_LINE_DATA]
|
||||
@@ -692,6 +694,7 @@ proc key.ctrl_d ;///// INSERT SEPARATOR ////////////////////////
|
||||
;---------------------------------------------------------------
|
||||
mov eax,90+sizeof.EDITOR_LINE_DATA
|
||||
call editor_realloc_lines
|
||||
jc .exit
|
||||
|
||||
mov ecx,[cur_editor.Caret.Y]
|
||||
call get_line_offset
|
||||
@@ -748,6 +751,7 @@ proc key.ctrl_y ;///// DELETE CURRENT LINE /////////////////////
|
||||
shr ecx,2
|
||||
cld
|
||||
rep movsd
|
||||
call set_lines_terminator
|
||||
|
||||
pop eax
|
||||
add eax,sizeof.EDITOR_LINE_DATA
|
||||
@@ -1151,6 +1155,7 @@ proc key.del ;///// DELETE NEXT CHAR OR SELECTION //////////////
|
||||
|
||||
.ok.dec.lines:
|
||||
dec [cur_editor.Lines.Count]
|
||||
call set_lines_terminator
|
||||
mov eax,[cur_editor.Lines.Count]
|
||||
cmp [cur_editor.Caret.Y],eax
|
||||
jb @f
|
||||
@@ -1264,6 +1269,7 @@ proc key.tab ;///// TABULATE ///////////////////////////////////
|
||||
push eax
|
||||
call editor_realloc_lines
|
||||
pop eax
|
||||
jc .failed
|
||||
mov ecx,[cur_editor.Caret.Y]
|
||||
call get_line_offset
|
||||
and [esi+EDITOR_LINE_DATA.Flags],not EDITOR_LINE_FLAG_SAVED
|
||||
@@ -1282,6 +1288,7 @@ proc key.tab ;///// TABULATE ///////////////////////////////////
|
||||
push eax
|
||||
mov eax,10
|
||||
call editor_realloc_lines
|
||||
jc .failed.1
|
||||
add esi,eax
|
||||
pop eax
|
||||
pushad
|
||||
@@ -1332,6 +1339,12 @@ proc key.tab ;///// TABULATE ///////////////////////////////////
|
||||
|
||||
.exit:
|
||||
ret
|
||||
|
||||
.failed.1:
|
||||
pop eax
|
||||
.failed:
|
||||
add esp,4*2
|
||||
ret
|
||||
endp
|
||||
|
||||
;---------------------------------------------------------------
|
||||
@@ -1342,6 +1355,7 @@ proc key.return ;///// CARRIAGE RETURN /////////////////////////
|
||||
; so you should do a little more value
|
||||
mov eax,14*100
|
||||
call editor_realloc_lines
|
||||
jc .exit
|
||||
|
||||
mov ecx,[cur_editor.Caret.Y]
|
||||
call get_line_offset
|
||||
|
||||
@@ -51,6 +51,7 @@ include '../../load_lib.mac'
|
||||
include '../../dll.inc'
|
||||
include '../../develop/libraries/libs-dev/libio/libio.inc'
|
||||
include '../../develop/libraries/libs-dev/libimg/libimg.inc'
|
||||
include '../../develop/libraries/box_lib/box_lib.mac'
|
||||
;include '../../debug.inc'
|
||||
|
||||
@use_library mem.Alloc,mem.Free,mem.ReAlloc,dll.Load
|
||||
@@ -63,15 +64,16 @@ ci_offs_skin_w equ 5 ;adjustment to the width of the skin frame
|
||||
ci_offs_skin_h equ 24 ;skin height adjustment
|
||||
|
||||
; main window
|
||||
ci_wnd_min_siz_x equ 585 ;minimum size x
|
||||
ci_wnd_min_siz_y equ 400 ;minimum size y
|
||||
ci_wnd_start_siz_x equ 585
|
||||
ci_wnd_start_siz_y equ 400
|
||||
ci_wnd_min_siz_x equ 510 ;minimum size x
|
||||
ci_wnd_min_siz_y equ 180 ;minimum size y
|
||||
|
||||
; toolbar
|
||||
ci_panel_x_pos equ 0 ;coord. x for panel
|
||||
ci_panel_y_pos equ 20 ;coord. y for panel
|
||||
ci_panel_but_y1 equ ci_panel_y_pos +5 ;y coordinate for 1st row of buttons
|
||||
ci_panel_but_y2 equ ci_panel_y_pos+30 ;y coordinate for 2nd row of buttons
|
||||
ci_palete_y_pos equ ci_panel_y_pos+51 ;y coordinate for color palette
|
||||
ci_panel_zoom_x equ 178 ;x coordinate for zoom bar buttons
|
||||
|
||||
; editor window
|
||||
@@ -80,7 +82,7 @@ ci_edit_wnd_y_pos equ 71 ;y coordinate for editor window
|
||||
ci_edit_wnd_border equ 3 ;frame around the editor window
|
||||
|
||||
; scrolling
|
||||
ci_scroll_dim equ 22 ;scroll sizes
|
||||
ci_scroll_dim equ 16 ;scroll sizes
|
||||
ci_scrollh_coord_x_min equ (ci_edit_wnd_x_pos+3) ;x minimum slider position
|
||||
;horizontal scrolling
|
||||
ci_scrollv_coord_y_min equ (ci_edit_wnd_y_pos+3) ;y minimum slider position
|
||||
@@ -149,6 +151,12 @@ include 'init_data.inc'
|
||||
;OpenDialog initialisation
|
||||
stdcall [OpenDialog_Init], OpenDialog_data
|
||||
stdcall [ColorDialog_Init], ColorDialog_data
|
||||
|
||||
mcall SF_REDRAW,SSF_BEGIN_DRAW
|
||||
mov ebx,50 shl 16 + ci_wnd_start_siz_x
|
||||
mov ecx,50 shl 16 + ci_wnd_start_siz_y
|
||||
mcall SF_CREATE_WINDOW,,,0x73aabbcc,,name_of_program
|
||||
mcall SF_REDRAW,SSF_END_DRAW
|
||||
;---------------------------------------------------------------------
|
||||
|
||||
align 4
|
||||
@@ -161,16 +169,16 @@ align 4
|
||||
still:
|
||||
mcall SF_WAIT_EVENT
|
||||
|
||||
cmp eax,1
|
||||
cmp eax,EV_REDRAW
|
||||
je red
|
||||
|
||||
cmp eax,2
|
||||
cmp eax,EV_KEY
|
||||
je keys
|
||||
|
||||
cmp eax,3
|
||||
cmp eax,EV_BUTTON
|
||||
je buttons
|
||||
|
||||
cmp eax,6
|
||||
cmp eax,EV_MOUSE
|
||||
je mouse
|
||||
|
||||
jmp still
|
||||
@@ -186,7 +194,16 @@ copy_str_1:
|
||||
jnz @b
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
include 'events.inc'
|
||||
;description:
|
||||
; move both scrollbars back to the top left corner (0,0)
|
||||
align 4
|
||||
scrollbar_move_00:
|
||||
and [PosX],0
|
||||
and [PosY],0
|
||||
mov [sb_horizont.position],0
|
||||
mov [sb_vertical.position],0
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
include 'events_of_window.inc'
|
||||
include 'events_of_keys.inc'
|
||||
include 'events_of_buttons.inc'
|
||||
@@ -205,7 +222,6 @@ include 'menu.inc'
|
||||
;-----------------------------------------------------------
|
||||
;------------variables and data of program------------------
|
||||
;-----------------------------------------------------------
|
||||
;sound_havent_memory db 150,64,0
|
||||
|
||||
include 'lib_data.inc'
|
||||
include 'panel_data.inc'
|
||||
@@ -240,6 +256,13 @@ spray_cursor:
|
||||
file 'cursors/spray.cur'
|
||||
zoom_cursor:
|
||||
file 'cursors/zoom.cur'
|
||||
|
||||
align 4
|
||||
scroll_drag dd 0
|
||||
sb_horizont scrollbar ci_wnd_start_siz_x-ci_scroll_dim-2*ci_offs_skin_w,0,\
|
||||
ci_scroll_dim,ci_edit_wnd_y_pos+284, 15, 100,30,0, 0xaaaaaa, 0xcccccc,0, 1
|
||||
sb_vertical scrollbar ci_scroll_dim,ci_wnd_start_siz_x-ci_scroll_dim-2*ci_offs_skin_w,\
|
||||
284,ci_edit_wnd_y_pos, 15, 100,30,0, 0xaaaaaa, 0xcccccc,0, 1
|
||||
;----------------------------------------------------------
|
||||
align 4
|
||||
IM_END:
|
||||
@@ -305,20 +328,6 @@ counter2 rd 1
|
||||
number_panel rd 1
|
||||
number_menu rd 1
|
||||
|
||||
Scroll1CoordinatX rd 1 ;scroll x screen position
|
||||
Scroll1CoordinatY rd 1 ;scroll y screen position
|
||||
Scroll1MaxSizeX rd 1
|
||||
Scroll1MaxSizeY rd 1
|
||||
Scroll1SizeX rd 1 ;scroll polzunok size
|
||||
Scroll1FreeX rd 1
|
||||
|
||||
Scroll2CoordinatX rd 1
|
||||
Scroll2CoordinatY rd 1
|
||||
Scroll2MaxSizeX rd 1
|
||||
Scroll2MaxSizeY rd 1
|
||||
Scroll2SizeY rd 1
|
||||
Scroll2FreeY rd 1
|
||||
|
||||
x rd 1
|
||||
y rd 1
|
||||
|
||||
@@ -366,7 +375,7 @@ filename_area rb 256
|
||||
temp_dir_pach rb 4096
|
||||
library_path rb 4096
|
||||
cur_dir_path rb 4096
|
||||
procinfo: rb 1024
|
||||
procinfo process_information
|
||||
align 4
|
||||
syscolors rb 192
|
||||
syscolors_end:
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
;----------------------------------------------------------
|
||||
;---------------------sound of events----------------------
|
||||
;----------------------------------------------------------
|
||||
align 4
|
||||
sound:
|
||||
mcall SF_SPEAKER_PLAY,55
|
||||
ret
|
||||
|
||||
;----------------------------------------------------------
|
||||
;---------------------user events--------------------------
|
||||
;----------------------------------------------------------
|
||||
|
||||
;description:
|
||||
; перемещение скроллингов в левый верхний угол (0,0)
|
||||
align 4
|
||||
scrollbar_move_00:
|
||||
and [PosX],0
|
||||
and [PosY],0
|
||||
mov [Scroll1CoordinatX],ci_scrollh_coord_x_min
|
||||
mov [Scroll2CoordinatY],ci_scrollv_coord_y_min
|
||||
ret
|
||||
@@ -1,17 +1,22 @@
|
||||
;---------------------------------------------
|
||||
;-------------interraction MOUSE--------------
|
||||
;---------------------------------------------
|
||||
align 4
|
||||
mouse:
|
||||
stdcall [kmainmenu_dispatch_cursorevent], [main_menu]
|
||||
|
||||
or ecx,-1
|
||||
mcall SF_THREAD_INFO,procinfo
|
||||
|
||||
mov eax,[procinfo+70] ;staus of window
|
||||
movzx eax,byte [procinfo.wnd_state]
|
||||
test eax,100b
|
||||
jne still
|
||||
|
||||
call GetMouseClick
|
||||
bt [MouseBut],16
|
||||
jnc @f
|
||||
mov [scroll_drag],0
|
||||
@@:
|
||||
|
||||
call GetMouseCoordinats
|
||||
mov eax,[MouseX]
|
||||
@@ -21,6 +26,11 @@ mouse:
|
||||
add ecx,ci_scrollh_coord_x_min
|
||||
add edx,ci_scrollv_coord_y_min
|
||||
|
||||
cmp [scroll_drag],1
|
||||
je sb_hor_mouse
|
||||
cmp [scroll_drag],2
|
||||
je sb_ver_mouse
|
||||
|
||||
cmp eax,ecx
|
||||
jae mouse_scroll
|
||||
|
||||
@@ -36,105 +46,50 @@ mouse_scroll:
|
||||
|
||||
;call GetMouseCoordinats
|
||||
;interraction with horizontal scroller
|
||||
mov eax,[Scroll1CoordinatX]
|
||||
mov ebx,[Scroll1CoordinatY]
|
||||
movzx eax,[sb_horizont.x_pos]
|
||||
movzx ebx,[sb_horizont.y_pos]
|
||||
mov ecx,[MouseX]
|
||||
mov edx,[MouseY]
|
||||
mov esi,[Scroll1MaxSizeX]
|
||||
mov edi,[Scroll1MaxSizeY]
|
||||
movzx esi,[sb_horizont.x_size]
|
||||
movzx edi,[sb_horizont.y_size]
|
||||
call columnus
|
||||
test eax,eax
|
||||
jz no_horizontal
|
||||
|
||||
mov eax,ci_scrollh_coord_x_min
|
||||
mov ebx,[Scroll1CoordinatY]
|
||||
mov ecx,[Scroll1MaxSizeX]
|
||||
inc ecx
|
||||
mov edx,ci_scroll_dim-6
|
||||
mov esi,7
|
||||
call draw_volume_rectangle ; horizontal scrollbar clear
|
||||
|
||||
mov eax,[MouseX]
|
||||
mov ebx,[Scroll1SizeX]
|
||||
shr ebx,1
|
||||
sub eax,ebx
|
||||
mov ecx,[MouseX]
|
||||
add ecx,ebx
|
||||
mov edx,ci_scrollh_coord_x_min
|
||||
add edx,[Scroll1MaxSizeX]
|
||||
mov [Scroll1CoordinatX],eax
|
||||
sub eax,ci_scrollh_coord_x_min
|
||||
jns no_min_scroll
|
||||
|
||||
mov [Scroll1CoordinatX],ci_scrollh_coord_x_min
|
||||
|
||||
no_min_scroll:
|
||||
cmp ecx,edx
|
||||
jl no_max_scroll
|
||||
|
||||
sub edx,ebx
|
||||
sub edx,ebx
|
||||
mov [Scroll1CoordinatX],edx
|
||||
|
||||
no_max_scroll:
|
||||
mov eax,[Scroll1CoordinatX]
|
||||
sub eax,ci_scrollh_coord_x_min
|
||||
bt [MouseBut],8
|
||||
jnc sb_hor_mouse
|
||||
mov [scroll_drag],1
|
||||
sb_hor_mouse:
|
||||
stdcall [scrollbar_h_mouse],sb_horizont
|
||||
mov eax,[sb_horizont.position]
|
||||
mov ebx,[Picture_SizeX]
|
||||
imul eax,ebx
|
||||
mov ebx,[Scroll1MaxSizeX]
|
||||
mov ebx,[sb_horizont.max_area]
|
||||
cdq
|
||||
idiv ebx
|
||||
mov [PosX],eax
|
||||
jmp no_vertical
|
||||
|
||||
no_horizontal:
|
||||
mov eax,[Scroll2CoordinatX]
|
||||
mov ebx,[Scroll2CoordinatY]
|
||||
movzx eax,[sb_vertical.x_pos]
|
||||
movzx ebx,[sb_vertical.y_pos]
|
||||
mov ecx,[MouseX]
|
||||
mov edx,[MouseY]
|
||||
mov esi,[Scroll2MaxSizeX]
|
||||
mov edi,[Scroll2MaxSizeY]
|
||||
movzx esi,[sb_vertical.x_size]
|
||||
movzx edi,[sb_vertical.y_size]
|
||||
call columnus
|
||||
test eax,eax
|
||||
jz no_vertical
|
||||
|
||||
mov eax,[Scroll2CoordinatX]
|
||||
mov ebx,ci_scrollv_coord_y_min
|
||||
mov ecx,ci_scroll_dim-6
|
||||
mov edx,[Scroll2MaxSizeY]
|
||||
inc edx
|
||||
mov esi,7
|
||||
call draw_volume_rectangle ; vertical scrollbar clear
|
||||
|
||||
mov eax,[MouseY]
|
||||
mov ebx,[Scroll2SizeY]
|
||||
shr ebx,1
|
||||
sub eax,ebx
|
||||
mov ecx,[MouseY]
|
||||
add ecx,ebx
|
||||
mov edx,ci_scrollv_coord_y_min
|
||||
add edx,[Scroll2MaxSizeY]
|
||||
mov [Scroll2CoordinatY],eax
|
||||
|
||||
sub eax,ci_scrollv_coord_y_min
|
||||
jns no_min_scroll2
|
||||
|
||||
mov [Scroll2CoordinatY],ci_scrollv_coord_y_min
|
||||
|
||||
no_min_scroll2:
|
||||
cmp ecx,edx
|
||||
jl no_max_scroll2
|
||||
|
||||
sub edx,ebx
|
||||
sub edx,ebx
|
||||
mov [Scroll2CoordinatY],edx
|
||||
|
||||
no_max_scroll2:
|
||||
mov eax,[Scroll2CoordinatY]
|
||||
sub eax,ci_scrollv_coord_y_min
|
||||
bt [MouseBut],8
|
||||
jnc sb_ver_mouse
|
||||
mov [scroll_drag],2
|
||||
sb_ver_mouse:
|
||||
stdcall [scrollbar_v_mouse],sb_vertical
|
||||
mov eax,[sb_vertical.position]
|
||||
mov ebx,[Picture_SizeY]
|
||||
imul eax,ebx
|
||||
mov ebx,[Scroll2MaxSizeY]
|
||||
mov ebx,[sb_vertical.max_area]
|
||||
cdq
|
||||
idiv ebx
|
||||
mov [PosY],eax
|
||||
|
||||
@@ -4,12 +4,11 @@
|
||||
drawwin:
|
||||
or ecx,-1
|
||||
mcall SF_THREAD_INFO,procinfo
|
||||
mov esi,procinfo
|
||||
|
||||
mov eax,[esi+process_information.box.left]
|
||||
mov ebx,[esi+process_information.box.top]
|
||||
mov ecx,[esi+process_information.box.width]
|
||||
mov edx,[esi+process_information.box.height]
|
||||
mov eax,[procinfo.box.left]
|
||||
mov ebx,[procinfo.box.top]
|
||||
mov ecx,[procinfo.box.width]
|
||||
mov edx,[procinfo.box.height]
|
||||
mov [Window_CordinatX],eax
|
||||
mov [Window_CordinatY],ebx
|
||||
|
||||
@@ -23,6 +22,20 @@ drawwin:
|
||||
@@:
|
||||
mov [Window_SizeX],ecx
|
||||
mov [Window_SizeY],edx
|
||||
; keep the size alone for a rolled up window
|
||||
test [procinfo.wnd_state],byte 100b
|
||||
jnz .no_change
|
||||
cmp ecx,[procinfo.box.width]
|
||||
jne @f
|
||||
cmp edx,[procinfo.box.height]
|
||||
jz .no_change
|
||||
@@:
|
||||
push ecx edx esi
|
||||
mov esi,edx
|
||||
mov edx,ecx
|
||||
mcall SF_CHANGE_WINDOW, -1, -1
|
||||
pop esi edx ecx
|
||||
.no_change:
|
||||
mov [MaxWorkScreen_SizeX],ecx
|
||||
mov [MaxWorkScreen_SizeY],edx
|
||||
sub [MaxWorkScreen_SizeX],ci_edit_wnd_x_pos+2*ci_edit_wnd_border\
|
||||
@@ -51,7 +64,7 @@ no_znak2:
|
||||
add ecx, [Window_SizeY]
|
||||
mcall SF_CREATE_WINDOW,,,0x73aabbcc,,name_of_program
|
||||
|
||||
mov eax,[procinfo+70] ;staus of window
|
||||
movzx eax,byte [procinfo.wnd_state]
|
||||
test eax,100b
|
||||
jne .end
|
||||
|
||||
@@ -81,7 +94,7 @@ no_znak2:
|
||||
add ebx,ci_edit_wnd_x_pos+ci_edit_wnd_border
|
||||
mov edx,[Window_SizeX]
|
||||
sub edx,ebx
|
||||
sub edx,ci_scroll_dim+5-ci_edit_wnd_border
|
||||
sub edx,ci_scroll_dim+5+ci_edit_wnd_border
|
||||
shl ebx,16
|
||||
mov bx,dx ;ширина бордюра
|
||||
|
||||
@@ -113,23 +126,6 @@ no_znak2:
|
||||
;------------------------------------------------
|
||||
mcall ,,<ci_edit_wnd_y_pos,ci_edit_wnd_border> ;бордюр под панелью и над окном
|
||||
;------------------------------------------------
|
||||
mov eax,ci_edit_wnd_x_pos
|
||||
mov ebx,[Window_SizeY]
|
||||
mov ecx,[Window_SizeX]
|
||||
mov edx,ci_scroll_dim
|
||||
mov esi,3
|
||||
sub ecx,ci_scroll_dim+5+ci_edit_wnd_x_pos+ci_offs_skin_w
|
||||
sub ebx,ci_scroll_dim+5+ci_offs_skin_h
|
||||
call draw_volume_rectangle ; horizontal scrollbar border
|
||||
;------------------------------------------------
|
||||
mov eax,[Window_SizeX]
|
||||
mov ebx,ci_edit_wnd_y_pos
|
||||
mov ecx,ci_scroll_dim
|
||||
mov edx,[Window_SizeY]
|
||||
mov esi,3
|
||||
sub eax,ci_scroll_dim+5+ci_offs_skin_w
|
||||
sub edx,ci_scroll_dim+5+ci_edit_wnd_y_pos+ci_offs_skin_h
|
||||
call draw_volume_rectangle ; vertical scrollbar border
|
||||
call draw_scrollers
|
||||
;------------------------------------------------
|
||||
mov eax,[Window_SizeX]
|
||||
|
||||
@@ -2,12 +2,14 @@
|
||||
system_dir_1: db '/sys/lib/libimg.obj',0
|
||||
system_dir_2 db '/sys/lib/proc_lib.obj',0
|
||||
system_dir_3: db '/sys/lib/kmenu.obj',0
|
||||
system_dir_4: db '/sys/lib/box_lib.obj',0
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
l_libs_start:
|
||||
lib1 l_libs system_dir_1+9, library_path, system_dir_1, import_libimg
|
||||
lib2 l_libs system_dir_2+9, library_path, system_dir_2, ProcLib_import
|
||||
lib3 l_libs system_dir_3+9, library_path, system_dir_3, import_libkmenu
|
||||
lib4 l_libs system_dir_4+9, library_path, system_dir_4, import_box_lib
|
||||
end_l_libs:
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
@@ -79,51 +81,7 @@ colordialog_path:
|
||||
|
||||
path4 db '/sys/noname.bmp',0
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
import_libimg:
|
||||
dd alib_init1
|
||||
img_is_img dd aimg_is_img
|
||||
img_info dd aimg_info
|
||||
img_from_file dd aimg_from_file
|
||||
img_to_file dd aimg_to_file
|
||||
img_from_rgb dd aimg_from_rgb
|
||||
img_to_rgb dd aimg_to_rgb
|
||||
img_to_rgb2 dd aimg_to_rgb2
|
||||
img_decode dd aimg_decode
|
||||
img_encode dd aimg_encode
|
||||
img_create dd aimg_create
|
||||
img_destroy dd aimg_destroy
|
||||
img_destroy_layer dd aimg_destroy_layer
|
||||
img_count dd aimg_count
|
||||
img_lock_bits dd aimg_lock_bits
|
||||
img_unlock_bits dd aimg_unlock_bits
|
||||
img_flip dd aimg_flip
|
||||
img_flip_layer dd aimg_flip_layer
|
||||
img_rotate dd aimg_rotate
|
||||
img_rotate_layer dd aimg_rotate_layer
|
||||
img_draw dd aimg_draw
|
||||
dd 0,0
|
||||
alib_init1 db 'lib_init',0
|
||||
aimg_is_img db 'img_is_img',0
|
||||
aimg_info db 'img_info',0
|
||||
aimg_from_file db 'img_from_file',0
|
||||
aimg_to_file db 'img_to_file',0
|
||||
aimg_from_rgb db 'img_from_rgb',0
|
||||
aimg_to_rgb db 'img_to_rgb',0
|
||||
aimg_to_rgb2 db 'img_to_rgb2',0
|
||||
aimg_decode db 'img_decode',0
|
||||
aimg_encode db 'img_encode',0
|
||||
aimg_create db 'img_create',0
|
||||
aimg_destroy db 'img_destroy',0
|
||||
aimg_destroy_layer db 'img_destroy_layer',0
|
||||
aimg_count db 'img_count',0
|
||||
aimg_lock_bits db 'img_lock_bits',0
|
||||
aimg_unlock_bits db 'img_unlock_bits',0
|
||||
aimg_flip db 'img_flip',0
|
||||
aimg_flip_layer db 'img_flip_layer',0
|
||||
aimg_rotate db 'img_rotate',0
|
||||
aimg_rotate_layer db 'img_rotate_layer',0
|
||||
aimg_draw db 'img_draw',0
|
||||
include '../../develop/libraries/libs-dev/libimg/import.inc'
|
||||
|
||||
align 4
|
||||
ProcLib_import:
|
||||
@@ -163,4 +121,6 @@ dd 0,0
|
||||
akmenuitem_new db 'kmenuitem_new',0
|
||||
akmenuitem_delete db 'kmenuitem_delete',0
|
||||
akmenuitem_draw db 'kmenuitem_draw',0
|
||||
|
||||
include '../../develop/libraries/box_lib/import.inc'
|
||||
;---------------------------------------------------------------------
|
||||
@@ -1,7 +1,7 @@
|
||||
;**********************************************************
|
||||
;------------------TEXT DATA-------------------------------
|
||||
;**********************************************************
|
||||
name_of_program db 'ANIMAGE graphics editor v1.52',0
|
||||
name_of_program db 'ANIMAGE graphics editor v1.53',0
|
||||
mouse_pos_x db 'X='
|
||||
mouse_pos_y db 'Y='
|
||||
new_text1 db 'PICTURE SIZE X'
|
||||
|
||||
@@ -58,18 +58,16 @@ PrintMousePos:
|
||||
;----------------------------------------------------------
|
||||
;------------draw lines of scoll---------------------------
|
||||
;----------------------------------------------------------
|
||||
align 4
|
||||
draw_scrollers:
|
||||
mov edi,[CounterX]
|
||||
mov eax,[Scroll1CoordinatX]
|
||||
mov ebx,[Window_SizeY]
|
||||
sub ebx,(ci_scroll_dim-3)+5+ci_offs_skin_h
|
||||
sub ebx,ci_scroll_dim+5+ci_offs_skin_h
|
||||
mov ecx,[Window_SizeX]
|
||||
sub ecx,ci_scroll_dim+5+4+ci_scrollh_coord_x_min+ci_offs_skin_w
|
||||
mov edx,ci_scroll_dim-6
|
||||
mov esi,1
|
||||
mov [Scroll1CoordinatY],ebx
|
||||
mov [Scroll1MaxSizeY],edx
|
||||
mov [Scroll1MaxSizeX],ecx
|
||||
sub ecx,ci_scroll_dim+2+ci_scrollh_coord_x_min+ci_offs_skin_w
|
||||
mov [sb_horizont.y_pos],bx
|
||||
mov [sb_horizont.max_area],ecx
|
||||
mov [sb_horizont.x_size],cx
|
||||
imul ecx,edi
|
||||
push eax ebx edx
|
||||
mov eax,ecx
|
||||
@@ -78,22 +76,15 @@ draw_scrollers:
|
||||
idiv ebx
|
||||
mov ecx,eax
|
||||
pop edx ebx eax
|
||||
mov [Scroll1SizeX],ecx
|
||||
mov edi,[Scroll1MaxSizeX]
|
||||
sub edi,ecx
|
||||
mov [Scroll1FreeX],edi
|
||||
call draw_volume_rectangle ; horizontal scrollbar polzunok
|
||||
mov [sb_horizont.cur_area],ecx
|
||||
|
||||
mov eax,[Window_SizeX]
|
||||
sub eax,(ci_scroll_dim-3)+5+ci_offs_skin_w
|
||||
mov ebx,[Scroll2CoordinatY]
|
||||
mov ecx,ci_scroll_dim-6
|
||||
sub eax,ci_scroll_dim+5+ci_offs_skin_w
|
||||
mov edx,[Window_SizeY]
|
||||
sub edx,ci_scroll_dim+5+4+ci_scrollv_coord_y_min+ci_offs_skin_h
|
||||
mov esi,1
|
||||
mov [Scroll2CoordinatX],eax
|
||||
mov [Scroll2MaxSizeX],ecx
|
||||
mov [Scroll2MaxSizeY],edx
|
||||
sub edx,ci_scroll_dim+2+ci_scrollv_coord_y_min+ci_offs_skin_h
|
||||
mov [sb_vertical.x_pos],ax
|
||||
mov [sb_vertical.max_area],edx
|
||||
mov [sb_vertical.y_size],dx
|
||||
|
||||
imul edx,[CounterY]
|
||||
push eax ebx
|
||||
@@ -103,12 +94,12 @@ draw_scrollers:
|
||||
idiv ebx
|
||||
mov edx,eax
|
||||
pop ebx eax
|
||||
mov [Scroll2SizeY],edx
|
||||
mov edi,[Scroll2MaxSizeY]
|
||||
sub edi,edx
|
||||
mov [Scroll2FreeY],edi
|
||||
call draw_volume_rectangle ; vertical scrollbar polzunok
|
||||
mov [sb_vertical.cur_area],edx
|
||||
|
||||
mov [sb_vertical.all_redraw],1
|
||||
stdcall [scrollbar_v_draw],sb_vertical
|
||||
mov [sb_horizont.all_redraw],1
|
||||
stdcall [scrollbar_h_draw],sb_horizont
|
||||
ret
|
||||
|
||||
button_menu_size_x dd 0
|
||||
|
||||
@@ -474,7 +474,7 @@ system_dir_ProcLib db '/sys/lib/proc_lib.obj',0
|
||||
;---------------------------------------------------------------------
|
||||
l_libs_start:
|
||||
library01 l_libs system_dir_Boxlib+9, library_path, system_dir_Boxlib, \
|
||||
Box_lib_import, plugins_directory
|
||||
import_box_lib, plugins_directory
|
||||
|
||||
library02 l_libs system_dir_Libini+9, library_path, system_dir_Libini, \
|
||||
Libini_import, plugins_directory
|
||||
@@ -728,83 +728,7 @@ aIni_set_int db 'ini_set_int',0
|
||||
aIni_set_color db 'ini_set_color',0
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
Box_lib_import:
|
||||
;init_lib dd a_init
|
||||
;version_lib dd a_version
|
||||
|
||||
edit_box_draw dd aEdit_box_draw
|
||||
edit_box_key dd aEdit_box_key
|
||||
edit_box_mouse dd aEdit_box_mouse
|
||||
;version_ed dd aVersion_ed
|
||||
|
||||
init_checkbox dd aInit_checkbox
|
||||
check_box_draw dd aCheck_box_draw
|
||||
check_box_mouse dd aCheck_box_mouse
|
||||
;version_ch dd aVersion_ch
|
||||
|
||||
option_box_draw dd aOption_box_draw
|
||||
option_box_mouse dd aOption_box_mouse
|
||||
;version_op dd aVersion_op
|
||||
|
||||
scrollbar_ver_draw dd aScrollbar_ver_draw
|
||||
scrollbar_ver_mouse dd aScrollbar_ver_mouse
|
||||
scrollbar_hor_draw dd aScrollbar_hor_draw
|
||||
scrollbar_hor_mouse dd aScrollbar_hor_mouse
|
||||
;version_scrollbar dd aVersion_scrollbar
|
||||
|
||||
dinamic_button_draw dd aDbutton_draw
|
||||
dinamic_button_mouse dd aDbutton_mouse
|
||||
;version_dbutton dd aVersion_dbutton
|
||||
|
||||
menu_bar_draw dd aMenu_bar_draw
|
||||
menu_bar_mouse dd aMenu_bar_mouse
|
||||
menu_bar_activate dd aMenu_bar_activate
|
||||
;version_menu_bar dd aVersion_menu_bar
|
||||
|
||||
;FileBrowser_draw dd aFileBrowser_draw
|
||||
;FileBrowser_mouse dd aFileBrowser_mouse
|
||||
;FileBrowser_key dd aFileBrowser_key
|
||||
;Version_FileBrowser dd aVersion_FileBrowser
|
||||
dd 0
|
||||
dd 0
|
||||
|
||||
;a_init db 'lib_init',0
|
||||
;a_version db 'version',0
|
||||
|
||||
aEdit_box_draw db 'edit_box_draw',0
|
||||
aEdit_box_key db 'edit_box_key',0
|
||||
aEdit_box_mouse db 'edit_box_mouse',0
|
||||
;aVersion_ed db 'version_ed',0
|
||||
|
||||
aInit_checkbox db 'init_checkbox2',0
|
||||
aCheck_box_draw db 'check_box_draw2',0
|
||||
aCheck_box_mouse db 'check_box_mouse2',0
|
||||
;aVersion_ch db 'version_ch2',0
|
||||
|
||||
aOption_box_draw db 'option_box_draw',0
|
||||
aOption_box_mouse db 'option_box_mouse',0
|
||||
;aVersion_op db 'version_op',0
|
||||
|
||||
aScrollbar_ver_draw db 'scrollbar_v_draw',0
|
||||
aScrollbar_ver_mouse db 'scrollbar_v_mouse',0
|
||||
aScrollbar_hor_draw db 'scrollbar_h_draw',0
|
||||
aScrollbar_hor_mouse db 'scrollbar_h_mouse',0
|
||||
;aVersion_scrollbar db 'version_scrollbar',0
|
||||
|
||||
aDbutton_draw db 'dbutton_draw',0
|
||||
aDbutton_mouse db 'dbutton_mouse',0
|
||||
;aVersion_dbutton db 'version_dbutton',0
|
||||
|
||||
aMenu_bar_draw db 'menu_bar_draw',0
|
||||
aMenu_bar_mouse db 'menu_bar_mouse',0
|
||||
aMenu_bar_activate db 'menu_bar_activate',0
|
||||
;aVersion_menu_bar db 'version_menu_bar',0
|
||||
|
||||
;aFileBrowser_draw db 'FileBrowser_draw',0
|
||||
;aFileBrowser_mouse db 'FileBrowser_mouse',0
|
||||
;aFileBrowser_key db 'FileBrowser_key',0
|
||||
;aVersion_FileBrowser db 'version_FileBrowser',0
|
||||
include '../../develop/libraries/box_lib/import.inc'
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
load_directory_pointer dd 0
|
||||
|
||||
@@ -421,8 +421,7 @@ draw_scrollbars:
|
||||
jbe @f
|
||||
cmp [scroll_bar_data_vertical.cur_area],0
|
||||
je @f
|
||||
push dword scroll_bar_data_vertical
|
||||
call [scrollbar_ver_draw]
|
||||
stdcall [scrollbar_v_draw], scroll_bar_data_vertical
|
||||
; draw_scroll_bar_vertical scroll_bar_data_vertical
|
||||
inc [draw_scrollbar_counter]
|
||||
@@:
|
||||
@@ -434,8 +433,7 @@ draw_scrollbars:
|
||||
jbe @f
|
||||
cmp [scroll_bar_data_horizontal.cur_area],0
|
||||
je @f
|
||||
push dword scroll_bar_data_horizontal
|
||||
call [scrollbar_hor_draw]
|
||||
stdcall [scrollbar_h_draw], scroll_bar_data_horizontal
|
||||
; draw_scroll_bar_horizontal scroll_bar_data_horizontal
|
||||
inc [draw_scrollbar_counter]
|
||||
@@:
|
||||
|
||||
@@ -18,49 +18,28 @@ draw_window:
|
||||
|
||||
call draw_other
|
||||
|
||||
push dword menu_data_1
|
||||
call [menu_bar_draw]
|
||||
push dword menu_data_2
|
||||
call [menu_bar_draw]
|
||||
push dword menu_data_3
|
||||
call [menu_bar_draw]
|
||||
push dword menu_data_4
|
||||
call [menu_bar_draw]
|
||||
push dword menu_data_5
|
||||
call [menu_bar_draw]
|
||||
push dword menu_data_6
|
||||
call [menu_bar_draw]
|
||||
stdcall [menu_bar_draw], menu_data_1
|
||||
stdcall [menu_bar_draw], menu_data_2
|
||||
stdcall [menu_bar_draw], menu_data_3
|
||||
stdcall [menu_bar_draw], menu_data_4
|
||||
stdcall [menu_bar_draw], menu_data_5
|
||||
stdcall [menu_bar_draw], menu_data_6
|
||||
|
||||
push dword dinamic_button_data_1
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_2
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_3
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_4
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_5
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_6
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_7
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_8
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_9
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_10
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_11
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_12
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_13
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_14
|
||||
call [dinamic_button_draw]
|
||||
push dword dinamic_button_data_15
|
||||
call [dinamic_button_draw]
|
||||
stdcall [dbutton_draw], dinamic_button_data_1
|
||||
stdcall [dbutton_draw], dinamic_button_data_2
|
||||
stdcall [dbutton_draw], dinamic_button_data_3
|
||||
stdcall [dbutton_draw], dinamic_button_data_4
|
||||
stdcall [dbutton_draw], dinamic_button_data_5
|
||||
stdcall [dbutton_draw], dinamic_button_data_6
|
||||
stdcall [dbutton_draw], dinamic_button_data_7
|
||||
stdcall [dbutton_draw], dinamic_button_data_8
|
||||
stdcall [dbutton_draw], dinamic_button_data_9
|
||||
stdcall [dbutton_draw], dinamic_button_data_10
|
||||
stdcall [dbutton_draw], dinamic_button_data_11
|
||||
stdcall [dbutton_draw], dinamic_button_data_12
|
||||
stdcall [dbutton_draw], dinamic_button_data_13
|
||||
stdcall [dbutton_draw], dinamic_button_data_14
|
||||
stdcall [dbutton_draw], dinamic_button_data_15
|
||||
|
||||
mcall 13,<225,2>,<3,22>,0x677EA0 ;0x052B64
|
||||
mcall ,<280,2>
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
;---------------------------------------------------------------------
|
||||
mouse:
|
||||
mcall 18,7
|
||||
mcall SF_SYSTEM,SSF_GET_ACTIVE_WINDOW
|
||||
cmp [active_process],eax
|
||||
jne still
|
||||
|
||||
mcall 37,7
|
||||
mcall SF_MOUSE_GET,SSF_SCROLL_DATA
|
||||
mov [mouse_scroll_data],eax
|
||||
|
||||
mov eax,[mouse_position]
|
||||
mov [mouse_position_old],eax
|
||||
mcall 37,1
|
||||
mcall SF_MOUSE_GET,SSF_WINDOW_POSITION
|
||||
mov [mouse_position],eax
|
||||
|
||||
mov eax,[mouse_keys]
|
||||
mov [mouse_keys_old],eax
|
||||
mcall 37,2
|
||||
mcall SF_MOUSE_GET,SSF_BUTTON
|
||||
mov [mouse_keys],eax
|
||||
|
||||
cmp [soi],dword 0
|
||||
@@ -32,8 +32,7 @@ mouse:
|
||||
cmp eax,[scroll_bar_data_horizontal.cur_area]
|
||||
jbe .vertical
|
||||
|
||||
push dword scroll_bar_data_horizontal
|
||||
call [scrollbar_hor_mouse]
|
||||
stdcall [scrollbar_h_mouse], scroll_bar_data_horizontal
|
||||
|
||||
; mouse_scroll_bar_horizontal scroll_bar_data_horizontal
|
||||
cmp [scroll_bar_data_horizontal.redraw],0
|
||||
@@ -50,8 +49,7 @@ mouse:
|
||||
cmp eax,[scroll_bar_data_vertical.cur_area]
|
||||
jbe .menu_bar
|
||||
|
||||
push dword scroll_bar_data_vertical
|
||||
call [scrollbar_ver_mouse]
|
||||
stdcall [scrollbar_v_mouse], scroll_bar_data_vertical
|
||||
|
||||
; mouse_scroll_bar_vertical scroll_bar_data_vertical
|
||||
cmp [scroll_bar_data_vertical.redraw],0
|
||||
@@ -83,8 +81,7 @@ mouse:
|
||||
.menu_bar_1:
|
||||
call .set_mouse_flag
|
||||
@@:
|
||||
push dword menu_data_1
|
||||
call [menu_bar_mouse]
|
||||
stdcall [menu_bar_mouse], menu_data_1
|
||||
; mouse_menubar menu_data_1
|
||||
cmp [menu_data_1.click],dword 1
|
||||
jne .menu_bar_2
|
||||
@@ -95,8 +92,7 @@ mouse:
|
||||
;--------------------------------------------
|
||||
.menu_bar_2:
|
||||
; Edit
|
||||
push dword menu_data_2
|
||||
call [menu_bar_mouse]
|
||||
stdcall [menu_bar_mouse], menu_data_2
|
||||
; mouse_menubar menu_data_2
|
||||
cmp [menu_data_2.click],dword 1
|
||||
jne .menu_bar_3
|
||||
@@ -107,8 +103,7 @@ mouse:
|
||||
;--------------------------------------------
|
||||
.menu_bar_3:
|
||||
; View
|
||||
push dword menu_data_3
|
||||
call [menu_bar_mouse]
|
||||
stdcall [menu_bar_mouse], menu_data_3
|
||||
; mouse_menubar menu_data_3
|
||||
cmp [menu_data_3.click],dword 1
|
||||
jne .menu_bar_4
|
||||
@@ -119,8 +114,7 @@ mouse:
|
||||
;--------------------------------------------
|
||||
.menu_bar_4:
|
||||
; Zoom
|
||||
push dword menu_data_4
|
||||
call [menu_bar_mouse]
|
||||
stdcall [menu_bar_mouse], menu_data_4
|
||||
; mouse_menubar menu_data_4
|
||||
cmp [menu_data_4.click],dword 1
|
||||
jne .menu_bar_5
|
||||
@@ -131,8 +125,7 @@ mouse:
|
||||
;--------------------------------------------
|
||||
.menu_bar_5:
|
||||
; Tools
|
||||
push dword menu_data_5
|
||||
call [menu_bar_mouse]
|
||||
stdcall [menu_bar_mouse], menu_data_5
|
||||
; mouse_menubar menu_data_5
|
||||
cmp [menu_data_5.click],dword 1
|
||||
jne .menu_bar_6
|
||||
@@ -143,8 +136,7 @@ mouse:
|
||||
;--------------------------------------------
|
||||
.menu_bar_6:
|
||||
; Help
|
||||
push dword menu_data_6
|
||||
call [menu_bar_mouse]
|
||||
stdcall [menu_bar_mouse], menu_data_6
|
||||
; mouse_menubar menu_data_6
|
||||
cmp [menu_data_6.click],dword 1
|
||||
jne .mouse_dinamic_button
|
||||
@@ -155,8 +147,7 @@ mouse:
|
||||
;---------------------------------------------------
|
||||
.mouse_dinamic_button:
|
||||
; open file
|
||||
push dword dinamic_button_data_1
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_1
|
||||
; mouse_dinamic_button dinamic_button_data_1
|
||||
mov eax,dinamic_button_data_1.click
|
||||
cmp [eax],dword 1
|
||||
@@ -166,8 +157,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; reload file
|
||||
push dword dinamic_button_data_2
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_2
|
||||
; mouse_dinamic_button dinamic_button_data_2
|
||||
mov eax,dinamic_button_data_2.click
|
||||
cmp [eax],dword 1
|
||||
@@ -177,8 +167,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; left limit
|
||||
push dword dinamic_button_data_3
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_3
|
||||
; mouse_dinamic_button dinamic_button_data_3
|
||||
mov eax,dinamic_button_data_3.click
|
||||
cmp [eax],dword 1
|
||||
@@ -188,8 +177,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; left arrow
|
||||
push dword dinamic_button_data_4
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_4
|
||||
; mouse_dinamic_button dinamic_button_data_4
|
||||
mov eax,dinamic_button_data_4.click
|
||||
cmp [eax],dword 1
|
||||
@@ -199,8 +187,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; slide show
|
||||
push dword dinamic_button_data_5
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_5
|
||||
; mouse_dinamic_button dinamic_button_data_5
|
||||
mov eax,dinamic_button_data_5.click
|
||||
cmp [eax],dword 1
|
||||
@@ -210,8 +197,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; right arrow
|
||||
push dword dinamic_button_data_6
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_6
|
||||
; mouse_dinamic_button dinamic_button_data_6
|
||||
mov eax,dinamic_button_data_6.click
|
||||
cmp [eax],dword 1
|
||||
@@ -221,8 +207,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; right limit
|
||||
push dword dinamic_button_data_7
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_7
|
||||
; mouse_dinamic_button dinamic_button_data_7
|
||||
mov eax,dinamic_button_data_7.click
|
||||
cmp [eax],dword 1
|
||||
@@ -232,8 +217,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; zoom +
|
||||
push dword dinamic_button_data_8
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_8
|
||||
; mouse_dinamic_button dinamic_button_data_8
|
||||
mov eax,dinamic_button_data_8.click
|
||||
cmp [eax],dword 1
|
||||
@@ -243,8 +227,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; zoom -
|
||||
push dword dinamic_button_data_9
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_9
|
||||
; mouse_dinamic_button dinamic_button_data_9
|
||||
mov eax,dinamic_button_data_9.click
|
||||
cmp [eax],dword 1
|
||||
@@ -254,8 +237,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; zoom 100%
|
||||
push dword dinamic_button_data_10
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_10
|
||||
; mouse_dinamic_button dinamic_button_data_10
|
||||
mov eax,dinamic_button_data_10.click
|
||||
cmp [eax],dword 1
|
||||
@@ -265,8 +247,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; rotate clockwise
|
||||
push dword dinamic_button_data_11
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_11
|
||||
; mouse_dinamic_button dinamic_button_data_11
|
||||
mov eax,dinamic_button_data_11.click
|
||||
cmp [eax],dword 1
|
||||
@@ -276,8 +257,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; rotate counter-clockwise
|
||||
push dword dinamic_button_data_12
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_12
|
||||
; mouse_dinamic_button dinamic_button_data_12
|
||||
mov eax,dinamic_button_data_12.click
|
||||
cmp [eax],dword 1
|
||||
@@ -287,8 +267,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; file information
|
||||
push dword dinamic_button_data_13
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_13
|
||||
; mouse_dinamic_button dinamic_button_data_13
|
||||
mov eax,dinamic_button_data_13.click
|
||||
cmp [eax],dword 1
|
||||
@@ -298,8 +277,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; wallpaper
|
||||
push dword dinamic_button_data_14
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_14
|
||||
; mouse_dinamic_button dinamic_button_data_14
|
||||
mov eax,dinamic_button_data_14.click
|
||||
cmp [eax],dword 1
|
||||
@@ -309,8 +287,7 @@ mouse:
|
||||
;-------------------------------------------------
|
||||
@@:
|
||||
; settings
|
||||
push dword dinamic_button_data_15
|
||||
call [dinamic_button_mouse]
|
||||
stdcall [dbutton_mouse], dinamic_button_data_15
|
||||
; mouse_dinamic_button dinamic_button_data_15
|
||||
mov eax,dinamic_button_data_15.click
|
||||
cmp [eax],dword 1
|
||||
|
||||
@@ -14,6 +14,7 @@ struct thread_data
|
||||
socketnum dd ? ; Commands socket
|
||||
state dd ? ; disconnected/logging in/logged in/..
|
||||
passivesocknum dd ? ; when in passive mode, this is the listening socket
|
||||
pasv_ports_left dd ? ; ports left to try for the current PASV
|
||||
datasocketnum dd ? ; socket used for data transfers
|
||||
permissions dd ? ; read/write/execute/....
|
||||
buffer_ptr dd ?
|
||||
@@ -136,12 +137,48 @@ socketerror:
|
||||
sendFTP "425 Can't open data connection"
|
||||
ret
|
||||
|
||||
align 4
|
||||
; Close the data socket if this thread currently owns one. datasocketnum only
|
||||
; holds a live socket in these two modes; in any other mode it is a handle that
|
||||
; has already been closed or was never opened.
|
||||
close_data_sock:
|
||||
cmp [ebp + thread_data.mode], MODE_PASSIVE_OK
|
||||
je @f
|
||||
cmp [ebp + thread_data.mode], MODE_ACTIVE
|
||||
jne .done
|
||||
@@:
|
||||
mov [ebp + thread_data.mode], MODE_NOTREADY
|
||||
mcall close, [ebp + thread_data.datasocketnum]
|
||||
mov [ebp + thread_data.datasocketnum], -1
|
||||
.done:
|
||||
ret
|
||||
|
||||
align 4
|
||||
; Close the passive listening socket if one is still open. It is open only
|
||||
; while waiting for the client (MODE_PASSIVE_WAIT, MODE_PASSIVE_FAILED) or after
|
||||
; a failed listen, so no data connection exists and the mode drops to NOTREADY.
|
||||
close_pasv_sock:
|
||||
cmp [ebp + thread_data.passivesocknum], -1
|
||||
je .done
|
||||
mcall close, [ebp + thread_data.passivesocknum]
|
||||
mov [ebp + thread_data.passivesocknum], -1
|
||||
mov [ebp + thread_data.mode], MODE_NOTREADY
|
||||
.done:
|
||||
ret
|
||||
|
||||
align 4
|
||||
; A data transfer failed with the file in ebx open: close the file and the data
|
||||
; socket, then report the error.
|
||||
transfer_error:
|
||||
invoke file.close, ebx
|
||||
call close_data_sock
|
||||
jmp socketerror
|
||||
|
||||
align 4
|
||||
abort_transfer:
|
||||
and [ebp + thread_data.permissions], not ABORT
|
||||
mov [ebp + thread_data.mode], MODE_NOTREADY
|
||||
invoke file.close, ebx
|
||||
mcall close, [ebp + thread_data.datasocketnum]
|
||||
call close_data_sock
|
||||
|
||||
sendFTP "530 Transfer aborted"
|
||||
ret
|
||||
@@ -327,7 +364,7 @@ open_datasock:
|
||||
.pasv_ok:
|
||||
mov [ebp + thread_data.datasocketnum], eax
|
||||
mov [ebp + thread_data.mode], MODE_PASSIVE_OK
|
||||
mcall close ; [ebp + thread_data.passivesocknum]
|
||||
mcall close, [ebp + thread_data.passivesocknum]
|
||||
mov [ebp + thread_data.passivesocknum], -1
|
||||
invoke con_write_asciiz, str_datasock
|
||||
|
||||
@@ -691,13 +728,13 @@ cmdLIST:
|
||||
mcall send
|
||||
|
||||
; close the data socket..
|
||||
mov [ebp + thread_data.mode], MODE_NOTREADY
|
||||
mcall close, [ebp + thread_data.datasocketnum]
|
||||
call close_data_sock
|
||||
|
||||
sendFTP "226 List OK"
|
||||
ret
|
||||
|
||||
.nosuchdir:
|
||||
call close_data_sock
|
||||
sendFTP "550 Directory does not exist"
|
||||
ret
|
||||
|
||||
@@ -793,10 +830,9 @@ cmdPASS:
|
||||
align 4
|
||||
cmdPASV:
|
||||
|
||||
; cmp [ebp + thread_data.passivesocknum], -1
|
||||
; je @f
|
||||
; mcall close, [ebp + thread_data.passivesocknum] ; if there is still a socket open, close it
|
||||
; @@:
|
||||
; Drop whatever data connection the previous PASV/PORT left behind
|
||||
call close_data_sock
|
||||
call close_pasv_sock
|
||||
|
||||
; Open a new TCP socket
|
||||
mcall socket, AF_INET4, SOCK_STREAM, 0
|
||||
@@ -812,7 +848,13 @@ cmdPASV:
|
||||
lea edx, [ebp + thread_data.datasock]
|
||||
mov esi, sizeof.thread_data.datasock
|
||||
|
||||
.next_port: ; TODO: break the endless loop
|
||||
movzx eax, word [pasv_end]
|
||||
movzx ebx, word [pasv_start]
|
||||
sub eax, ebx
|
||||
inc eax
|
||||
mov [ebp + thread_data.pasv_ports_left], eax ; number of ports in the range
|
||||
|
||||
.next_port:
|
||||
call nextpasvport
|
||||
mov ax, [pasv_port]
|
||||
xchg al, ah
|
||||
@@ -820,12 +862,23 @@ cmdPASV:
|
||||
|
||||
mcall bind
|
||||
cmp eax, -1
|
||||
je .next_port
|
||||
jne .bound
|
||||
dec dword [ebp + thread_data.pasv_ports_left] ; only count a port once bind failed
|
||||
jnz .next_port
|
||||
|
||||
; No usable port: the range is exhausted, or listen() refused the bound one.
|
||||
; Give up instead of spinning, and drop the socket before answering 425.
|
||||
.fail:
|
||||
call close_data_sock
|
||||
call close_pasv_sock
|
||||
jmp socketerror
|
||||
|
||||
.bound:
|
||||
|
||||
; And set it to listen!
|
||||
mcall listen, , 1
|
||||
cmp eax, -1
|
||||
je socketerror
|
||||
je .fail
|
||||
|
||||
; Tell our thread we are ready to accept incoming calls
|
||||
mov [ebp + thread_data.mode], MODE_PASSIVE_WAIT
|
||||
@@ -932,6 +985,10 @@ cmdPWD:
|
||||
align 4
|
||||
cmdPORT:
|
||||
|
||||
; Drop whatever data connection the previous PASV/PORT left behind
|
||||
call close_data_sock
|
||||
call close_pasv_sock
|
||||
|
||||
; PORT a1,a2,a3,a4,p1,p2
|
||||
; IP address a1.a2.a3.a4, port p1*256+p2
|
||||
|
||||
@@ -972,7 +1029,8 @@ align 4
|
||||
cmdQUIT:
|
||||
|
||||
sendFTP "221 Bye!"
|
||||
mcall close, [ebp + thread_data.datasocketnum]
|
||||
call close_data_sock
|
||||
call close_pasv_sock
|
||||
mcall close, [ebp + thread_data.socketnum]
|
||||
|
||||
add esp, 4 ; get rid of call return address
|
||||
@@ -1035,7 +1093,7 @@ cmdRETR:
|
||||
lea eax, [ebp + thread_data.buffer] ; FIXME: use another buffer!! if we receive something on control connection now, we screw up!
|
||||
invoke file.read, ebx, eax, BUFFERSIZE
|
||||
cmp eax, -1
|
||||
je .cannot_open ; FIXME: this is not the correct error
|
||||
je .read_error ; FIXME: this is not the correct error
|
||||
|
||||
push eax
|
||||
invoke con_write_asciiz, str2
|
||||
@@ -1049,7 +1107,7 @@ cmdRETR:
|
||||
mcall send
|
||||
pop ebx ecx
|
||||
cmp eax, -1
|
||||
je socketerror ; FIXME: not the correct error
|
||||
je transfer_error ; FIXME: not the correct error
|
||||
|
||||
; cmp eax, ecx
|
||||
; jne not_all_byes_sent ; TODO
|
||||
@@ -1061,13 +1119,15 @@ cmdRETR:
|
||||
|
||||
invoke con_write_asciiz, str2b
|
||||
|
||||
mov [ebp + thread_data.mode], MODE_NOTREADY
|
||||
mcall close, [ebp + thread_data.datasocketnum]
|
||||
call close_data_sock
|
||||
|
||||
sendFTP "226 Transfer OK, closing connection"
|
||||
ret
|
||||
|
||||
.read_error:
|
||||
invoke file.close, ebx
|
||||
.cannot_open:
|
||||
call close_data_sock
|
||||
invoke con_set_flags, 0x0c
|
||||
invoke con_write_asciiz, str_notfound
|
||||
invoke con_set_flags, 0x07
|
||||
@@ -1126,7 +1186,14 @@ cmdSTOR:
|
||||
test eax, eax
|
||||
jz .cannot_open
|
||||
|
||||
; STOR replaces the file: drop the previous, possibly longer contents
|
||||
push eax
|
||||
invoke file.truncate, eax
|
||||
pop ebx
|
||||
test eax, eax
|
||||
js .truncate_error
|
||||
|
||||
push ebx
|
||||
sendFTP "150 Here it comes.."
|
||||
pop ebx
|
||||
|
||||
@@ -1142,7 +1209,7 @@ cmdSTOR:
|
||||
mcall recv
|
||||
pop ebx ecx
|
||||
cmp eax, -1
|
||||
je socketerror ; FIXME: not the correct error
|
||||
je transfer_error ; FIXME: not the correct error
|
||||
|
||||
test eax, eax
|
||||
jz @f
|
||||
@@ -1154,7 +1221,7 @@ cmdSTOR:
|
||||
pop edx
|
||||
|
||||
cmp eax, -1
|
||||
je .cannot_open ; FIXME: this is not the correct error
|
||||
je .write_error ; FIXME: this is not the correct error
|
||||
|
||||
invoke con_write_asciiz, str2
|
||||
|
||||
@@ -1170,8 +1237,7 @@ cmdSTOR:
|
||||
|
||||
invoke con_write_asciiz, str2b
|
||||
|
||||
mov [ebp + thread_data.mode], MODE_NOTREADY
|
||||
mcall close, [ebp + thread_data.datasocketnum]
|
||||
call close_data_sock
|
||||
|
||||
|
||||
|
||||
@@ -1185,10 +1251,20 @@ cmdSTOR:
|
||||
sendFTP "226 Transfer OK"
|
||||
ret
|
||||
|
||||
.write_error:
|
||||
invoke file.close, ebx
|
||||
.cannot_open:
|
||||
call close_data_sock
|
||||
sendFTP "550 No create file"
|
||||
ret
|
||||
|
||||
.truncate_error:
|
||||
invoke file.close, ebx
|
||||
mov [ebp + thread_data.mode], MODE_NOTREADY
|
||||
mcall close, [ebp + thread_data.datasocketnum]
|
||||
sendFTP "550 Cannot truncate file"
|
||||
ret
|
||||
|
||||
;------------------------------------------------
|
||||
; "SYST"
|
||||
;
|
||||
|
||||
@@ -172,6 +172,14 @@ start:
|
||||
invoke ini.get_int, path, str_pasv, str_end, 5000
|
||||
mov [pasv_end], ax
|
||||
|
||||
; an inverted range would leave no port to bind, fall back to the defaults
|
||||
mov ax, [pasv_start]
|
||||
cmp ax, [pasv_end]
|
||||
jbe @f
|
||||
mov word [pasv_start], 2000
|
||||
mov word [pasv_end], 5000
|
||||
@@:
|
||||
|
||||
mov [alive], 1
|
||||
|
||||
mainloop:
|
||||
@@ -237,6 +245,7 @@ end if
|
||||
lea eax, [ebp + thread_data.buffer]
|
||||
mov [ebp + thread_data.buffer_ptr], eax
|
||||
mov [ebp + thread_data.passivesocknum], -1
|
||||
mov [ebp + thread_data.datasocketnum], -1
|
||||
|
||||
sendFTP "220 Welcome to KolibriOS FTP daemon" ; fix output code
|
||||
|
||||
@@ -264,7 +273,7 @@ threadloop:
|
||||
je .not_passive
|
||||
mov [ebp + thread_data.datasocketnum], eax
|
||||
mov [ebp + thread_data.mode], MODE_PASSIVE_OK
|
||||
mcall close ; [ebp + thread_data.passivesocknum]
|
||||
mcall close, [ebp + thread_data.passivesocknum]
|
||||
mov [ebp + thread_data.passivesocknum], -1
|
||||
|
||||
invoke con_write_asciiz, str_datasock
|
||||
@@ -447,6 +456,7 @@ import libio,\
|
||||
file.open, 'file_open',\
|
||||
file.read, 'file_read',\
|
||||
file.write, 'file_write',\
|
||||
file.truncate, 'file_truncate',\
|
||||
file.close, 'file_close',\
|
||||
file.find.first, 'file_find_first',\
|
||||
file.find.next, 'file_find_next',\
|
||||
|
||||
@@ -1,2 +1,5 @@
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
tup.rule("kpack.asm", "fasm %f %o " .. tup.getconfig("KPACK_CMD"), "kpack")
|
||||
-- Native host ports (windowless in-place compressor):
|
||||
tup.rule("kpackw.asm", "fasm %f %o", "kpackw.exe") -- Windows PE
|
||||
tup.rule("kpackl.asm", "fasm %f %o", "kpackl") -- Linux ELF32
|
||||
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
# Build the native Linux port of kpack (windowless, in-place compressor).
|
||||
# Self-contained ELF32 - only FASM is needed, no gcc / no linker.
|
||||
fasm kpackl.asm kpackl
|
||||
chmod +x kpackl
|
||||
@@ -0,0 +1,4 @@
|
||||
@echo off
|
||||
rem Build the native Windows port of kpack (no window, drag-and-drop compressor).
|
||||
rem Requires FASM in PATH (or edit the line below to point at fasm.exe).
|
||||
fasm -m 16384 kpackw.asm kpackw.exe
|
||||
@@ -0,0 +1,795 @@
|
||||
; kpackl = Kolibri Packer, native Linux port (no output, in-place compressor)
|
||||
;
|
||||
; Usage: kpackl <file>
|
||||
; The file is compressed in place (overwritten).
|
||||
; If the file name is "kernel.mnt" it is packed with the "Kernel" option
|
||||
; (self-extracting KERNPACK format), otherwise the normal KPCK format is used.
|
||||
; The program prints nothing; on any problem it just leaves the file alone.
|
||||
;
|
||||
; Self-contained ELF32 using raw Linux int 0x80 syscalls - no libc, no linker.
|
||||
; Compression core (LZMA + calltrick) and the self-extractor stub are the
|
||||
; original KolibriOS kpack sources by diamond; only the OS glue is new.
|
||||
|
||||
format ELF executable 3
|
||||
entry _start
|
||||
|
||||
segment readable writeable executable
|
||||
|
||||
use_lzma = 1
|
||||
use_calltrick1 = 40h
|
||||
use_calltrick2 = 80h
|
||||
|
||||
; Linux i386 syscalls
|
||||
sys_exit = 1
|
||||
sys_read = 3
|
||||
sys_write = 4
|
||||
sys_open = 5
|
||||
sys_close = 6
|
||||
sys_lseek = 19
|
||||
sys_mmap2 = 192
|
||||
|
||||
_start:
|
||||
; ---- get the file argument (argv[1]) ------------------------------
|
||||
mov eax, [esp] ; argc
|
||||
cmp eax, 2
|
||||
jb quit
|
||||
mov esi, [esp+8] ; argv[1]
|
||||
mov [infilename], esi
|
||||
; ---- is the base name "kernel.mnt" ? ------------------------------
|
||||
mov ebx, esi ; ebx = start of base name
|
||||
.bn:
|
||||
mov al, [esi]
|
||||
test al, al
|
||||
jz .bn_done
|
||||
cmp al, '/'
|
||||
jne .bn_n
|
||||
inc esi
|
||||
mov ebx, esi
|
||||
jmp .bn
|
||||
.bn_n:
|
||||
inc esi
|
||||
jmp .bn
|
||||
.bn_done:
|
||||
mov esi, ebx
|
||||
mov edi, kernel_name
|
||||
.cmpk:
|
||||
mov al, [esi]
|
||||
mov ah, [edi]
|
||||
test ah, ah
|
||||
jnz .notend
|
||||
test al, al ; kernel_name ended: match iff input ended too
|
||||
jz do_kerpack
|
||||
jmp do_pack
|
||||
.notend:
|
||||
or al, 20h ; tolower (kernel_name is lowercase)
|
||||
cmp al, ah
|
||||
jne do_pack
|
||||
inc esi
|
||||
inc edi
|
||||
jmp .cmpk
|
||||
|
||||
;=====================================================================
|
||||
; helper: allocate ecx bytes -> eax = ptr, or eax = 0 on failure
|
||||
;=====================================================================
|
||||
alloc:
|
||||
push ebx
|
||||
push edx
|
||||
push esi
|
||||
push edi
|
||||
push ebp
|
||||
mov eax, sys_mmap2
|
||||
xor ebx, ebx ; addr = NULL
|
||||
mov edx, 3 ; PROT_READ|PROT_WRITE
|
||||
mov esi, 22h ; MAP_PRIVATE|MAP_ANONYMOUS
|
||||
or edi, -1 ; fd = -1
|
||||
xor ebp, ebp ; offset = 0
|
||||
int 0x80
|
||||
pop ebp
|
||||
pop edi
|
||||
pop esi
|
||||
pop edx
|
||||
pop ebx
|
||||
cmp eax, 0xFFFFF000 ; -4096..-1 == error
|
||||
jb .ok
|
||||
xor eax, eax
|
||||
.ok:
|
||||
ret
|
||||
|
||||
;=====================================================================
|
||||
; Normal packing (KPCK)
|
||||
;=====================================================================
|
||||
do_pack:
|
||||
; open input (O_RDONLY)
|
||||
mov eax, sys_open
|
||||
mov ebx, [infilename]
|
||||
xor ecx, ecx
|
||||
xor edx, edx
|
||||
int 0x80
|
||||
test eax, eax
|
||||
js quit
|
||||
mov [fd], eax
|
||||
; size = lseek(fd, 0, SEEK_END)
|
||||
mov eax, sys_lseek
|
||||
mov ebx, [fd]
|
||||
xor ecx, ecx
|
||||
mov edx, 2
|
||||
int 0x80
|
||||
test eax, eax
|
||||
jle quit
|
||||
mov [insize], eax
|
||||
; rewind
|
||||
mov eax, sys_lseek
|
||||
mov ebx, [fd]
|
||||
xor ecx, ecx
|
||||
xor edx, edx
|
||||
int 0x80
|
||||
; allocate infile
|
||||
mov ecx, [insize]
|
||||
call alloc
|
||||
test eax, eax
|
||||
jz quit
|
||||
mov [infile], eax
|
||||
; read
|
||||
mov eax, sys_read
|
||||
mov ebx, [fd]
|
||||
mov ecx, [infile]
|
||||
mov edx, [insize]
|
||||
int 0x80
|
||||
; close
|
||||
mov eax, sys_close
|
||||
mov ebx, [fd]
|
||||
int 0x80
|
||||
; maximum output size
|
||||
mov eax, [insize]
|
||||
shr eax, 3
|
||||
add eax, [insize]
|
||||
add eax, 400h
|
||||
mov esi, eax ; esi = maxout (preserved across alloc)
|
||||
add eax, eax
|
||||
mov ecx, eax
|
||||
call alloc
|
||||
test eax, eax
|
||||
jz quit
|
||||
mov [outfile], eax
|
||||
mov [outfile1], eax
|
||||
mov [outfilebest], eax
|
||||
add eax, esi
|
||||
mov [outfile2], eax
|
||||
; KPCK header
|
||||
mov eax, [outfile1]
|
||||
mov dword [eax], 'KPCK'
|
||||
mov ecx, [insize]
|
||||
mov [eax+4], ecx
|
||||
; LZMA dictionary size
|
||||
dec ecx
|
||||
bsr eax, ecx
|
||||
inc eax
|
||||
cmp eax, 28
|
||||
jb @f
|
||||
mov eax, 28
|
||||
@@:
|
||||
push eax
|
||||
push eax
|
||||
call lzma_set_dict_size ; ret 4
|
||||
pop ecx
|
||||
mov eax, 1
|
||||
shl eax, cl
|
||||
; workmem
|
||||
imul eax, 19
|
||||
shr eax, 1
|
||||
add eax, 509000h
|
||||
mov ecx, eax
|
||||
call alloc
|
||||
test eax, eax
|
||||
jz quit
|
||||
mov [workmem], eax
|
||||
; first pass: plain LZMA
|
||||
mov eax, [outfile2]
|
||||
mov [outfile], eax
|
||||
xchg eax, edi
|
||||
mov esi, [outfile1]
|
||||
movsd
|
||||
movsd
|
||||
call pk_pack_lzma
|
||||
mov [outsize], eax
|
||||
mov eax, [outfile]
|
||||
mov [outfilebest], eax
|
||||
mov [method], use_lzma
|
||||
; calltrick 1
|
||||
call pk_preprocess_calltrick
|
||||
test eax, eax
|
||||
jz .noct1
|
||||
call pk_set_outfile
|
||||
call pk_pack_lzma
|
||||
add eax, 5
|
||||
cmp eax, [outsize]
|
||||
jae .noct1
|
||||
mov [outsize], eax
|
||||
mov eax, [outfile]
|
||||
mov [outfilebest], eax
|
||||
mov [method], use_lzma or use_calltrick1
|
||||
.noct1:
|
||||
call pk_set_outfile
|
||||
push dword [ctn]
|
||||
movzx eax, byte [cti]
|
||||
push eax
|
||||
call pk_preprocess_calltrick2
|
||||
test eax, eax
|
||||
jz .noct2
|
||||
call pk_set_outfile
|
||||
call pk_pack_lzma
|
||||
add eax, 5
|
||||
cmp eax, [outsize]
|
||||
jae .noct2
|
||||
mov [outsize], eax
|
||||
mov eax, [outfile]
|
||||
mov [outfilebest], eax
|
||||
mov [method], use_lzma or use_calltrick2
|
||||
pop ecx
|
||||
pop ecx
|
||||
push dword [ctn]
|
||||
movzx eax, byte [cti]
|
||||
push eax
|
||||
.noct2:
|
||||
pop eax
|
||||
mov [cti], al
|
||||
pop eax
|
||||
mov [ctn], eax
|
||||
add dword [outsize], 12
|
||||
mov eax, [outsize]
|
||||
cmp eax, [insize]
|
||||
jb .packed_ok
|
||||
jmp quit ; not smaller: leave original
|
||||
.packed_ok:
|
||||
movzx eax, byte [method]
|
||||
mov edi, [outfilebest]
|
||||
mov [edi+8], eax
|
||||
test al, use_calltrick1 or use_calltrick2
|
||||
jz .save
|
||||
mov ecx, [outsize]
|
||||
add ecx, edi
|
||||
mov eax, [ctn]
|
||||
mov [ecx-5], eax
|
||||
mov al, [cti]
|
||||
mov [ecx-1], al
|
||||
.save:
|
||||
; open(name, O_WRONLY|O_CREAT|O_TRUNC, 0644)
|
||||
mov eax, sys_open
|
||||
mov ebx, [infilename]
|
||||
mov ecx, 0x241
|
||||
mov edx, 0x1A4
|
||||
int 0x80
|
||||
test eax, eax
|
||||
js quit
|
||||
mov [fd], eax
|
||||
mov eax, sys_write
|
||||
mov ebx, [fd]
|
||||
mov ecx, [outfilebest]
|
||||
mov edx, [outsize]
|
||||
int 0x80
|
||||
mov eax, sys_close
|
||||
mov ebx, [fd]
|
||||
int 0x80
|
||||
quit:
|
||||
mov eax, sys_exit
|
||||
xor ebx, ebx
|
||||
int 0x80
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
pk_set_outfile:
|
||||
mov eax, [outfilebest]
|
||||
xor eax, [outfile1]
|
||||
xor eax, [outfile2]
|
||||
mov [outfile], eax
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
pk_pack_lzma:
|
||||
mov eax, [outfile]
|
||||
add eax, 11
|
||||
push [workmem]
|
||||
push [insize]
|
||||
push eax
|
||||
push [infile]
|
||||
call lzma_compress ; ret 16
|
||||
mov ecx, [outfile]
|
||||
mov edx, [ecx+12]
|
||||
bswap edx
|
||||
mov [ecx+12], edx
|
||||
dec eax
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
pk_ct_fail:
|
||||
xor eax, eax
|
||||
mov [ctn], eax
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
pk_preprocess_calltrick:
|
||||
mov ecx, [insize]
|
||||
call alloc
|
||||
test eax, eax
|
||||
jz pk_ct_fail
|
||||
push eax
|
||||
xor eax, eax
|
||||
mov edi, ct1
|
||||
mov ecx, 256/4
|
||||
push edi
|
||||
rep stosd
|
||||
pop edi
|
||||
mov ecx, [insize]
|
||||
mov esi, [infile]
|
||||
xchg eax, edx ; edx = 0
|
||||
pop eax
|
||||
xchg eax, ebx ; ebx = temp buffer
|
||||
push ebx
|
||||
.pre:
|
||||
lodsb
|
||||
sub al, 0E8h
|
||||
cmp al, 1
|
||||
ja .cont
|
||||
cmp ecx, 5
|
||||
jb .done
|
||||
lodsd
|
||||
add eax, esi
|
||||
sub eax, [infile]
|
||||
cmp eax, [insize]
|
||||
jae .xxx
|
||||
cmp eax, 1000000h
|
||||
jae .xxx
|
||||
sub ecx, 4
|
||||
bswap eax
|
||||
mov [esi-4], eax
|
||||
inc edx
|
||||
mov [ebx], esi
|
||||
add ebx, 4
|
||||
jmp .cont
|
||||
.xxx:
|
||||
sub esi, 4
|
||||
movzx eax, byte [esi]
|
||||
mov byte [eax+edi], 1
|
||||
.cont:
|
||||
loop .pre
|
||||
.done:
|
||||
mov [ctn], edx
|
||||
pop edx ; edx = base of temp buffer
|
||||
xor eax, eax
|
||||
mov ecx, 256
|
||||
repnz scasb
|
||||
jnz pk_ct_fail
|
||||
not cl
|
||||
mov [cti], cl
|
||||
@@:
|
||||
cmp ebx, edx
|
||||
jz @f
|
||||
sub ebx, 4
|
||||
mov eax, [ebx]
|
||||
mov [eax-4], cl
|
||||
jmp @b
|
||||
@@:
|
||||
mov al, 1
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
pk_preprocess_calltrick2:
|
||||
; restore input
|
||||
mov esi, [infile]
|
||||
mov ecx, [ctn]
|
||||
jecxz .pre_init
|
||||
.restore:
|
||||
lodsb
|
||||
sub al, 0E8h
|
||||
cmp al, 1
|
||||
ja .restore
|
||||
mov al, [cti]
|
||||
cmp [esi], al
|
||||
jnz .restore
|
||||
lodsd
|
||||
mov al, 0
|
||||
bswap eax
|
||||
sub eax, esi
|
||||
add eax, [infile]
|
||||
mov [esi-4], eax
|
||||
loop .restore
|
||||
.pre_init:
|
||||
mov ecx, [insize]
|
||||
call alloc
|
||||
test eax, eax
|
||||
jz pk_ct_fail
|
||||
mov edi, ct1
|
||||
xchg eax, ebx
|
||||
xor eax, eax
|
||||
push edi
|
||||
mov ecx, 256/4
|
||||
rep stosd
|
||||
pop edi
|
||||
mov ecx, [insize]
|
||||
mov esi, [infile]
|
||||
xchg eax, edx ; edx = 0
|
||||
push ebx
|
||||
.pre:
|
||||
lodsb
|
||||
.chk0f:
|
||||
cmp al, 0Fh
|
||||
jnz .ip1
|
||||
dec ecx
|
||||
jz .done
|
||||
lodsb
|
||||
cmp al, 80h
|
||||
jb .chk0f
|
||||
cmp al, 90h
|
||||
jb .take
|
||||
.ip1:
|
||||
sub al, 0E8h
|
||||
cmp al, 1
|
||||
ja .cont
|
||||
.take:
|
||||
cmp ecx, 5
|
||||
jb .done
|
||||
lodsd
|
||||
add eax, esi
|
||||
sub eax, [infile]
|
||||
cmp eax, [insize]
|
||||
jae .xxx
|
||||
cmp eax, 1000000h
|
||||
jae .xxx
|
||||
sub ecx, 4
|
||||
bswap eax
|
||||
mov [esi-4], eax
|
||||
inc edx
|
||||
mov [ebx], esi
|
||||
add ebx, 4
|
||||
jmp .cont
|
||||
.xxx:
|
||||
sub esi, 4
|
||||
movzx eax, byte [esi]
|
||||
mov byte [eax+edi], 1
|
||||
.cont:
|
||||
loop .pre
|
||||
.done:
|
||||
mov [ctn], edx
|
||||
pop edx
|
||||
xor eax, eax
|
||||
mov ecx, 256
|
||||
repnz scasb
|
||||
jnz pk_ct_fail
|
||||
not cl
|
||||
mov [cti], cl
|
||||
@@:
|
||||
cmp ebx, edx
|
||||
jz @f
|
||||
sub ebx, 4
|
||||
mov eax, [ebx]
|
||||
mov [eax-4], cl
|
||||
jmp @b
|
||||
@@:
|
||||
mov al, 1
|
||||
ret
|
||||
|
||||
;=====================================================================
|
||||
; Kernel packing (self-extracting KERNPACK)
|
||||
;=====================================================================
|
||||
do_kerpack:
|
||||
mov ecx, 300*1024*3 + 6A8000h
|
||||
call alloc
|
||||
test eax, eax
|
||||
jz quit
|
||||
mov [infile], eax
|
||||
add eax, 300*1024
|
||||
mov [inbuftmp], eax
|
||||
add eax, 300*1024
|
||||
mov [outfile], eax
|
||||
add eax, 300*1024
|
||||
mov [workmem], eax
|
||||
; open + read
|
||||
mov eax, sys_open
|
||||
mov ebx, [infilename]
|
||||
xor ecx, ecx
|
||||
xor edx, edx
|
||||
int 0x80
|
||||
test eax, eax
|
||||
js quit
|
||||
mov [fd], eax
|
||||
mov eax, sys_lseek
|
||||
mov ebx, [fd]
|
||||
xor ecx, ecx
|
||||
mov edx, 2
|
||||
int 0x80
|
||||
test eax, eax
|
||||
jle quit
|
||||
cmp eax, 300*1024
|
||||
jbe @f
|
||||
mov eax, 300*1024
|
||||
@@:
|
||||
mov [insize3], eax
|
||||
mov eax, sys_lseek
|
||||
mov ebx, [fd]
|
||||
xor ecx, ecx
|
||||
xor edx, edx
|
||||
int 0x80
|
||||
mov eax, sys_read
|
||||
mov ebx, [fd]
|
||||
mov ecx, [infile]
|
||||
mov edx, [insize3]
|
||||
int 0x80
|
||||
mov eax, sys_close
|
||||
mov ebx, [fd]
|
||||
int 0x80
|
||||
; already packed?
|
||||
mov ebx, [insize3]
|
||||
mov edi, [infile]
|
||||
add edi, ebx
|
||||
cmp dword [edi-8], 'KERN'
|
||||
jnz .go
|
||||
cmp dword [edi-4], 'PACK'
|
||||
jz quit
|
||||
.go:
|
||||
push 18
|
||||
call lzma_set_dict_size
|
||||
; find jump to 32-bit code
|
||||
mov edi, [infile]
|
||||
mov eax, edi
|
||||
add eax, [insize3]
|
||||
dec edi
|
||||
.find:
|
||||
cmp eax, edi
|
||||
je quit ; not a kernel
|
||||
inc edi
|
||||
cmp dword [edi], 0xE88EE08E ; mov fs,ax / mov gs,ax
|
||||
jnz .find
|
||||
cmp dword [edi+4], 0x00BCD08E ; mov ss,ax / mov esp,00xxxxxx
|
||||
jnz .find
|
||||
add edi, 11
|
||||
mov [inptr], edi
|
||||
sub edi, [infile]
|
||||
mov [indelta], edi
|
||||
lea eax, [ebx+0x10000]
|
||||
mov dword [loader_patch3+2], eax
|
||||
sub ebx, edi
|
||||
mov [insize1], ebx
|
||||
call ker_preprocess_calltrick3
|
||||
mov al, [cti]
|
||||
mov [loader_patch5-1], al
|
||||
mov eax, [ctn]
|
||||
mov [loader_patch4+1], eax
|
||||
mov eax, [inptr]
|
||||
add eax, [outfile]
|
||||
sub eax, [infile]
|
||||
add eax, loader_size - 5
|
||||
push [workmem]
|
||||
push [insize1]
|
||||
push eax
|
||||
push [inptr]
|
||||
call lzma_compress
|
||||
add eax, loader_size - 5
|
||||
mov [loader_patch1+6], eax
|
||||
add eax, [indelta]
|
||||
mov [outsize3], eax
|
||||
mov eax, [indelta]
|
||||
mov ecx, eax
|
||||
add ecx, [outfile]
|
||||
mov ecx, [ecx + loader_size - 4]
|
||||
bswap ecx
|
||||
mov [loader_patch2+4], ecx
|
||||
add eax, 0x10000
|
||||
mov [loader_patch1+1], eax
|
||||
mov esi, [infile]
|
||||
mov edi, [outfile]
|
||||
mov ecx, [indelta]
|
||||
rep movsb
|
||||
mov esi, loader_start
|
||||
mov ecx, loader_size
|
||||
rep movsb
|
||||
mov eax, [outfile]
|
||||
add eax, [outsize3]
|
||||
mov dword [eax], 'KERN'
|
||||
mov dword [eax+4], 'PACK'
|
||||
add dword [outsize3], 8
|
||||
; save
|
||||
mov eax, sys_open
|
||||
mov ebx, [infilename]
|
||||
mov ecx, 0x241
|
||||
mov edx, 0x1A4
|
||||
int 0x80
|
||||
test eax, eax
|
||||
js quit
|
||||
mov [fd], eax
|
||||
mov eax, sys_write
|
||||
mov ebx, [fd]
|
||||
mov ecx, [outfile]
|
||||
mov edx, [outsize3]
|
||||
int 0x80
|
||||
mov eax, sys_close
|
||||
mov ebx, [fd]
|
||||
int 0x80
|
||||
jmp quit
|
||||
;---------------------------------------------------------------------
|
||||
ker_preprocess_calltrick3:
|
||||
mov edi, ct1
|
||||
xor eax, eax
|
||||
push edi
|
||||
mov ecx, 256/4
|
||||
rep stosd
|
||||
pop edi
|
||||
mov ecx, ebx ; ecx = insize1
|
||||
mov esi, [inptr]
|
||||
mov ebx, [inbuftmp]
|
||||
xchg eax, edx ; edx = 0
|
||||
.pre:
|
||||
lodsb
|
||||
.chk0f:
|
||||
cmp al, 0Fh
|
||||
jnz .ip1
|
||||
dec ecx
|
||||
jz .done
|
||||
lodsb
|
||||
cmp al, 80h
|
||||
jb .chk0f
|
||||
cmp al, 90h
|
||||
jb .take
|
||||
.ip1:
|
||||
sub al, 0E8h
|
||||
cmp al, 1
|
||||
ja .cont
|
||||
.take:
|
||||
cmp ecx, 5
|
||||
jb .done
|
||||
lodsd
|
||||
add eax, esi
|
||||
sub eax, [inptr]
|
||||
cmp eax, [insize1]
|
||||
jae .xxx
|
||||
cmp eax, 1000000h
|
||||
jae .xxx
|
||||
sub ecx, 4
|
||||
bswap eax
|
||||
mov [esi-4], eax
|
||||
inc edx
|
||||
mov [ebx], esi
|
||||
add ebx, 4
|
||||
jmp .cont
|
||||
.xxx:
|
||||
sub esi, 4
|
||||
movzx eax, byte [esi]
|
||||
mov byte [eax+edi], 1
|
||||
.cont:
|
||||
loop .pre
|
||||
.done:
|
||||
mov [ctn], edx
|
||||
xor eax, eax
|
||||
mov ecx, 256
|
||||
repnz scasb
|
||||
jnz .ret
|
||||
not cl
|
||||
mov [cti], cl
|
||||
@@:
|
||||
cmp ebx, [inbuftmp]
|
||||
jz .ret
|
||||
sub ebx, 4
|
||||
mov eax, [ebx]
|
||||
mov [eax-4], cl
|
||||
jmp @b
|
||||
.ret:
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
; LZMA compressor and the self-extractor stub (original diamond code)
|
||||
;---------------------------------------------------------------------
|
||||
include 'lzma_compress.inc'
|
||||
include 'lzma_set_dict_size.inc'
|
||||
include 'loader_lzma.inc'
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
; initialized data
|
||||
;---------------------------------------------------------------------
|
||||
kernel_name db 'kernel.mnt', 0
|
||||
|
||||
align 4
|
||||
LiteralNextStates:
|
||||
db 0,0,0,0,1,2,3,4,5,6,4,5
|
||||
MatchNextStates:
|
||||
db 7,7,7,7,7,7,7,10,10,10,10,10
|
||||
RepNextStates:
|
||||
db 8,8,8,8,8,8,8,11,11,11,11,11
|
||||
ShortRepNextStates:
|
||||
db 9,9,9,9,9,9,9,11,11,11,11,11
|
||||
|
||||
align 4
|
||||
method db 1
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
; uninitialized data (BSS - must stay at the very end of the segment)
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
infilename dd ?
|
||||
fd dd ?
|
||||
infile dd ?
|
||||
outfile dd ?
|
||||
outfile1 dd ?
|
||||
outfile2 dd ?
|
||||
outfilebest dd ?
|
||||
inbuftmp dd ?
|
||||
workmem dd ?
|
||||
insize dd ?
|
||||
outsize dd ?
|
||||
insize3 dd ?
|
||||
outsize3 dd ?
|
||||
inptr dd ?
|
||||
indelta dd ?
|
||||
insize1 dd ?
|
||||
ctn dd ?
|
||||
cti db ?
|
||||
db 0,0,0
|
||||
ct1 rb 256
|
||||
|
||||
align 4
|
||||
; LZMA compressor work area (from kpack data.inc) - referenced by name
|
||||
; from lzma_compress.inc; must keep this exact layout.
|
||||
_lenEncoder: rd 8451
|
||||
_prices: rd 4384
|
||||
rd 17
|
||||
_finished: rb 1
|
||||
_writeEndMark: rb 1
|
||||
_longestMatchWasFound: rb 1
|
||||
_previousByte: rb 1
|
||||
_longestMatchLength: rd 1
|
||||
g_FastPos: rb 1024
|
||||
_posSlotPrices: rd 256
|
||||
_isRep0Long: rd 192
|
||||
distances: rd 274
|
||||
_optimumCurrentIndex: rd 1
|
||||
_additionalOffset: rd 1
|
||||
_isRepG1: rd 12
|
||||
_isMatch: rd 192
|
||||
_alignPriceCount: rd 1
|
||||
_numLiteralContextBits: rd 1
|
||||
_literalEncoder: rd 114
|
||||
nowPos64: rd 2
|
||||
_distancesPrices: rd 512
|
||||
_repDistances: rd 4
|
||||
_posSlotEncoder: rd 1028
|
||||
lastPosSlotFillingPos: rd 2
|
||||
_numFastBytes: rd 1
|
||||
_posStateMask: rd 1
|
||||
_isRepG0: rd 12
|
||||
_repMatchLenEncoder: rd 8451
|
||||
rd 4384
|
||||
rd 17
|
||||
_isRepG2: rd 12
|
||||
_dictionarySize: rd 1
|
||||
_numLiteralPosStateBits:rd 1
|
||||
_distTableSize: rd 1
|
||||
_optimumEndIndex: rd 1
|
||||
state.State: rb 1
|
||||
state.Prev1IsChar: rb 1
|
||||
state.Prev2: rb 2
|
||||
state.PosPrev2: rd 1
|
||||
state.BackPrev2: rd 1
|
||||
state.Price: rd 1
|
||||
state.PosPrev: rd 1
|
||||
state.BackPrev: rd 1
|
||||
state.Backs: rd 4
|
||||
rd 40950
|
||||
_alignPrices: rd 16
|
||||
_isRep: rd 12
|
||||
_posAlignEncoder: rd 256
|
||||
i_01: rd 1
|
||||
_state: rb 1
|
||||
_cache: rb 1
|
||||
_state.Prev2: rb 2
|
||||
_posEncoders: rd 1
|
||||
_numPrevBits: rd 1
|
||||
_numPosBits: rd 1
|
||||
_posMask: rd 1
|
||||
_posStateBits: rd 1
|
||||
_range: rd 1
|
||||
_cacheSize: rd 1
|
||||
_cyclicBufferSize: rd 1
|
||||
low: rd 2
|
||||
Models: rd 512
|
||||
_matchMaxLen: rd 1
|
||||
pack_pos: rd 1
|
||||
_cutValue: rd 1
|
||||
_hash: rd 1
|
||||
crc_table: rd 256
|
||||
_buffer: rd 1
|
||||
_pos: rd 1
|
||||
_streamPos: rd 1
|
||||
pack_length: rd 1
|
||||
@@ -0,0 +1,890 @@
|
||||
; kpackw = Kolibri Packer, native Windows port (no window, not even a console)
|
||||
;
|
||||
; Usage: drag a file onto kpackw.exe, or kpackw.exe <file>
|
||||
; The file is compressed in place (overwritten).
|
||||
; If the file name is "kernel.mnt" it is packed with the "Kernel" option
|
||||
; (self-extracting KERNPACK format), otherwise the normal KPCK format is used.
|
||||
;
|
||||
; Compression core (LZMA + calltrick) and the self-extractor stub are the
|
||||
; original KolibriOS kpack sources by diamond; only the OS glue is new.
|
||||
|
||||
format PE GUI 4.0
|
||||
entry start
|
||||
|
||||
;=====================================================================
|
||||
section '.text' code readable writeable executable
|
||||
;=====================================================================
|
||||
|
||||
use_lzma = 1
|
||||
use_calltrick1 = 40h
|
||||
use_calltrick2 = 80h
|
||||
|
||||
start:
|
||||
; ---- get command line, extract the file argument ------------------
|
||||
call [GetCommandLineA]
|
||||
mov esi, eax
|
||||
; skip leading spaces
|
||||
.skip1:
|
||||
mov al, [esi]
|
||||
cmp al, ' '
|
||||
jne .arg0
|
||||
inc esi
|
||||
jmp .skip1
|
||||
; skip program name (argv[0])
|
||||
.arg0:
|
||||
cmp byte [esi], '"'
|
||||
jne .arg0_plain
|
||||
inc esi
|
||||
.arg0_q:
|
||||
mov al, [esi]
|
||||
test al, al
|
||||
jz .no_arg
|
||||
inc esi
|
||||
cmp al, '"'
|
||||
jne .arg0_q
|
||||
jmp .skip2
|
||||
.arg0_plain:
|
||||
mov al, [esi]
|
||||
test al, al
|
||||
jz .no_arg
|
||||
cmp al, ' '
|
||||
je .skip2
|
||||
inc esi
|
||||
jmp .arg0_plain
|
||||
; skip spaces between argv[0] and argv[1]
|
||||
.skip2:
|
||||
mov al, [esi]
|
||||
cmp al, ' '
|
||||
jne .arg1
|
||||
inc esi
|
||||
jmp .skip2
|
||||
; read the file name argument into infilename
|
||||
.arg1:
|
||||
mov al, [esi]
|
||||
test al, al
|
||||
jz .no_arg
|
||||
mov edi, infilename
|
||||
cmp al, '"'
|
||||
jne .arg1_plain
|
||||
inc esi
|
||||
.arg1_q:
|
||||
mov al, [esi]
|
||||
test al, al
|
||||
jz .name_done
|
||||
inc esi
|
||||
cmp al, '"'
|
||||
je .name_done
|
||||
stosb
|
||||
jmp .arg1_q
|
||||
.arg1_plain:
|
||||
mov al, [esi]
|
||||
test al, al
|
||||
jz .name_done
|
||||
cmp al, ' '
|
||||
je .name_done
|
||||
inc esi
|
||||
stosb
|
||||
jmp .arg1_plain
|
||||
.name_done:
|
||||
mov byte [edi], 0
|
||||
|
||||
; ---- is the base name "kernel.mnt" ? ------------------------------
|
||||
; find base name (after last '\' or '/')
|
||||
mov esi, infilename
|
||||
mov ebx, esi ; ebx = start of base name
|
||||
.bn:
|
||||
mov al, [esi]
|
||||
test al, al
|
||||
jz .bn_done
|
||||
cmp al, '\'
|
||||
je .bn_sep
|
||||
cmp al, '/'
|
||||
je .bn_sep
|
||||
inc esi
|
||||
jmp .bn
|
||||
.bn_sep:
|
||||
inc esi
|
||||
mov ebx, esi
|
||||
jmp .bn
|
||||
.bn_done:
|
||||
; case-insensitive compare ebx with "kernel.mnt"
|
||||
mov esi, ebx
|
||||
mov edi, kernel_name
|
||||
.cmpk:
|
||||
mov al, [esi]
|
||||
mov ah, [edi]
|
||||
test ah, ah
|
||||
jnz .notend
|
||||
test al, al ; kernel_name ended: match iff input ended too
|
||||
jz do_kerpack
|
||||
jmp do_pack
|
||||
.notend:
|
||||
or al, 20h ; tolower (kernel_name is lowercase)
|
||||
cmp al, ah
|
||||
jne do_pack
|
||||
inc esi
|
||||
inc edi
|
||||
jmp .cmpk
|
||||
|
||||
.no_arg:
|
||||
push 0
|
||||
call [ExitProcess]
|
||||
|
||||
;=====================================================================
|
||||
; Normal packing (KPCK) - transcribed from the KolibriOS/linux kpack
|
||||
;=====================================================================
|
||||
do_pack:
|
||||
; open input
|
||||
push 0
|
||||
push 0
|
||||
push 3 ; OPEN_EXISTING
|
||||
push 0
|
||||
push 1 ; FILE_SHARE_READ
|
||||
push 80000000h ; GENERIC_READ
|
||||
push infilename
|
||||
call [CreateFileA]
|
||||
cmp eax, -1
|
||||
je quit
|
||||
mov esi, eax ; handle
|
||||
push 0
|
||||
push esi
|
||||
call [GetFileSize]
|
||||
cmp eax, -1
|
||||
je quit
|
||||
test eax, eax
|
||||
jz quit
|
||||
mov [insize], eax
|
||||
; allocate infile
|
||||
push 4
|
||||
push 3000h
|
||||
push eax
|
||||
push 0
|
||||
call [VirtualAlloc]
|
||||
test eax, eax
|
||||
jz quit
|
||||
mov [infile], eax
|
||||
; read
|
||||
push 0
|
||||
push bytesdone
|
||||
push [insize]
|
||||
push eax
|
||||
push esi
|
||||
call [ReadFile]
|
||||
test eax, eax
|
||||
jz quit
|
||||
push esi
|
||||
call [CloseHandle]
|
||||
; maximum output size
|
||||
mov eax, [insize]
|
||||
shr eax, 3
|
||||
add eax, [insize]
|
||||
add eax, 400h
|
||||
mov esi, eax ; esi = maxout
|
||||
add eax, eax ; two copies
|
||||
push 4
|
||||
push 3000h
|
||||
push eax
|
||||
push 0
|
||||
call [VirtualAlloc]
|
||||
test eax, eax
|
||||
jz quit
|
||||
mov [outfile], eax
|
||||
mov [outfile1], eax
|
||||
mov [outfilebest], eax
|
||||
add eax, esi
|
||||
mov [outfile2], eax
|
||||
; KPCK header
|
||||
mov eax, [outfile1]
|
||||
mov dword [eax], 'KPCK'
|
||||
mov ecx, [insize]
|
||||
mov [eax+4], ecx
|
||||
; LZMA dictionary size
|
||||
dec ecx
|
||||
bsr eax, ecx
|
||||
inc eax
|
||||
cmp eax, 28
|
||||
jb @f
|
||||
mov eax, 28
|
||||
@@:
|
||||
push eax
|
||||
push eax
|
||||
call lzma_set_dict_size ; ret 4 (pops one)
|
||||
pop ecx ; ecx = log2(dict)
|
||||
mov eax, 1
|
||||
shl eax, cl
|
||||
; workmem
|
||||
imul eax, 19
|
||||
shr eax, 1
|
||||
add eax, 509000h
|
||||
push 4
|
||||
push 3000h
|
||||
push eax
|
||||
push 0
|
||||
call [VirtualAlloc]
|
||||
test eax, eax
|
||||
jz quit
|
||||
mov [workmem], eax
|
||||
; first pass: plain LZMA
|
||||
mov eax, [outfile2]
|
||||
mov [outfile], eax
|
||||
xchg eax, edi
|
||||
mov esi, [outfile1]
|
||||
movsd
|
||||
movsd
|
||||
call pk_pack_lzma
|
||||
mov [outsize], eax
|
||||
mov eax, [outfile]
|
||||
mov [outfilebest], eax
|
||||
mov [method], use_lzma
|
||||
; calltrick 1
|
||||
call pk_preprocess_calltrick
|
||||
test eax, eax
|
||||
jz .noct1
|
||||
call pk_set_outfile
|
||||
call pk_pack_lzma
|
||||
add eax, 5
|
||||
cmp eax, [outsize]
|
||||
jae .noct1
|
||||
mov [outsize], eax
|
||||
mov eax, [outfile]
|
||||
mov [outfilebest], eax
|
||||
mov [method], use_lzma or use_calltrick1
|
||||
.noct1:
|
||||
call pk_set_outfile
|
||||
push dword [ctn]
|
||||
movzx eax, byte [cti]
|
||||
push eax
|
||||
call pk_preprocess_calltrick2
|
||||
test eax, eax
|
||||
jz .noct2
|
||||
call pk_set_outfile
|
||||
call pk_pack_lzma
|
||||
add eax, 5
|
||||
cmp eax, [outsize]
|
||||
jae .noct2
|
||||
mov [outsize], eax
|
||||
mov eax, [outfile]
|
||||
mov [outfilebest], eax
|
||||
mov [method], use_lzma or use_calltrick2
|
||||
pop ecx
|
||||
pop ecx
|
||||
push dword [ctn]
|
||||
movzx eax, byte [cti]
|
||||
push eax
|
||||
.noct2:
|
||||
pop eax
|
||||
mov [cti], al
|
||||
pop eax
|
||||
mov [ctn], eax
|
||||
add dword [outsize], 12
|
||||
mov eax, [outsize]
|
||||
cmp eax, [insize]
|
||||
jb .packed_ok
|
||||
jmp quit ; output not smaller: leave original untouched
|
||||
.packed_ok:
|
||||
movzx eax, byte [method]
|
||||
mov edi, [outfilebest]
|
||||
mov [edi+8], eax
|
||||
test al, use_calltrick1 or use_calltrick2
|
||||
jz .save
|
||||
mov ecx, [outsize]
|
||||
add ecx, edi
|
||||
mov eax, [ctn]
|
||||
mov [ecx-5], eax
|
||||
mov al, [cti]
|
||||
mov [ecx-1], al
|
||||
.save:
|
||||
push 0
|
||||
push 80h ; FILE_ATTRIBUTE_NORMAL
|
||||
push 2 ; CREATE_ALWAYS
|
||||
push 0
|
||||
push 0
|
||||
push 40000000h ; GENERIC_WRITE
|
||||
push infilename
|
||||
call [CreateFileA]
|
||||
cmp eax, -1
|
||||
je quit
|
||||
mov esi, eax
|
||||
push 0
|
||||
push bytesdone
|
||||
push [outsize]
|
||||
push [outfilebest]
|
||||
push esi
|
||||
call [WriteFile]
|
||||
push esi
|
||||
call [CloseHandle]
|
||||
quit:
|
||||
push 0
|
||||
call [ExitProcess]
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
pk_set_outfile:
|
||||
mov eax, [outfilebest]
|
||||
xor eax, [outfile1]
|
||||
xor eax, [outfile2]
|
||||
mov [outfile], eax
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
pk_pack_lzma:
|
||||
mov eax, [outfile]
|
||||
add eax, 11
|
||||
push [workmem]
|
||||
push [insize]
|
||||
push eax
|
||||
push [infile]
|
||||
call lzma_compress ; ret 16
|
||||
mov ecx, [outfile]
|
||||
mov edx, [ecx+12]
|
||||
bswap edx
|
||||
mov [ecx+12], edx
|
||||
dec eax
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
pk_ct_fail:
|
||||
xor eax, eax
|
||||
mov [ctn], eax
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
pk_preprocess_calltrick:
|
||||
push 4
|
||||
push 3000h
|
||||
push [insize]
|
||||
push 0
|
||||
call [VirtualAlloc]
|
||||
test eax, eax
|
||||
jz pk_ct_fail
|
||||
push eax
|
||||
xor eax, eax
|
||||
mov edi, ct1
|
||||
mov ecx, 256/4
|
||||
push edi
|
||||
rep stosd
|
||||
pop edi
|
||||
mov ecx, [insize]
|
||||
mov esi, [infile]
|
||||
xchg eax, edx ; edx = 0
|
||||
pop eax
|
||||
xchg eax, ebx ; ebx = temp buffer
|
||||
push ebx
|
||||
.pre:
|
||||
lodsb
|
||||
sub al, 0E8h
|
||||
cmp al, 1
|
||||
ja .cont
|
||||
cmp ecx, 5
|
||||
jb .done
|
||||
lodsd
|
||||
add eax, esi
|
||||
sub eax, [infile]
|
||||
cmp eax, [insize]
|
||||
jae .xxx
|
||||
cmp eax, 1000000h
|
||||
jae .xxx
|
||||
sub ecx, 4
|
||||
bswap eax
|
||||
mov [esi-4], eax
|
||||
inc edx
|
||||
mov [ebx], esi
|
||||
add ebx, 4
|
||||
jmp .cont
|
||||
.xxx:
|
||||
sub esi, 4
|
||||
movzx eax, byte [esi]
|
||||
mov byte [eax+edi], 1
|
||||
.cont:
|
||||
loop .pre
|
||||
.done:
|
||||
mov [ctn], edx
|
||||
pop edx ; edx = base of temp buffer
|
||||
xor eax, eax
|
||||
mov ecx, 256
|
||||
repnz scasb
|
||||
jnz pk_ct_fail
|
||||
not cl
|
||||
mov [cti], cl
|
||||
@@:
|
||||
cmp ebx, edx
|
||||
jz @f
|
||||
sub ebx, 4
|
||||
mov eax, [ebx]
|
||||
mov [eax-4], cl
|
||||
jmp @b
|
||||
@@:
|
||||
mov al, 1
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
pk_preprocess_calltrick2:
|
||||
; restore input
|
||||
mov esi, [infile]
|
||||
mov ecx, [ctn]
|
||||
jecxz .pre_init
|
||||
.restore:
|
||||
lodsb
|
||||
sub al, 0E8h
|
||||
cmp al, 1
|
||||
ja .restore
|
||||
mov al, [cti]
|
||||
cmp [esi], al
|
||||
jnz .restore
|
||||
lodsd
|
||||
mov al, 0
|
||||
bswap eax
|
||||
sub eax, esi
|
||||
add eax, [infile]
|
||||
mov [esi-4], eax
|
||||
loop .restore
|
||||
.pre_init:
|
||||
push 4
|
||||
push 3000h
|
||||
push [insize]
|
||||
push 0
|
||||
call [VirtualAlloc]
|
||||
test eax, eax
|
||||
jz pk_ct_fail
|
||||
mov edi, ct1
|
||||
xchg eax, ebx
|
||||
xor eax, eax
|
||||
push edi
|
||||
mov ecx, 256/4
|
||||
rep stosd
|
||||
pop edi
|
||||
mov ecx, [insize]
|
||||
mov esi, [infile]
|
||||
xchg eax, edx ; edx = 0
|
||||
push ebx
|
||||
.pre:
|
||||
lodsb
|
||||
.chk0f:
|
||||
cmp al, 0Fh
|
||||
jnz .ip1
|
||||
dec ecx
|
||||
jz .done
|
||||
lodsb
|
||||
cmp al, 80h
|
||||
jb .chk0f
|
||||
cmp al, 90h
|
||||
jb .take
|
||||
.ip1:
|
||||
sub al, 0E8h
|
||||
cmp al, 1
|
||||
ja .cont
|
||||
.take:
|
||||
cmp ecx, 5
|
||||
jb .done
|
||||
lodsd
|
||||
add eax, esi
|
||||
sub eax, [infile]
|
||||
cmp eax, [insize]
|
||||
jae .xxx
|
||||
cmp eax, 1000000h
|
||||
jae .xxx
|
||||
sub ecx, 4
|
||||
bswap eax
|
||||
mov [esi-4], eax
|
||||
inc edx
|
||||
mov [ebx], esi
|
||||
add ebx, 4
|
||||
jmp .cont
|
||||
.xxx:
|
||||
sub esi, 4
|
||||
movzx eax, byte [esi]
|
||||
mov byte [eax+edi], 1
|
||||
.cont:
|
||||
loop .pre
|
||||
.done:
|
||||
mov [ctn], edx
|
||||
pop edx
|
||||
xor eax, eax
|
||||
mov ecx, 256
|
||||
repnz scasb
|
||||
jnz pk_ct_fail
|
||||
not cl
|
||||
mov [cti], cl
|
||||
@@:
|
||||
cmp ebx, edx
|
||||
jz @f
|
||||
sub ebx, 4
|
||||
mov eax, [ebx]
|
||||
mov [eax-4], cl
|
||||
jmp @b
|
||||
@@:
|
||||
mov al, 1
|
||||
ret
|
||||
|
||||
;=====================================================================
|
||||
; Kernel packing (self-extracting KERNPACK) - from kerpack.inc
|
||||
;=====================================================================
|
||||
do_kerpack:
|
||||
push 4
|
||||
push 3000h
|
||||
push 300*1024*3 + 6A8000h
|
||||
push 0
|
||||
call [VirtualAlloc]
|
||||
test eax, eax
|
||||
jz quit
|
||||
mov [infile], eax
|
||||
add eax, 300*1024
|
||||
mov [inbuftmp], eax
|
||||
add eax, 300*1024
|
||||
mov [outfile], eax
|
||||
add eax, 300*1024
|
||||
mov [workmem], eax
|
||||
; open + read
|
||||
push 0
|
||||
push 0
|
||||
push 3
|
||||
push 0
|
||||
push 1
|
||||
push 80000000h
|
||||
push infilename
|
||||
call [CreateFileA]
|
||||
cmp eax, -1
|
||||
je quit
|
||||
mov esi, eax
|
||||
push 0
|
||||
push esi
|
||||
call [GetFileSize]
|
||||
cmp eax, -1
|
||||
je quit
|
||||
test eax, eax
|
||||
jz quit
|
||||
cmp eax, 300*1024
|
||||
jbe @f
|
||||
mov eax, 300*1024
|
||||
@@:
|
||||
mov [insize3], eax
|
||||
push 0
|
||||
push bytesdone
|
||||
push [insize3]
|
||||
push [infile]
|
||||
push esi
|
||||
call [ReadFile]
|
||||
push esi
|
||||
call [CloseHandle]
|
||||
; already packed?
|
||||
mov ebx, [insize3]
|
||||
mov edi, [infile]
|
||||
add edi, ebx
|
||||
cmp dword [edi-8], 'KERN'
|
||||
jnz .go
|
||||
cmp dword [edi-4], 'PACK'
|
||||
jz quit
|
||||
.go:
|
||||
push 18
|
||||
call lzma_set_dict_size
|
||||
; find jump to 32-bit code
|
||||
mov edi, [infile]
|
||||
mov eax, edi
|
||||
add eax, [insize3]
|
||||
dec edi
|
||||
.find:
|
||||
cmp eax, edi
|
||||
je quit ; not a kernel
|
||||
inc edi
|
||||
cmp dword [edi], 0xE88EE08E ; mov fs,ax / mov gs,ax
|
||||
jnz .find
|
||||
cmp dword [edi+4], 0x00BCD08E ; mov ss,ax / mov esp,00xxxxxx
|
||||
jnz .find
|
||||
add edi, 11
|
||||
mov [inptr], edi
|
||||
sub edi, [infile]
|
||||
mov [indelta], edi
|
||||
lea eax, [ebx+0x10000]
|
||||
mov dword [loader_patch3+2], eax
|
||||
sub ebx, edi
|
||||
mov [insize1], ebx
|
||||
call ker_preprocess_calltrick3
|
||||
mov al, [cti]
|
||||
mov [loader_patch5-1], al
|
||||
mov eax, [ctn]
|
||||
mov [loader_patch4+1], eax
|
||||
mov eax, [inptr]
|
||||
add eax, [outfile]
|
||||
sub eax, [infile]
|
||||
add eax, loader_size - 5
|
||||
push [workmem]
|
||||
push [insize1]
|
||||
push eax
|
||||
push [inptr]
|
||||
call lzma_compress
|
||||
add eax, loader_size - 5
|
||||
mov [loader_patch1+6], eax
|
||||
add eax, [indelta]
|
||||
mov [outsize3], eax
|
||||
mov eax, [indelta]
|
||||
mov ecx, eax
|
||||
add ecx, [outfile]
|
||||
mov ecx, [ecx + loader_size - 4]
|
||||
bswap ecx
|
||||
mov [loader_patch2+4], ecx
|
||||
add eax, 0x10000
|
||||
mov [loader_patch1+1], eax
|
||||
mov esi, [infile]
|
||||
mov edi, [outfile]
|
||||
mov ecx, [indelta]
|
||||
rep movsb
|
||||
mov esi, loader_start
|
||||
mov ecx, loader_size
|
||||
rep movsb
|
||||
mov eax, [outfile]
|
||||
add eax, [outsize3]
|
||||
mov dword [eax], 'KERN'
|
||||
mov dword [eax+4], 'PACK'
|
||||
add dword [outsize3], 8
|
||||
; save
|
||||
push 0
|
||||
push 80h
|
||||
push 2
|
||||
push 0
|
||||
push 0
|
||||
push 40000000h
|
||||
push infilename
|
||||
call [CreateFileA]
|
||||
cmp eax, -1
|
||||
je quit
|
||||
mov esi, eax
|
||||
push 0
|
||||
push bytesdone
|
||||
push [outsize3]
|
||||
push [outfile]
|
||||
push esi
|
||||
call [WriteFile]
|
||||
push esi
|
||||
call [CloseHandle]
|
||||
jmp quit
|
||||
;---------------------------------------------------------------------
|
||||
ker_preprocess_calltrick3:
|
||||
mov edi, ct1
|
||||
xor eax, eax
|
||||
push edi
|
||||
mov ecx, 256/4
|
||||
rep stosd
|
||||
pop edi
|
||||
mov ecx, ebx ; ecx = insize1
|
||||
mov esi, [inptr]
|
||||
mov ebx, [inbuftmp]
|
||||
xchg eax, edx ; edx = 0
|
||||
.pre:
|
||||
lodsb
|
||||
.chk0f:
|
||||
cmp al, 0Fh
|
||||
jnz .ip1
|
||||
dec ecx
|
||||
jz .done
|
||||
lodsb
|
||||
cmp al, 80h
|
||||
jb .chk0f
|
||||
cmp al, 90h
|
||||
jb .take
|
||||
.ip1:
|
||||
sub al, 0E8h
|
||||
cmp al, 1
|
||||
ja .cont
|
||||
.take:
|
||||
cmp ecx, 5
|
||||
jb .done
|
||||
lodsd
|
||||
add eax, esi
|
||||
sub eax, [inptr]
|
||||
cmp eax, [insize1]
|
||||
jae .xxx
|
||||
cmp eax, 1000000h
|
||||
jae .xxx
|
||||
sub ecx, 4
|
||||
bswap eax
|
||||
mov [esi-4], eax
|
||||
inc edx
|
||||
mov [ebx], esi
|
||||
add ebx, 4
|
||||
jmp .cont
|
||||
.xxx:
|
||||
sub esi, 4
|
||||
movzx eax, byte [esi]
|
||||
mov byte [eax+edi], 1
|
||||
.cont:
|
||||
loop .pre
|
||||
.done:
|
||||
mov [ctn], edx
|
||||
xor eax, eax
|
||||
mov ecx, 256
|
||||
repnz scasb
|
||||
jnz .ret
|
||||
not cl
|
||||
mov [cti], cl
|
||||
@@:
|
||||
cmp ebx, [inbuftmp]
|
||||
jz .ret
|
||||
sub ebx, 4
|
||||
mov eax, [ebx]
|
||||
mov [eax-4], cl
|
||||
jmp @b
|
||||
.ret:
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------------
|
||||
; LZMA compressor and the self-extractor stub (original diamond code)
|
||||
;---------------------------------------------------------------------
|
||||
include 'lzma_compress.inc'
|
||||
include 'lzma_set_dict_size.inc'
|
||||
include 'loader_lzma.inc'
|
||||
|
||||
;=====================================================================
|
||||
section '.data' data readable writeable
|
||||
;=====================================================================
|
||||
kernel_name db 'kernel.mnt', 0
|
||||
|
||||
align 4
|
||||
; LZMA state-transition tables (constants, referenced by lzma_compress)
|
||||
LiteralNextStates:
|
||||
db 0,0,0,0,1,2,3,4,5,6,4,5
|
||||
MatchNextStates:
|
||||
db 7,7,7,7,7,7,7,10,10,10,10,10
|
||||
RepNextStates:
|
||||
db 8,8,8,8,8,8,8,11,11,11,11,11
|
||||
ShortRepNextStates:
|
||||
db 9,9,9,9,9,9,9,11,11,11,11,11
|
||||
|
||||
align 4
|
||||
method db 1
|
||||
db 0,0,0
|
||||
infile dd ?
|
||||
outfile dd ?
|
||||
outfile1 dd ?
|
||||
outfile2 dd ?
|
||||
outfilebest dd ?
|
||||
inbuftmp dd ?
|
||||
workmem dd ?
|
||||
insize dd ?
|
||||
outsize dd ?
|
||||
insize3 dd ?
|
||||
outsize3 dd ?
|
||||
inptr dd ?
|
||||
indelta dd ?
|
||||
insize1 dd ?
|
||||
ctn dd ?
|
||||
cti db ?
|
||||
db 0,0,0
|
||||
bytesdone dd ?
|
||||
|
||||
;=====================================================================
|
||||
section '.bss' data readable writeable
|
||||
;=====================================================================
|
||||
infilename rb 1024
|
||||
ct1 rb 256
|
||||
|
||||
align 4
|
||||
;---------------------------------------------------------------------
|
||||
; LZMA compressor work area (from kpack data.inc) - referenced by name
|
||||
; from lzma_compress.inc; must keep this exact layout.
|
||||
;---------------------------------------------------------------------
|
||||
_lenEncoder: rd 8451
|
||||
_prices: rd 4384
|
||||
rd 17
|
||||
_finished: rb 1
|
||||
_writeEndMark: rb 1
|
||||
_longestMatchWasFound: rb 1
|
||||
_previousByte: rb 1
|
||||
_longestMatchLength: rd 1
|
||||
g_FastPos: rb 1024
|
||||
_posSlotPrices: rd 256
|
||||
_isRep0Long: rd 192
|
||||
distances: rd 274
|
||||
_optimumCurrentIndex: rd 1
|
||||
_additionalOffset: rd 1
|
||||
_isRepG1: rd 12
|
||||
_isMatch: rd 192
|
||||
_alignPriceCount: rd 1
|
||||
_numLiteralContextBits: rd 1
|
||||
_literalEncoder: rd 114
|
||||
nowPos64: rd 2
|
||||
_distancesPrices: rd 512
|
||||
_repDistances: rd 4
|
||||
_posSlotEncoder: rd 1028
|
||||
lastPosSlotFillingPos: rd 2
|
||||
_numFastBytes: rd 1
|
||||
_posStateMask: rd 1
|
||||
_isRepG0: rd 12
|
||||
_repMatchLenEncoder: rd 8451
|
||||
rd 4384
|
||||
rd 17
|
||||
_isRepG2: rd 12
|
||||
_dictionarySize: rd 1
|
||||
_numLiteralPosStateBits:rd 1
|
||||
_distTableSize: rd 1
|
||||
_optimumEndIndex: rd 1
|
||||
state.State: rb 1
|
||||
state.Prev1IsChar: rb 1
|
||||
state.Prev2: rb 2
|
||||
state.PosPrev2: rd 1
|
||||
state.BackPrev2: rd 1
|
||||
state.Price: rd 1
|
||||
state.PosPrev: rd 1
|
||||
state.BackPrev: rd 1
|
||||
state.Backs: rd 4
|
||||
rd 40950
|
||||
_alignPrices: rd 16
|
||||
_isRep: rd 12
|
||||
_posAlignEncoder: rd 256
|
||||
i_01: rd 1
|
||||
_state: rb 1
|
||||
_cache: rb 1
|
||||
_state.Prev2: rb 2
|
||||
_posEncoders: rd 1
|
||||
_numPrevBits: rd 1
|
||||
_numPosBits: rd 1
|
||||
_posMask: rd 1
|
||||
_posStateBits: rd 1
|
||||
_range: rd 1
|
||||
_cacheSize: rd 1
|
||||
_cyclicBufferSize: rd 1
|
||||
low: rd 2
|
||||
Models: rd 512
|
||||
_matchMaxLen: rd 1
|
||||
pack_pos: rd 1
|
||||
_cutValue: rd 1
|
||||
_hash: rd 1
|
||||
crc_table: rd 256
|
||||
_buffer: rd 1
|
||||
_pos: rd 1
|
||||
_streamPos: rd 1
|
||||
pack_length: rd 1
|
||||
|
||||
;=====================================================================
|
||||
section '.idata' import data readable writeable
|
||||
;=====================================================================
|
||||
dd 0,0,0, RVA kernel_txt, RVA kernel_iat
|
||||
dd 0,0,0, 0, 0
|
||||
|
||||
kernel_iat:
|
||||
GetCommandLineA dd RVA _GetCommandLineA
|
||||
CreateFileA dd RVA _CreateFileA
|
||||
GetFileSize dd RVA _GetFileSize
|
||||
ReadFile dd RVA _ReadFile
|
||||
WriteFile dd RVA _WriteFile
|
||||
CloseHandle dd RVA _CloseHandle
|
||||
VirtualAlloc dd RVA _VirtualAlloc
|
||||
VirtualFree dd RVA _VirtualFree
|
||||
ExitProcess dd RVA _ExitProcess
|
||||
dd 0
|
||||
|
||||
kernel_txt db 'KERNEL32.DLL', 0
|
||||
|
||||
align 2
|
||||
_GetCommandLineA dw 0
|
||||
db 'GetCommandLineA', 0
|
||||
_CreateFileA dw 0
|
||||
db 'CreateFileA', 0
|
||||
_GetFileSize dw 0
|
||||
db 'GetFileSize', 0
|
||||
_ReadFile dw 0
|
||||
db 'ReadFile', 0
|
||||
_WriteFile dw 0
|
||||
db 'WriteFile', 0
|
||||
_CloseHandle dw 0
|
||||
db 'CloseHandle', 0
|
||||
_VirtualAlloc dw 0
|
||||
db 'VirtualAlloc', 0
|
||||
_VirtualFree dw 0
|
||||
db 'VirtualFree', 0
|
||||
_ExitProcess dw 0
|
||||
db 'ExitProcess', 0
|
||||
@@ -451,19 +451,19 @@ mouse:
|
||||
;--------------------------------------
|
||||
align 4
|
||||
.red:
|
||||
stdcall [scrollbar_ver_mouse], scroll_bar_data_red
|
||||
stdcall [scrollbar_v_mouse], scroll_bar_data_red
|
||||
cmp [scroll_bar_data_red.delta2],0
|
||||
jne @f
|
||||
;--------------------------------------
|
||||
align 4
|
||||
.green:
|
||||
stdcall [scrollbar_ver_mouse], scroll_bar_data_green
|
||||
stdcall [scrollbar_v_mouse], scroll_bar_data_green
|
||||
cmp [scroll_bar_data_green.delta2],0
|
||||
jne @f
|
||||
;--------------------------------------
|
||||
align 4
|
||||
.blue:
|
||||
stdcall [scrollbar_ver_mouse], scroll_bar_data_blue
|
||||
stdcall [scrollbar_v_mouse], scroll_bar_data_blue
|
||||
cmp [scroll_bar_data_blue.delta2],0
|
||||
jne @f
|
||||
;--------------------------------------
|
||||
@@ -499,9 +499,9 @@ draw_tone:
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
draw_scrollbars:
|
||||
stdcall [scrollbar_ver_draw], scroll_bar_data_red
|
||||
stdcall [scrollbar_ver_draw], scroll_bar_data_green
|
||||
stdcall [scrollbar_ver_draw], scroll_bar_data_blue
|
||||
stdcall [scrollbar_v_draw], scroll_bar_data_red
|
||||
stdcall [scrollbar_v_draw], scroll_bar_data_green
|
||||
stdcall [scrollbar_v_draw], scroll_bar_data_blue
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
@@ -512,7 +512,7 @@ draw_history_frame:
|
||||
mov [frame_data.draw_text_flag],dword 1
|
||||
|
||||
mov [frame_data.text_pointer],dword history_text
|
||||
stdcall [Frame_draw], frame_data
|
||||
stdcall [frame_draw], frame_data
|
||||
ret
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
@@ -590,7 +590,7 @@ newcol:
|
||||
mov [frame_data.x],ebx
|
||||
mov [frame_data.y],ecx
|
||||
|
||||
stdcall [Frame_draw], frame_data
|
||||
stdcall [frame_draw], frame_data
|
||||
|
||||
pop ecx ebx
|
||||
|
||||
|
||||
@@ -23,102 +23,11 @@ system_dir_Boxlib db '/sys/lib/box_lib.obj',0
|
||||
align 4
|
||||
l_libs_start:
|
||||
library01 l_libs system_dir_Boxlib+9,file_name,system_dir_Boxlib,\
|
||||
Box_lib_import,plugins_directory
|
||||
import_box_lib,plugins_directory
|
||||
|
||||
end_l_libs:
|
||||
;---------------------------------------------------------------------
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
Box_lib_import:
|
||||
;init_lib dd a_init
|
||||
;version_lib dd a_version
|
||||
|
||||
edit_box_draw dd aEdit_box_draw
|
||||
edit_box_key dd aEdit_box_key
|
||||
edit_box_mouse dd aEdit_box_mouse
|
||||
edit_box_set_text dd aEdit_box_set_text
|
||||
;version_ed dd aVersion_ed
|
||||
|
||||
;check_box_draw dd aCheck_box_draw
|
||||
;check_box_mouse dd aCheck_box_mouse
|
||||
;version_ch dd aVersion_ch
|
||||
|
||||
;option_box_draw dd aOption_box_draw
|
||||
;option_box_mouse dd aOption_box_mouse
|
||||
;version_op dd aVersion_op
|
||||
|
||||
scrollbar_ver_draw dd aScrollbar_ver_draw
|
||||
scrollbar_ver_mouse dd aScrollbar_ver_mouse
|
||||
;scrollbar_hor_draw dd aScrollbar_hor_draw
|
||||
;scrollbar_hor_mouse dd aScrollbar_hor_mouse
|
||||
;version_scrollbar dd aVersion_scrollbar
|
||||
|
||||
;dinamic_button_draw dd aDbutton_draw
|
||||
;dinamic_button_mouse dd aDbutton_mouse
|
||||
;version_dbutton dd aVersion_dbutton
|
||||
|
||||
;menu_bar_draw dd aMenu_bar_draw
|
||||
;menu_bar_mouse dd aMenu_bar_mouse
|
||||
;menu_bar_activate dd aMenu_bar_activate
|
||||
;version_menu_bar dd aVersion_menu_bar
|
||||
|
||||
;FileBrowser_draw dd aFileBrowser_draw
|
||||
;FileBrowser_mouse dd aFileBrowser_mouse
|
||||
;FileBrowser_key dd aFileBrowser_key
|
||||
;Version_FileBrowser dd aVersion_FileBrowser
|
||||
|
||||
;PathShow_prepare dd sz_PathShow_prepare
|
||||
;PathShow_draw dd sz_PathShow_draw
|
||||
;Version_path_show dd szVersion_path_show
|
||||
|
||||
Frame_draw dd sz_Frame_draw
|
||||
;Version_frame dd szVersion_frame
|
||||
|
||||
dd 0,0
|
||||
|
||||
;a_init db 'lib_init',0
|
||||
;a_version db 'version',0
|
||||
|
||||
aEdit_box_draw db 'edit_box_draw',0
|
||||
aEdit_box_key db 'edit_box_key',0
|
||||
aEdit_box_mouse db 'edit_box_mouse',0
|
||||
aEdit_box_set_text db 'edit_box_set_text',0
|
||||
;aVersion_ed db 'version_ed',0
|
||||
|
||||
;aCheck_box_draw db 'check_box_draw',0
|
||||
;aCheck_box_mouse db 'check_box_mouse',0
|
||||
;aVersion_ch db 'version_ch',0
|
||||
|
||||
;aOption_box_draw db 'option_box_draw',0
|
||||
;aOption_box_mouse db 'option_box_mouse',0
|
||||
;aVersion_op db 'version_op',0
|
||||
|
||||
aScrollbar_ver_draw db 'scrollbar_v_draw',0
|
||||
aScrollbar_ver_mouse db 'scrollbar_v_mouse',0
|
||||
;aScrollbar_hor_draw db 'scrollbar_h_draw',0
|
||||
;aScrollbar_hor_mouse db 'scrollbar_h_mouse',0
|
||||
;aVersion_scrollbar db 'version_scrollbar',0
|
||||
|
||||
;aDbutton_draw db 'dbutton_draw',0
|
||||
;aDbutton_mouse db 'dbutton_mouse',0
|
||||
;aVersion_dbutton db 'version_dbutton',0
|
||||
|
||||
;aMenu_bar_draw db 'menu_bar_draw',0
|
||||
;aMenu_bar_mouse db 'menu_bar_mouse',0
|
||||
;aMenu_bar_activate db 'menu_bar_activate',0
|
||||
;aVersion_menu_bar db 'version_menu_bar',0
|
||||
|
||||
;aFileBrowser_draw db 'FileBrowser_draw',0
|
||||
;aFileBrowser_mouse db 'FileBrowser_mouse',0
|
||||
;aFileBrowser_key db 'FileBrowser_key',0
|
||||
;aVersion_FileBrowser db 'version_FileBrowser',0
|
||||
|
||||
;sz_PathShow_prepare db 'PathShow_prepare',0
|
||||
;sz_PathShow_draw db 'PathShow_draw',0
|
||||
;szVersion_path_show db 'version_PathShow',0
|
||||
|
||||
sz_Frame_draw db 'frame_draw',0
|
||||
;szVersion_frame db 'version_frame',0
|
||||
include '../../develop/libraries/box_lib/import.inc'
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
scroll_bar_data_red:
|
||||
|
||||
@@ -100,7 +100,7 @@ macro mz text,str1,str2,str3 {
|
||||
}
|
||||
;---------------------------------------------------------------------
|
||||
START:
|
||||
; load_library boxlib_name,buf_cmd_lin,system_path,Box_lib_import
|
||||
; load_library boxlib_name,buf_cmd_lin,system_path,import_box_lib
|
||||
mcall SF_SYS_MISC,SSF_HEAP_INIT
|
||||
|
||||
load_libraries l_libs_start,end_l_libs
|
||||
@@ -1669,7 +1669,7 @@ system_dir_ProcLib db '/sys/lib/proc_lib.obj',0
|
||||
align 4
|
||||
l_libs_start:
|
||||
|
||||
library01 l_libs system_dir_Boxlib+9, library_path, system_dir_Boxlib, Box_lib_import
|
||||
library01 l_libs system_dir_Boxlib+9, library_path, system_dir_Boxlib, import_box_lib
|
||||
|
||||
library02 l_libs system_dir_ProcLib+9, library_path, system_dir_ProcLib, ProcLib_import
|
||||
|
||||
@@ -1714,89 +1714,7 @@ aOpenDialog_Init db 'OpenDialog_init',0
|
||||
aOpenDialog_Start db 'OpenDialog_start',0
|
||||
;aOpenDialog_Version db 'Version_OpenDialog',0
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
Box_lib_import:
|
||||
;init_lib dd a_init
|
||||
;version_lib dd a_version
|
||||
|
||||
|
||||
edit_box_draw dd aEdit_box_draw
|
||||
edit_box_key dd aEdit_box_key
|
||||
edit_box_mouse dd aEdit_box_mouse
|
||||
;version_ed dd aVersion_ed
|
||||
|
||||
;check_box_draw dd aCheck_box_draw
|
||||
;check_box_mouse dd aCheck_box_mouse
|
||||
;version_ch dd aVersion_ch
|
||||
|
||||
option_box_draw dd aOption_box_draw
|
||||
option_box_mouse dd aOption_box_mouse
|
||||
;version_op dd aVersion_op
|
||||
|
||||
;scrollbar_ver_draw dd aScrollbar_ver_draw
|
||||
;scrollbar_ver_mouse dd aScrollbar_ver_mouse
|
||||
;scrollbar_hor_draw dd aScrollbar_hor_draw
|
||||
;scrollbar_hor_mouse dd aScrollbar_hor_mouse
|
||||
;version_scrollbar dd aVersion_scrollbar
|
||||
|
||||
;dinamic_button_draw dd aDbutton_draw
|
||||
;dinamic_button_mouse dd aDbutton_mouse
|
||||
;version_dbutton dd aVersion_dbutton
|
||||
|
||||
;menu_bar_draw dd aMenu_bar_draw
|
||||
;menu_bar_mouse dd aMenu_bar_mouse
|
||||
;menu_bar_activate dd aMenu_bar_activate
|
||||
;version_menu_bar dd aVersion_menu_bar
|
||||
|
||||
;FileBrowser_draw dd aFileBrowser_draw
|
||||
;FileBrowser_mouse dd aFileBrowser_mouse
|
||||
;FileBrowser_key dd aFileBrowser_key
|
||||
;Version_FileBrowser dd aVersion_FileBrowser
|
||||
|
||||
PathShow_prepare dd sz_PathShow_prepare
|
||||
PathShow_draw dd sz_PathShow_draw
|
||||
;Version_path_show dd szVersion_path_show
|
||||
dd 0,0
|
||||
|
||||
;a_init db 'lib_init',0
|
||||
;a_version db 'version',0
|
||||
|
||||
aEdit_box_draw db 'edit_box_draw',0
|
||||
aEdit_box_key db 'edit_box_key',0
|
||||
aEdit_box_mouse db 'edit_box_mouse',0
|
||||
;aVersion_ed db 'version_ed',0
|
||||
|
||||
;aCheck_box_draw db 'check_box_draw',0
|
||||
;aCheck_box_mouse db 'check_box_mouse',0
|
||||
;aVersion_ch db 'version_ch',0
|
||||
|
||||
aOption_box_draw db 'option_box_draw',0
|
||||
aOption_box_mouse db 'option_box_mouse',0
|
||||
;aVersion_op db 'version_op',0
|
||||
|
||||
;aScrollbar_ver_draw db 'scrollbar_v_draw',0
|
||||
;aScrollbar_ver_mouse db 'scrollbar_v_mouse',0
|
||||
;aScrollbar_hor_draw db 'scrollbar_h_draw',0
|
||||
;aScrollbar_hor_mouse db 'scrollbar_h_mouse',0
|
||||
;aVersion_scrollbar db 'version_scrollbar',0
|
||||
|
||||
;aDbutton_draw db 'dbutton_draw',0
|
||||
;aDbutton_mouse db 'dbutton_mouse',0
|
||||
;aVersion_dbutton db 'version_dbutton',0
|
||||
|
||||
;aMenu_bar_draw db 'menu_bar_draw',0
|
||||
;aMenu_bar_mouse db 'menu_bar_mouse',0
|
||||
;aMenu_bar_activate db 'menu_bar_activate',0
|
||||
;aVersion_menu_bar db 'version_menu_bar',0
|
||||
|
||||
;aFileBrowser_draw db 'FileBrowser_draw',0
|
||||
;aFileBrowser_mouse db 'FileBrowser_mouse',0
|
||||
;aFileBrowser_key db 'FileBrowser_key',0
|
||||
;aVersion_FileBrowser db 'version_FileBrowser',0
|
||||
|
||||
sz_PathShow_prepare db 'PathShow_prepare',0
|
||||
sz_PathShow_draw db 'PathShow_draw',0
|
||||
;szVersion_path_show db 'version_PathShow',0
|
||||
include '../../develop/libraries/box_lib/import.inc'
|
||||
;---------------------------------------------------------------------
|
||||
PathShow_data_1:
|
||||
.type dd 0 ;+0
|
||||
|
||||
@@ -0,0 +1,256 @@
|
||||
; SPDX-License-Identifier: NOASSERTION
|
||||
;
|
||||
; System settings: read them from the kernel or from system.ini,
|
||||
; apply them to the kernel and save them to system.ini.
|
||||
|
||||
;---------------------------------------------------------------
|
||||
; Take the current values from the kernel, the mouse ones at system start only
|
||||
settings_read_boot:
|
||||
mcall 18,19,0
|
||||
mov [mouseSpeed],eax
|
||||
mcall 18,,2
|
||||
mov [mouseAccel],eax
|
||||
mcall 18,,6
|
||||
mov [mouseDelay],eax
|
||||
settings_read_system:
|
||||
mcall 26,5
|
||||
dec eax ; the kernel counts languages from 1
|
||||
cmp eax,LANGUAGES
|
||||
jb @f
|
||||
xor eax,eax
|
||||
@@:
|
||||
mov [language],eax
|
||||
mcall 26,11
|
||||
mov [lba],eax
|
||||
mcall 26,12
|
||||
mov [pci],eax
|
||||
mcall 18,8,1
|
||||
mov [speakerMute],eax
|
||||
mcall 48,9
|
||||
mov [fontSmoothing],eax
|
||||
mcall 48,11
|
||||
mov [fontHeight],eax
|
||||
; keep the font height within what the window shows and steps through
|
||||
font_height_limits:
|
||||
mov eax,[fontHeight]
|
||||
cmp eax,FONT_H_MIN
|
||||
jge @f
|
||||
mov eax,FONT_H_MIN
|
||||
@@:
|
||||
cmp eax,FONT_H_MAX
|
||||
jle @f
|
||||
mov eax,FONT_H_MAX
|
||||
@@:
|
||||
mov [fontHeight],eax
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------
|
||||
; Override the values with the ones stored in system.ini.
|
||||
; A missing or unknown value keeps the current one.
|
||||
settings_read_ini:
|
||||
mov esi,iniSettings
|
||||
.next:
|
||||
mov edi,[esi+12]
|
||||
test edi,edi
|
||||
jnz .word
|
||||
mov eax,[esi+8]
|
||||
invoke ini.get_int, sz_ini, [esi], [esi+4], [eax]
|
||||
jmp .store
|
||||
.word:
|
||||
and [iniWord],0
|
||||
invoke ini.get_str, sz_ini, [esi], [esi+4], iniWord, 4, 0
|
||||
mov eax,[iniWord]
|
||||
or eax,0x20202020 ; lowercase, zeroes become spaces
|
||||
xor edx,edx
|
||||
@@:
|
||||
cmp eax,[edi+4+edx*4]
|
||||
jz .found
|
||||
inc edx
|
||||
cmp edx,[edi]
|
||||
jb @b
|
||||
jmp .skip
|
||||
.found:
|
||||
mov eax,edx
|
||||
.store:
|
||||
mov edx,[esi+8]
|
||||
mov [edx],eax
|
||||
.skip:
|
||||
add esi,16
|
||||
cmp esi,iniSettings.end
|
||||
jb .next
|
||||
jmp font_height_limits
|
||||
|
||||
;---------------------------------------------------------------
|
||||
; Store the values to system.ini (all but the mouse ones).
|
||||
; Not ebx for the loop: ini_set_str returns with ebx = 13.
|
||||
settings_save_ini:
|
||||
mov esi,iniSettings
|
||||
.next:
|
||||
mov eax,[esi+8]
|
||||
mov eax,[eax]
|
||||
mov edi,[esi+12]
|
||||
test edi,edi
|
||||
jnz .word
|
||||
invoke ini.set_int, sz_ini, [esi], [esi+4], eax
|
||||
jmp .done
|
||||
.word:
|
||||
mov eax,[edi+4+eax*4]
|
||||
mov [iniWord],eax
|
||||
xor ecx,ecx ; length of the word
|
||||
@@:
|
||||
cmp byte[iniWord+ecx],' '
|
||||
jz @f
|
||||
inc ecx
|
||||
cmp ecx,4
|
||||
jb @b
|
||||
@@:
|
||||
invoke ini.set_str, sz_ini, [esi], [esi+4], iniWord, ecx
|
||||
.done:
|
||||
add esi,16
|
||||
cmp esi,iniSettings.saved
|
||||
jb .next
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------
|
||||
; Pass the values to the kernel, the mouse ones at system start only
|
||||
settings_apply_boot:
|
||||
mcall 18,19,1,[mouseSpeed]
|
||||
mcall 18,,3,[mouseAccel]
|
||||
mcall 18,,7,[mouseDelay]
|
||||
settings_apply:
|
||||
mov ecx,[language]
|
||||
inc ecx
|
||||
mcall 21,5
|
||||
mcall 21,11,[lba]
|
||||
mcall 21,12,[pci]
|
||||
mcall 48,10,[fontSmoothing]
|
||||
mcall 48,12,[fontHeight]
|
||||
; the speaker can only be toggled
|
||||
mcall 18,8,1
|
||||
cmp eax,[speakerMute]
|
||||
jz @f
|
||||
mcall 18,,2
|
||||
@@:
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------
|
||||
; Button style, desktop background and skin from the [style] section.
|
||||
; Used at system start only.
|
||||
style_apply:
|
||||
invoke ini.get_int, sz_ini, sz_style, sz_buttonStyle, 0
|
||||
mcall 48,1,eax
|
||||
|
||||
; the background is set by a program: bg_program with bg_param
|
||||
invoke ini.get_str, sz_ini, sz_style, sz_bgProgram, bgProgram, PATH_MAX, 0
|
||||
cmp byte[bgProgram],0
|
||||
jz .skin
|
||||
invoke ini.get_str, sz_ini, sz_style, sz_bgParam, bgParam, PATH_MAX, 0
|
||||
cmp byte[bgParam],'\' ; KIV param like '\S__/path/to/img'
|
||||
jnz @f
|
||||
mov [fileInfo.path],bgParam+4
|
||||
call wait_for_file
|
||||
@@:
|
||||
mcall 70,runBgProgram
|
||||
|
||||
.skin:
|
||||
invoke ini.get_str, sz_ini, sz_style, sz_skin, skinPath, PATH_MAX, 0
|
||||
cmp byte[skinPath],0
|
||||
jz @f
|
||||
mov [fileInfo.path],skinPath
|
||||
call wait_for_file
|
||||
mcall 48,8,skinPath
|
||||
@@:
|
||||
ret
|
||||
|
||||
; Files on /kolibrios and /usbhd may appear a few seconds after boot:
|
||||
; try to read the file for up to 5 seconds
|
||||
wait_for_file:
|
||||
mov edi,5
|
||||
@@:
|
||||
mcall 70,fileInfo
|
||||
test eax,eax
|
||||
jz @f
|
||||
mcall 5,100
|
||||
dec edi
|
||||
jnz @b
|
||||
@@:
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------
|
||||
; DATA
|
||||
; The languages of the kernel
|
||||
LANGUAGES = 8
|
||||
FONT_H_MIN = 9
|
||||
FONT_H_MAX = 99 ; two digits in the window
|
||||
PATH_MAX = 256
|
||||
|
||||
; Every value stored in system.ini: section, key, variable, words.
|
||||
; Words = 0 for a number, otherwise the list of words for 0, 1, 2...
|
||||
align 4
|
||||
iniSettings:
|
||||
dd sz_system, sz_language, language, wordsLanguage
|
||||
dd sz_system, sz_fontHeight, fontHeight, 0
|
||||
dd sz_system, sz_fontSmooth, fontSmoothing, wordsSmoothing
|
||||
dd sz_lowLevel, sz_lba, lba, wordsOnOff
|
||||
dd sz_lowLevel, sz_pci, pci, wordsOnOff
|
||||
dd sz_lowLevel, sz_speaker, speakerMute, wordsSpeaker
|
||||
.saved: ; the mouse is configured by its own application
|
||||
dd sz_mouse, sz_speed, mouseSpeed, 0
|
||||
dd sz_mouse, sz_accel, mouseAccel, 0
|
||||
dd sz_mouse, sz_dblClick, mouseDelay, 0
|
||||
.end:
|
||||
|
||||
wordsOnOff dd 2, 'off ','on '
|
||||
wordsSpeaker dd 2, 'on ','off ' ; the ini keeps 'speaker on', not 'mute'
|
||||
wordsSmoothing dd 3, 'off ','on ','sbp '
|
||||
wordsLanguage dd LANGUAGES, 'en ','fi ','de ','ru ','fr ','et ','es ','it '
|
||||
|
||||
runBgProgram:
|
||||
dd 7, 0, bgParam, 0, 0
|
||||
db 0
|
||||
dd bgProgram
|
||||
|
||||
fileInfo:
|
||||
dd 0, 0, 0, 4, fileBuf
|
||||
db 0
|
||||
.path dd ?
|
||||
|
||||
sz_ini db "/sys/settings/system.ini",0
|
||||
|
||||
sz_system db "system",0
|
||||
sz_language db "language",0
|
||||
sz_fontHeight db "font height",0
|
||||
sz_fontSmooth db "font smoothing",0
|
||||
sz_speaker db "speaker",0
|
||||
|
||||
sz_lowLevel db "low-level",0
|
||||
sz_lba db "LBA",0
|
||||
sz_pci db "PCI",0
|
||||
|
||||
sz_mouse db "mouse",0
|
||||
sz_speed db "speed",0
|
||||
sz_accel db "acceleration",0
|
||||
sz_dblClick db "double_click_delay",0
|
||||
|
||||
sz_style db "style",0
|
||||
sz_buttonStyle db "buttons_gradient",0
|
||||
sz_bgProgram db "bg_program",0
|
||||
sz_bgParam db "bg_param",0
|
||||
sz_skin db "skin",0
|
||||
|
||||
; not stored in the program file
|
||||
language dd ?
|
||||
lba dd ?
|
||||
pci dd ?
|
||||
speakerMute dd ?
|
||||
fontSmoothing dd ?
|
||||
fontHeight dd ?
|
||||
mouseSpeed dd ?
|
||||
mouseAccel dd ?
|
||||
mouseDelay dd ?
|
||||
|
||||
iniWord dd ? ; a word of system.ini
|
||||
fileBuf dd ?
|
||||
bgProgram rb PATH_MAX
|
||||
bgParam rb PATH_MAX
|
||||
skinPath rb PATH_MAX
|
||||
+342
-476
@@ -1,462 +1,316 @@
|
||||
; SPDX-License-Identifier: NOASSERTION
|
||||
;
|
||||
; System settings.
|
||||
; SETUP BOOT - apply the settings from system.ini (run from AUTORUN.DAT)
|
||||
; SETUP - window to change and save them
|
||||
;
|
||||
; Texts are UTF-8
|
||||
|
||||
; Text encoded with Code Page 866 - Cyrillic
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; SYSTEM SETTINGS ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
format binary as ""
|
||||
use32
|
||||
org 0
|
||||
|
||||
db 'MENUET01'
|
||||
dd 1
|
||||
dd START
|
||||
dd IM_END
|
||||
dd I_END
|
||||
dd I_END
|
||||
dd param
|
||||
dd 0
|
||||
include '../../macros.inc'
|
||||
format meos 01
|
||||
entry START
|
||||
stack 4096
|
||||
|
||||
include '../../proc32.inc'
|
||||
include '../../macros.inc'
|
||||
include '../../dll.inc'
|
||||
;---------------------------------------------------------------
|
||||
BootSettings:
|
||||
; Set system language
|
||||
mov word[param],0
|
||||
invoke ini.get_str, sz_ini, sz_system, sz_language, param, 2, 0
|
||||
mov ax, [param]
|
||||
or ax, 0x2020 ; convert to lowercase
|
||||
mov ecx,langMarks.size/2
|
||||
mov edi,langMarks
|
||||
repnz scasw
|
||||
jnz @f
|
||||
neg ecx
|
||||
add ecx,langMarks.size/2
|
||||
mcall 21,5
|
||||
@@:
|
||||
|
||||
; Set font smoothing
|
||||
mov dword[param],0
|
||||
invoke ini.get_str, sz_ini, sz_system, sz_fontSmooth, param, 4, 0
|
||||
xor ecx,ecx
|
||||
mov eax,[param]
|
||||
or eax,0x20202020
|
||||
cmp eax,'off '
|
||||
jz @f
|
||||
inc ecx
|
||||
cmp eax,'on '
|
||||
jz @f
|
||||
cmp eax,'sbp '
|
||||
jnz .skipFont
|
||||
inc ecx
|
||||
@@:
|
||||
mcall 48,10
|
||||
.skipFont:
|
||||
|
||||
; Enable/disable system speaker
|
||||
mov dword[param],0
|
||||
invoke ini.get_str, sz_ini, sz_system, sz_speaker, param, 4, 0
|
||||
mov eax,[param]
|
||||
or eax,0x20202020
|
||||
cmp eax,'off '
|
||||
jz @f
|
||||
cmp eax,'on '
|
||||
jnz .skipSpeaker
|
||||
inc [speaker_mute]
|
||||
@@:
|
||||
call _speaker_mute
|
||||
.skipSpeaker:
|
||||
|
||||
; Set font size
|
||||
invoke ini.get_int, sz_ini, sz_system, sz_fontSize, 9
|
||||
mov ecx,eax
|
||||
mcall 48,12
|
||||
|
||||
; Set mouse speed
|
||||
invoke ini.get_int, sz_ini, sz_mouse, sz_speed, 1
|
||||
mov edx,eax
|
||||
mcall 18,19,1
|
||||
|
||||
; Set mouse acceleration
|
||||
invoke ini.get_int, sz_ini, sz_mouse, sz_acceleration, 1
|
||||
mov edx,eax
|
||||
mcall 18,19,3
|
||||
|
||||
; Set mouse double click delay
|
||||
invoke ini.get_int, sz_ini, sz_mouse, sz_double_click_delay, 1
|
||||
mov edx,eax
|
||||
mcall 18,19,7
|
||||
|
||||
; Enable/disable LBA access for applications
|
||||
mov dword[param],0
|
||||
invoke ini.get_str, sz_ini, sz_low_level, sz_lba, param, 4, 0
|
||||
xor ecx,ecx
|
||||
mov eax,[param]
|
||||
or eax,0x20202020
|
||||
cmp eax,'off '
|
||||
jz @f
|
||||
cmp eax,'on '
|
||||
jnz .skipLBA
|
||||
inc ecx
|
||||
@@:
|
||||
mcall 21,11
|
||||
.skipLBA:
|
||||
|
||||
; Enable/disable PCI access for applications
|
||||
mov dword[param],0
|
||||
invoke ini.get_str, sz_ini, sz_low_level, sz_pci, param, 4, 0
|
||||
xor ecx,ecx
|
||||
mov eax,[param]
|
||||
or eax,0x20202020
|
||||
cmp eax,'off '
|
||||
jz @f
|
||||
cmp eax,'on '
|
||||
jnz close
|
||||
inc ecx
|
||||
@@:
|
||||
mcall 21,12
|
||||
jmp close
|
||||
;---------------------------------------------------------------
|
||||
START:
|
||||
mcall 68,11
|
||||
stdcall dll.Load, @IMPORT
|
||||
push eax
|
||||
test eax,eax
|
||||
jnz close
|
||||
jnz quit
|
||||
|
||||
cmp [param],dword 'BOOT'
|
||||
jz BootSettings
|
||||
pop eax
|
||||
GetCommandLine eax
|
||||
cmp dword[eax],'BOOT'
|
||||
jnz @f
|
||||
|
||||
; get current settings
|
||||
mcall 26,5
|
||||
dec eax
|
||||
mov [syslang],eax
|
||||
call settings_read_boot
|
||||
call settings_read_ini
|
||||
call settings_apply_boot
|
||||
call style_apply
|
||||
quit:
|
||||
mcall -1
|
||||
|
||||
mcall 26,11
|
||||
mov [lba_read],eax
|
||||
|
||||
mcall 26,12
|
||||
mov [pci_acc],eax
|
||||
|
||||
mcall 18,8,1
|
||||
mov [speaker_mute],eax
|
||||
|
||||
mcall 48,9
|
||||
mov [fontSmoothing],eax
|
||||
|
||||
mcall 48,11
|
||||
mov [fontSize],eax
|
||||
|
||||
loadtxt:
|
||||
cmp [syslang],3
|
||||
jz .ru
|
||||
cmp [syslang],5
|
||||
jz .et
|
||||
mov [text],texteng
|
||||
jmp draw_window
|
||||
.et:
|
||||
mov [text],textet
|
||||
jmp draw_window
|
||||
.ru:
|
||||
mov [text],textrus
|
||||
|
||||
draw_window:
|
||||
mcall 12,1
|
||||
mov ecx,50*65536+32*(4+stringsAmount)
|
||||
mcall 0,<50,700>,,0xB4111199,0,title
|
||||
; Main buttons
|
||||
mov eax,8
|
||||
mov ecx,6*65536+26
|
||||
mov edx,4
|
||||
mov esi,0x5580c0
|
||||
mov ebp,stringsAmount
|
||||
@@:
|
||||
mcall ,<490,24>
|
||||
call settings_read_system
|
||||
; the checkbox image is shared by @RESHARE, 0 if it is not running
|
||||
mcall 68,22,sz_checkbox,0,0
|
||||
mov [checkboxImage],eax
|
||||
|
||||
;---------------------------------------------------------------
|
||||
draw_window:
|
||||
mov eax,[language]
|
||||
mov eax,[texts+eax*4]
|
||||
mov [text],eax
|
||||
|
||||
mcall 12,1
|
||||
mcall 48,3,sc,sizeof.system_colors
|
||||
mov byte[sc.work_text+3],FONT
|
||||
mov byte[sc.work_button_text+3],FONT
|
||||
mcall 48,4
|
||||
lea ecx,[eax+(50 shl 16)+CLIENT_H+4]
|
||||
mov edx,[sc.work]
|
||||
or edx,0x34000000
|
||||
mcall 0,<50,CLIENT_W+9>,,,0,title
|
||||
|
||||
; a row: label, value (drawn by draw_values), '-' and '+' buttons
|
||||
xor ebp,ebp
|
||||
.row:
|
||||
imul edi,ebp,ROW_STEP
|
||||
add edi,TOP ; y of the row
|
||||
mov ecx,edi
|
||||
shl ecx,16
|
||||
add ecx,ROW_H-1 ; the button is 1 pixel bigger than given
|
||||
lea edx,[FIRST_ROW_BUTTON+ebp*2]
|
||||
mcall 8,<BUTTON1_X,ROW_H-1>,,,[sc.work_button]
|
||||
lea edx,[FIRST_ROW_BUTTON+1+ebp*2]
|
||||
mcall 8,<BUTTON2_X,ROW_H-1>
|
||||
; the kernel leaves the corners of a button out: one frame for both,
|
||||
; its right corners stay out
|
||||
mov edx,[sc.work_button]
|
||||
shr edx,1
|
||||
and edx,0x7F7F7F ; the border colour of a button
|
||||
mov cx,1
|
||||
mcall 13,<BUTTON1_X,BUTTON2_X+ROW_H-1-BUTTON1_X>
|
||||
add ecx,(ROW_H-1) shl 16
|
||||
mcall 13
|
||||
|
||||
lea ebx,[edi+TEXT_DY+(LABEL_X shl 16)]
|
||||
mov ecx,ebp
|
||||
call get_text
|
||||
mcall 4,,[sc.work_text]
|
||||
|
||||
lea ebx,[edi+TEXT_DY+((BUTTON1_X+8) shl 16)]
|
||||
lea edx,[glyphs+ebp*4]
|
||||
mcall 4,,[sc.work_button_text]
|
||||
lea ebx,[edi+TEXT_DY+((BUTTON2_X+8) shl 16)]
|
||||
lea edx,[glyphs+2+ebp*4]
|
||||
mcall 4
|
||||
|
||||
inc ebp
|
||||
cmp ebp,ROWS
|
||||
jb .row
|
||||
|
||||
; group box of the checkboxes: a frame, its title over it on the work colour
|
||||
mcall 13,<GROUP_X,GROUP_W>,<GROUP_Y,GROUP_H>,[sc.work_graph]
|
||||
mcall 13,<GROUP_X+1,GROUP_W-2>,<GROUP_Y+1,GROUP_H-2>,[sc.work]
|
||||
mov ecx,T_GROUP
|
||||
call get_text
|
||||
mov ecx,[sc.work_text]
|
||||
or ecx,0x40000000
|
||||
mcall 4,<GROUP_TITLE_X,GROUP_TITLE_Y>,,,,[sc.work]
|
||||
|
||||
; The checkboxes are spread over the group, the last one ends at its end.
|
||||
; LBA and PCI are fixed, so the step only depends on the speaker label.
|
||||
mov ecx,T_SPEAKER
|
||||
call get_text
|
||||
mov eax,ITEM_END-ITEM_X-CHECK_SIZE-8
|
||||
.length:
|
||||
mov cl,[edx]
|
||||
inc edx
|
||||
mcall ,<526,24>
|
||||
inc edx
|
||||
mcall ,<562,120>
|
||||
inc edx
|
||||
add ecx,32*65536
|
||||
dec ebp
|
||||
jnz @b
|
||||
; APPLY ALL
|
||||
add ecx,32*65536
|
||||
mcall ,<514,168>,,3,0x005588dd
|
||||
; SAVE ALL
|
||||
add ecx,32*65536
|
||||
dec edx
|
||||
mcall
|
||||
test cl,cl
|
||||
jz .step
|
||||
and cl,0xC0
|
||||
cmp cl,0x80 ; UTF-8 continuation byte
|
||||
jz .length
|
||||
sub eax,8
|
||||
jmp .length
|
||||
.step:
|
||||
shr eax,1
|
||||
mov [checkStep],eax
|
||||
|
||||
; a checkbox: the box (drawn by draw_values), then the label, both under
|
||||
; one button up to the end of the group. The next button covers the rest.
|
||||
xor ebp,ebp
|
||||
.check:
|
||||
mov edi,[checkStep]
|
||||
imul edi,ebp
|
||||
add edi,ITEM_X ; x of the box
|
||||
lea ebx,[edi+CHECK_SIZE+8]
|
||||
shl ebx,16
|
||||
add ebx,CHECK_Y+TEXT_DY
|
||||
call check_label
|
||||
mcall 4,,[sc.work_text]
|
||||
mov ebx,edi
|
||||
shl ebx,16
|
||||
add ebx,ITEM_END
|
||||
sub ebx,edi
|
||||
lea edx,[FIRST_CHECK_BUTTON+BT_HIDE+BT_NOFRAME+ebp]
|
||||
mcall 8,,<CHECK_Y,ROW_H-1>
|
||||
inc ebp
|
||||
cmp ebp,CHECKS
|
||||
jb .check
|
||||
|
||||
mcall 12,2
|
||||
|
||||
draw_infotext:
|
||||
mov eax,[syslang]
|
||||
mov edi,[text]
|
||||
lea esi,[eax*8+langs]
|
||||
add edi,28
|
||||
movsd
|
||||
movsd
|
||||
add edi,LLL-8
|
||||
;---------------------------------------------------------------
|
||||
draw_values:
|
||||
mov edx,languageNames
|
||||
mov ecx,[language]
|
||||
call nth_string
|
||||
mov [valueText],edx
|
||||
|
||||
mov eax,[lba_read]
|
||||
call onoff
|
||||
mov [edi],ebx
|
||||
|
||||
mov eax,[pci_acc]
|
||||
call onoff
|
||||
mov [edi+LLL],ebx
|
||||
|
||||
mov eax,[speaker_mute]
|
||||
call onoff
|
||||
mov [edi+LLL*2],ebx
|
||||
|
||||
mov ebx,'SUBP'
|
||||
mov ecx,'IXEL'
|
||||
cmp [fontSmoothing],2
|
||||
jz @f
|
||||
mov eax,[fontSmoothing]
|
||||
call onoff
|
||||
mov ecx,' '
|
||||
mov edx,sz_subpixel
|
||||
mov ecx,[fontSmoothing]
|
||||
cmp ecx,2
|
||||
jae @f
|
||||
add ecx,T_OFF
|
||||
call get_text
|
||||
@@:
|
||||
mov [edi+LLL*3],ebx
|
||||
mov [edi+LLL*3+4],ecx
|
||||
mov [valueText+4],edx
|
||||
|
||||
mov eax,[fontSize]
|
||||
mov bl, 10
|
||||
mov eax,[fontHeight]
|
||||
mov bl,10
|
||||
div bl
|
||||
add ax, '00'
|
||||
mov [edi+LLL*4],ax
|
||||
; draw text
|
||||
mcall 13,<342,96>,32*stringsAmount,80111199h
|
||||
mov eax,4
|
||||
mov ebx,6*65536+11
|
||||
mov ecx,1ffffffh
|
||||
mov edx,[text]
|
||||
mov esi,LLL
|
||||
mov ebp,stringsAmount
|
||||
newline:
|
||||
mcall
|
||||
add ebx,32
|
||||
add edx,esi
|
||||
dec ebp
|
||||
jnz newline
|
||||
add ax,'00'
|
||||
mov word[heightText],ax
|
||||
mov [valueText+8],heightText
|
||||
|
||||
mov ebp,2
|
||||
add ebx,32
|
||||
@@:
|
||||
mcall
|
||||
add ebx,32
|
||||
add edx,esi
|
||||
dec ebp
|
||||
jnz @b
|
||||
; each value in a light box framed on three sides, the button is the fourth,
|
||||
; the left corners are cut off
|
||||
xor ebp,ebp
|
||||
.row:
|
||||
imul edi,ebp,ROW_STEP
|
||||
add edi,TOP
|
||||
mov ecx,edi
|
||||
shl ecx,16
|
||||
add ecx,ROW_H
|
||||
mcall 13,<VALUE_X+1,VALUE_W-1>,,[sc.work_graph]
|
||||
add ecx,(1 shl 16)-2
|
||||
mcall 13,<VALUE_X,VALUE_W>
|
||||
; sunken, the inner lines of a button reversed: three boxes, each 1 pixel
|
||||
; smaller, leave darker lines left and top and lighter right and bottom
|
||||
mov edx,[sc.work_light]
|
||||
mov eax,edx
|
||||
shr eax,3
|
||||
and eax,0x1F1F1F
|
||||
sub edx,eax ; 1/8 darker
|
||||
mcall 13,<VALUE_X+1,VALUE_W-1>
|
||||
mov edx,[sc.work_light]
|
||||
or edx,0x1F1F1F ; lighter
|
||||
add ecx,(1 shl 16)-1
|
||||
mcall 13,<VALUE_X+2,VALUE_W-2>
|
||||
dec ecx
|
||||
mcall 13,<VALUE_X+2,VALUE_W-3>,,[sc.work_light]
|
||||
lea ebx,[edi+TEXT_DY+((VALUE_X+VALUE_PAD) shl 16)]
|
||||
mov edx,[valueText+ebp*4]
|
||||
mcall 4,,[sc.work_text]
|
||||
inc ebp
|
||||
cmp ebp,ROWS
|
||||
jb .row
|
||||
|
||||
; checkboxes: a frame, light inside, the @RESHARE image when set
|
||||
xor ebp,ebp
|
||||
.check:
|
||||
mov ebx,[checkStep]
|
||||
imul ebx,ebp
|
||||
add ebx,ITEM_X
|
||||
shl ebx,16
|
||||
add ebx,CHECK_SIZE
|
||||
mcall 13,,<CHECK_BOX_Y,CHECK_SIZE>,[sc.work_graph]
|
||||
add ebx,(1 shl 16)-2
|
||||
mcall 13,,<CHECK_BOX_Y+1,CHECK_SIZE-2>,[sc.work_light]
|
||||
mov eax,[checks+ebp*8]
|
||||
mov eax,[eax]
|
||||
xor eax,[checks+ebp*8+4]
|
||||
jz .next
|
||||
mov edx,ebx
|
||||
mov dx,CHECK_BOX_Y+1
|
||||
mov ebx,[checkboxImage]
|
||||
test ebx,ebx ; no @RESHARE: the box stays empty
|
||||
jz .next
|
||||
mcall 7,,<CHECK_SIZE-2,CHECK_SIZE-2>
|
||||
.next:
|
||||
inc ebp
|
||||
cmp ebp,CHECKS
|
||||
jb .check
|
||||
|
||||
;---------------------------------------------------------------
|
||||
still:
|
||||
mcall 10
|
||||
cmp eax,1
|
||||
jz draw_window
|
||||
|
||||
cmp eax,2
|
||||
jz key
|
||||
|
||||
jz .key
|
||||
cmp eax,3
|
||||
jz button
|
||||
jnz still
|
||||
|
||||
jmp still
|
||||
;---------------------------------------------------------------
|
||||
key:
|
||||
mcall 2
|
||||
jmp still
|
||||
;---------------------------------------------------------------
|
||||
button:
|
||||
mcall 17
|
||||
shr eax,8
|
||||
call dword[eax*4+buttonTab-4]
|
||||
jmp draw_infotext
|
||||
close:
|
||||
pop eax
|
||||
mcall -1
|
||||
language1:
|
||||
dec [syslang]
|
||||
jns @f
|
||||
mov [syslang],7
|
||||
jmp @f
|
||||
language2:
|
||||
inc [syslang]
|
||||
cmp [syslang],8
|
||||
jc @f
|
||||
mov [syslang],0
|
||||
@@:
|
||||
pop eax
|
||||
jmp loadtxt
|
||||
LBA1:
|
||||
btr [lba_read],0
|
||||
ret
|
||||
LBA2:
|
||||
bts [lba_read],0
|
||||
ret
|
||||
PCI1:
|
||||
btr [pci_acc],0
|
||||
ret
|
||||
PCI2:
|
||||
bts [pci_acc],0
|
||||
ret
|
||||
SPEAKER1:
|
||||
btr [speaker_mute],0
|
||||
ret
|
||||
SPEAKER2:
|
||||
bts [speaker_mute],0
|
||||
ret
|
||||
font1:
|
||||
cmp [fontSmoothing],0
|
||||
jz @f
|
||||
dec [fontSmoothing]
|
||||
ret
|
||||
font2:
|
||||
cmp [fontSmoothing],2
|
||||
jz @f
|
||||
inc [fontSmoothing]
|
||||
ret
|
||||
fontSize1:
|
||||
cmp [fontSize],10
|
||||
jc @f
|
||||
dec [fontSize]
|
||||
@@:
|
||||
ret
|
||||
fontSize2:
|
||||
inc [fontSize]
|
||||
ret
|
||||
apply_all:
|
||||
call _lba_read
|
||||
call _pci_acc
|
||||
call _speaker_mute
|
||||
call fontApply
|
||||
call fontSizeApply
|
||||
_syslang:
|
||||
mov ecx,[syslang]
|
||||
cmp eax,1
|
||||
jz quit
|
||||
sub eax,FIRST_ROW_BUTTON
|
||||
jb still ; 0: no button after all
|
||||
cmp eax,FIRST_CHECK_BUTTON-FIRST_ROW_BUTTON
|
||||
jae .check
|
||||
|
||||
; '-' or '+' of a row: step the value within the limits of the row
|
||||
shr eax,1 ; eax = row, CF = '+'
|
||||
lea esi,[eax*3]
|
||||
lea esi,[rows+esi*4]
|
||||
mov edi,[esi]
|
||||
mov ecx,[edi]
|
||||
jc .plus
|
||||
cmp ecx,[esi+4]
|
||||
jbe still
|
||||
dec ecx
|
||||
jmp .set
|
||||
.plus:
|
||||
cmp ecx,[esi+8]
|
||||
jae still
|
||||
inc ecx
|
||||
mcall 21,5
|
||||
ret
|
||||
_lba_read:
|
||||
mcall 21,11,[lba_read]
|
||||
ret
|
||||
_pci_acc:
|
||||
mcall 21,12,[pci_acc]
|
||||
ret
|
||||
fontApply:
|
||||
mcall 48,10,[fontSmoothing]
|
||||
ret
|
||||
fontSizeApply:
|
||||
mcall 48,12,[fontSize]
|
||||
ret
|
||||
_speaker_mute:
|
||||
mcall 18,8,1
|
||||
cmp [speaker_mute],eax
|
||||
jz @f
|
||||
inc ecx
|
||||
mcall 18
|
||||
@@:
|
||||
ret
|
||||
.set:
|
||||
mov [edi],ecx
|
||||
push eax
|
||||
call apply_and_save
|
||||
pop eax
|
||||
cmp eax,1 ; the language and the font smoothing
|
||||
jbe draw_window ; change all the texts: repaint the window
|
||||
jmp draw_values
|
||||
|
||||
.check:
|
||||
mov eax,[checks-(FIRST_CHECK_BUTTON-FIRST_ROW_BUTTON)*8+eax*8]
|
||||
xor dword[eax],1
|
||||
call apply_and_save
|
||||
jmp draw_values
|
||||
|
||||
.key:
|
||||
mcall 2
|
||||
jmp still
|
||||
|
||||
;---------------------------------------------------------------
|
||||
onoff:
|
||||
cmp [syslang],3
|
||||
jz .ru
|
||||
cmp [syslang],5
|
||||
jz .et
|
||||
mov ebx,'OFF '
|
||||
test eax,eax
|
||||
jz @f
|
||||
mov ebx,'ON '
|
||||
ret
|
||||
.ru:
|
||||
mov ebx,'НЕТ '
|
||||
test eax,eax
|
||||
jz @f
|
||||
mov ebx,'ДА '
|
||||
ret
|
||||
.et:
|
||||
mov ebx,'V─L.'
|
||||
test eax,eax
|
||||
jz @f
|
||||
mov ebx,'SEES'
|
||||
; every change takes effect at once and is kept in system.ini
|
||||
apply_and_save:
|
||||
call settings_apply
|
||||
jmp settings_save_ini
|
||||
|
||||
; edx = label of the checkbox ebp
|
||||
check_label:
|
||||
mov edx,[checkLabels+ebp*4]
|
||||
test edx,edx
|
||||
jnz @f
|
||||
mov ecx,T_SPEAKER
|
||||
call get_text
|
||||
@@:
|
||||
ret
|
||||
;---------------------------------------------------------------
|
||||
saveAll:
|
||||
; system language
|
||||
mov eax,[syslang]
|
||||
mov ax, word[eax*2+langMarks]
|
||||
mov [param],eax
|
||||
invoke ini.set_str, sz_ini, sz_system, sz_language, param, 2
|
||||
|
||||
; font size
|
||||
invoke ini.set_int, sz_ini, sz_system, sz_fontSize, [fontSize]
|
||||
|
||||
; font smoothing
|
||||
mov dword[param],'off'
|
||||
cmp [fontSmoothing],0
|
||||
jz @f
|
||||
mov dword[param],'on '
|
||||
cmp [fontSmoothing],1
|
||||
jz @f
|
||||
mov dword[param],'sbp'
|
||||
; edx = string number ecx of the window language
|
||||
get_text:
|
||||
mov edx,[text]
|
||||
; edx = string number ecx of the zero separated list at edx
|
||||
nth_string:
|
||||
jecxz .done
|
||||
@@:
|
||||
invoke ini.set_str, sz_ini, sz_system, sz_fontSmooth, param, 3
|
||||
|
||||
; system speaker
|
||||
mov dword[param],'off'
|
||||
cmp [speaker_mute],0
|
||||
jz @f
|
||||
mov dword[param],'on '
|
||||
@@:
|
||||
invoke ini.set_str, sz_ini, sz_system, sz_speaker, param, 3
|
||||
|
||||
; LBA access for applications
|
||||
mov dword[param],'off'
|
||||
cmp [lba_read],0
|
||||
jz @f
|
||||
mov dword[param],'on '
|
||||
@@:
|
||||
invoke ini.set_str, sz_ini, sz_low_level, sz_lba, param, 3
|
||||
|
||||
; PCI access for applications
|
||||
mov dword[param],'off'
|
||||
cmp [pci_acc],0
|
||||
jz @f
|
||||
mov dword[param],'on '
|
||||
@@:
|
||||
invoke ini.set_str, sz_ini, sz_low_level, sz_pci, param, 3
|
||||
inc edx
|
||||
cmp byte[edx-1],0
|
||||
jnz @b
|
||||
loop @b
|
||||
.done:
|
||||
ret
|
||||
|
||||
;---------------------------------------------------------------
|
||||
; DATA
|
||||
align 4
|
||||
buttonTab: ; button handler pointers: -,+,apply
|
||||
dd close
|
||||
dd saveAll
|
||||
dd apply_all
|
||||
dd language1
|
||||
dd language2
|
||||
dd _syslang
|
||||
dd LBA1
|
||||
dd LBA2
|
||||
dd _lba_read
|
||||
dd PCI1
|
||||
dd PCI2
|
||||
dd _pci_acc
|
||||
dd SPEAKER1
|
||||
dd SPEAKER2
|
||||
dd _speaker_mute
|
||||
dd font1
|
||||
dd font2
|
||||
dd fontApply
|
||||
dd fontSize1
|
||||
dd fontSize2
|
||||
dd fontSizeApply
|
||||
|
||||
@IMPORT:
|
||||
library libini, 'libini.obj'
|
||||
import libini, \
|
||||
@@ -465,76 +319,88 @@ import libini, \
|
||||
ini.set_str, 'ini_set_str',\
|
||||
ini.set_int, 'ini_set_int'
|
||||
|
||||
title db "System settings",0
|
||||
sz_ini db "/sys/settings/system.ini",0
|
||||
ROWS = 3
|
||||
CHECKS = 3
|
||||
FIRST_ROW_BUTTON = 10 ; row N has '-' = 10+N*2 and '+' = 11+N*2
|
||||
FIRST_CHECK_BUTTON = 20
|
||||
FONT = 0xB0 ; text flags: zero terminated, 8x16 UTF-8
|
||||
|
||||
sz_system db "system",0
|
||||
sz_language db "language",0
|
||||
sz_fontSize db "font height",0
|
||||
sz_fontSmooth db "font smoothing",0
|
||||
sz_speaker db "speaker mute",0
|
||||
|
||||
sz_mouse db "mouse",0
|
||||
sz_speed db "speed",0
|
||||
sz_acceleration db "acceleration",0
|
||||
sz_double_click_delay db "double_click_delay",0
|
||||
|
||||
sz_low_level db "low-level",0
|
||||
sz_lba db "LBA",0
|
||||
sz_pci db "PCI",0
|
||||
|
||||
LLL = 56
|
||||
stringsAmount = 6
|
||||
; layout of the client area: controls ROW_H high, GAP empty pixels apart,
|
||||
; EDGE to the window border, GAP at the top
|
||||
LABEL_CHARS = 20 ; the longest label, Spanish
|
||||
GAP = 12
|
||||
EDGE = 8
|
||||
TOP = GAP
|
||||
ROW_H = 24
|
||||
ROW_STEP = ROW_H + GAP
|
||||
TEXT_DY = 5 ; the capitals, rows 2..11 of the font, centred in ROW_H
|
||||
LABEL_X = EDGE - 1 ; column 0 of a letter is empty: aligned with the group frame
|
||||
VALUE_X = LABEL_X + LABEL_CHARS*8 + GAP
|
||||
VALUE_PAD = GAP
|
||||
VALUE_W = 8*8 + VALUE_PAD*2
|
||||
BUTTON1_X = VALUE_X + VALUE_W ; right after the value box
|
||||
BUTTON2_X = BUTTON1_X + ROW_H - 1 ; the buttons share a border
|
||||
CLIENT_W = BUTTON2_X + ROW_H + EDGE
|
||||
GROUP_X = EDGE
|
||||
GROUP_W = CLIENT_W - EDGE*2
|
||||
GROUP_Y = TOP + ROWS*ROW_STEP + 5 ; GAP to the capitals of the title
|
||||
GROUP_TITLE_Y = GROUP_Y - 7 ; the frame crosses the capitals
|
||||
CHECK_Y = GROUP_Y + 1 + GAP ; the row of the checkboxes
|
||||
GROUP_H = 1 + GAP + ROW_H + GAP + 1
|
||||
CHECK_SIZE = 15
|
||||
CHECK_BOX_Y = CHECK_Y + (ROW_H-CHECK_SIZE)/2
|
||||
ITEM_X = GROUP_X + 1 + GAP
|
||||
ITEM_END = GROUP_X + GROUP_W - GAP ; the last column of a letter is empty
|
||||
GROUP_TITLE_X = ITEM_X - 8 - 1 ; a space, then a letter from its column 1
|
||||
CLIENT_H = GROUP_Y + GROUP_H + EDGE
|
||||
|
||||
; variable, min, max of every row
|
||||
align 4
|
||||
langs:
|
||||
db 'ENGLISH FINNISH GERMAN RUSSIAN FRENCH ESTONIANSPANISH ITALIAN '
|
||||
sz langMarks, 'en','fi','de','ru','fr','et','es','it'
|
||||
rows:
|
||||
dd language, 0, LANGUAGES-1
|
||||
dd fontSmoothing, 0, 2
|
||||
dd fontHeight, FONT_H_MIN, FONT_H_MAX
|
||||
|
||||
textrus:
|
||||
db 'Язык системы : < > Применить'
|
||||
db 'Включить LBA : - + Применить'
|
||||
db 'Доступ к шине PCI : - + Применить'
|
||||
db 'Выключить SPEAKER : - + Применить'
|
||||
db 'Сглаживание шрифтов : - + Применить'
|
||||
db 'Высота шрифтов : - + Применить'
|
||||
; variable and the value of it that means 'not checked'
|
||||
checks dd lba,0, pci,0, speakerMute,1
|
||||
checkLabels dd sz_lba, sz_pci, 0 ; 0: the speaker label of the language
|
||||
|
||||
db 'ВНИМАНИЕ: Применить все'
|
||||
db 'НЕ ЗАБУДЬТЕ СОХРАНИТЬ НАСТРОЙКИ Сохранить все'
|
||||
glyphs db '<',0,'>',0,'<',0,'>',0,'-',0,'+',0
|
||||
sz_subpixel db 'Subpixel',0
|
||||
languageNames db 'English',0,'Finnish',0,'German',0,'Russian',0
|
||||
db 'French',0,'Estonian',0,'Spanish',0,'Italian',0
|
||||
|
||||
texteng:
|
||||
db 'System language : < > Apply '
|
||||
db 'Allow LBA access : - + Apply '
|
||||
db 'Allow PCI access : - + Apply '
|
||||
db 'Disable SPEAKER : - + Apply '
|
||||
db 'Font smoothing : - + Apply '
|
||||
db 'Font height : - + Apply '
|
||||
title db "System settings",0
|
||||
sz_checkbox db "CHECKBOX",0
|
||||
|
||||
db 'NOTE: Apply all '
|
||||
db 'SAVE YOUR SETTINGS BEFORE QUITING KOLIBRI Save all '
|
||||
; Texts of the window languages: zero terminated strings in this order
|
||||
; (row labels, group title, speaker label, 'off', 'on')
|
||||
T_GROUP = ROWS
|
||||
T_SPEAKER = ROWS + 1
|
||||
T_OFF = ROWS + 2
|
||||
|
||||
textet:
|
||||
db 'S№steemi keel : < > Kinnita '
|
||||
db 'LBA lugemine lubatud : - + Kinnita '
|
||||
db 'PCI juurdepффs programm. : - + Kinnita '
|
||||
db 'Disable SPEAKER : - + Kinnita '
|
||||
db 'Font smoothing : - + Kinnita '
|
||||
db 'Font height : - + Kinnita '
|
||||
; the texts of every kernel language, English where there is no translation
|
||||
texts dd texteng, texteng, texteng, textrus, texteng, texteng, textspa, texteng
|
||||
|
||||
db 'M─RKUS: Kinnita kїik '
|
||||
db 'SALVESTA SEADED ENNE KOLIBRIST V─LJUMIST Salvesta kїik'
|
||||
texteng db 'System language',0, 'Font smoothing',0, 'Font height',0
|
||||
db ' Access settings ',0, 'Speaker',0
|
||||
db 'Off',0, 'On',0
|
||||
|
||||
IM_END:
|
||||
textspa db 'Idioma del sistema',0, 'Suavizado de fuentes',0, 'Altura de fuente',0
|
||||
db ' Ajustes de acceso ',0, 'Altavoz',0
|
||||
db 'No',0, 'Sí',0
|
||||
|
||||
text dd ?
|
||||
textrus db 'Язык системы',0, 'Сглаживание шрифтов',0, 'Высота шрифтов',0
|
||||
db ' Настройки доступа ',0, 'Динамик',0
|
||||
db 'Нет',0, 'Да',0
|
||||
|
||||
syslang dd ?
|
||||
lba_read dd ?
|
||||
pci_acc dd ?
|
||||
speaker_mute dd ?
|
||||
fontSmoothing dd ?
|
||||
fontSize dd ?
|
||||
;---------------------------------------------------------------
|
||||
include 'settings.inc'
|
||||
|
||||
param:
|
||||
rb 1024
|
||||
I_END:
|
||||
|
||||
text dd ? ; texts of the window language
|
||||
checkboxImage dd ?
|
||||
checkStep dd ? ; x distance of two checkboxes
|
||||
sc system_colors
|
||||
valueText rd ROWS ; the strings shown in the value boxes
|
||||
heightText rb 4
|
||||
@@ -55,17 +55,18 @@ int program_console(int pid) {
|
||||
break;
|
||||
|
||||
case SHELL_PUTS:
|
||||
printf("%s", &buffer->data );
|
||||
buffer->return_value.written_bytes = printf("%s", &buffer->data );
|
||||
buffer->cmd = SHELL_OK;
|
||||
break;
|
||||
|
||||
case SHELL_GETC:
|
||||
buffer->data[0] = (char) getch() ;
|
||||
*((int *)buffer->data) = getch();
|
||||
buffer->cmd = SHELL_OK;
|
||||
break;
|
||||
|
||||
case SHELL_GETS:
|
||||
gets(buffer->data, size - 2);
|
||||
buffer->return_value.str = gets(buffer->data, size - 2);
|
||||
buffer->return_value.written_bytes = strlen(buffer->data);
|
||||
buffer->cmd = SHELL_OK;
|
||||
break;
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ aButtonStyle db 'buttons_gradient',0
|
||||
l_libs_start:
|
||||
|
||||
library01 l_libs system_dir_Boxlib+9, library_path, system_dir_Boxlib, \
|
||||
Box_lib_import
|
||||
import_box_lib
|
||||
|
||||
library02 l_libs system_dir_ProcLib+9, library_path, system_dir_ProcLib, \
|
||||
ProcLib_import
|
||||
@@ -150,96 +150,7 @@ aColorDialog_Init db 'ColorDialog_init',0
|
||||
aColorDialog_Start db 'ColorDialog_start',0
|
||||
;aOpenDialog_Version db 'Version_OpenDialog',0
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
Box_lib_import:
|
||||
;init_lib dd a_init
|
||||
;version_lib dd a_version
|
||||
|
||||
|
||||
;edit_box_draw dd aEdit_box_draw
|
||||
;edit_box_key dd aEdit_box_key
|
||||
;edit_box_mouse dd aEdit_box_mouse
|
||||
;version_ed dd aVersion_ed
|
||||
|
||||
;check_box_draw dd aCheck_box_draw
|
||||
;check_box_mouse dd aCheck_box_mouse
|
||||
;version_ch dd aVersion_ch
|
||||
|
||||
;option_box_draw dd aOption_box_draw
|
||||
;option_box_mouse dd aOption_box_mouse
|
||||
;version_op dd aVersion_op
|
||||
|
||||
;scrollbar_ver_draw dd aScrollbar_ver_draw
|
||||
;scrollbar_ver_mouse dd aScrollbar_ver_mouse
|
||||
;scrollbar_hor_draw dd aScrollbar_hor_draw
|
||||
;scrollbar_hor_mouse dd aScrollbar_hor_mouse
|
||||
;version_scrollbar dd aVersion_scrollbar
|
||||
|
||||
;dinamic_button_draw dd aDbutton_draw
|
||||
;dinamic_button_mouse dd aDbutton_mouse
|
||||
;version_dbutton dd aVersion_dbutton
|
||||
|
||||
;menu_bar_draw dd aMenu_bar_draw
|
||||
;menu_bar_mouse dd aMenu_bar_mouse
|
||||
;menu_bar_activate dd aMenu_bar_activate
|
||||
;version_menu_bar dd aVersion_menu_bar
|
||||
|
||||
;FileBrowser_draw dd aFileBrowser_draw
|
||||
;FileBrowser_mouse dd aFileBrowser_mouse
|
||||
;FileBrowser_key dd aFileBrowser_key
|
||||
;Version_FileBrowser dd aVersion_FileBrowser
|
||||
|
||||
PathShow_prepare dd sz_PathShow_prepare
|
||||
PathShow_draw dd sz_PathShow_draw
|
||||
;Version_path_show dd szVersion_path_show
|
||||
|
||||
Frame_draw dd sz_Frame_draw
|
||||
;Version_frame dd szVersion_frame
|
||||
|
||||
dd 0,0
|
||||
|
||||
;a_init db 'lib_init',0
|
||||
;a_version db 'version',0
|
||||
|
||||
;aEdit_box_draw db 'edit_box_draw',0
|
||||
;aEdit_box_key db 'edit_box_key',0
|
||||
;aEdit_box_mouse db 'edit_box_mouse',0
|
||||
;aVersion_ed db 'version_ed',0
|
||||
|
||||
;aCheck_box_draw db 'check_box_draw',0
|
||||
;aCheck_box_mouse db 'check_box_mouse',0
|
||||
;aVersion_ch db 'version_ch',0
|
||||
|
||||
;aOption_box_draw db 'option_box_draw',0
|
||||
;aOption_box_mouse db 'option_box_mouse',0
|
||||
;aVersion_op db 'version_op',0
|
||||
|
||||
;aScrollbar_ver_draw db 'scrollbar_v_draw',0
|
||||
;aScrollbar_ver_mouse db 'scrollbar_v_mouse',0
|
||||
;aScrollbar_hor_draw db 'scrollbar_h_draw',0
|
||||
;aScrollbar_hor_mouse db 'scrollbar_h_mouse',0
|
||||
;aVersion_scrollbar db 'version_scrollbar',0
|
||||
|
||||
;aDbutton_draw db 'dbutton_draw',0
|
||||
;aDbutton_mouse db 'dbutton_mouse',0
|
||||
;aVersion_dbutton db 'version_dbutton',0
|
||||
|
||||
;aMenu_bar_draw db 'menu_bar_draw',0
|
||||
;aMenu_bar_mouse db 'menu_bar_mouse',0
|
||||
;aMenu_bar_activate db 'menu_bar_activate',0
|
||||
;aVersion_menu_bar db 'version_menu_bar',0
|
||||
|
||||
;aFileBrowser_draw db 'FileBrowser_draw',0
|
||||
;aFileBrowser_mouse db 'FileBrowser_mouse',0
|
||||
;aFileBrowser_key db 'FileBrowser_key',0
|
||||
;aVersion_FileBrowser db 'version_FileBrowser',0
|
||||
|
||||
sz_PathShow_prepare db 'PathShow_prepare',0
|
||||
sz_PathShow_draw db 'PathShow_draw',0
|
||||
;szVersion_path_show db 'version_PathShow',0
|
||||
|
||||
sz_Frame_draw db 'frame_draw',0
|
||||
;szVersion_frame db 'version_frame',0
|
||||
include '../../develop/libraries/box_lib/import.inc'
|
||||
;---------------------------------------------------------------------
|
||||
PathShow_data_1:
|
||||
.type dd 0 ;+0
|
||||
|
||||
@@ -456,8 +456,7 @@ newcol:
|
||||
mov [frame_data.x],ebx
|
||||
mov [frame_data.y],ecx
|
||||
|
||||
push dword frame_data
|
||||
call [Frame_draw]
|
||||
stdcall [frame_draw], frame_data
|
||||
|
||||
pop ecx ebx
|
||||
|
||||
@@ -560,15 +559,13 @@ draw_window:
|
||||
mov [frame_data.font_color],eax
|
||||
mov [frame_data.draw_text_flag],dword 1
|
||||
|
||||
push dword frame_data
|
||||
call [Frame_draw]
|
||||
stdcall [frame_draw], frame_data
|
||||
;-----------------------------------
|
||||
mov [frame_data.x],dword frame_2.x shl 16+frame_2.w
|
||||
mov [frame_data.y],dword frame_2.y shl 16+frame_2.height
|
||||
mov [frame_data.text_pointer],dword select_skin_text
|
||||
|
||||
push dword frame_data
|
||||
call [Frame_draw]
|
||||
stdcall [frame_draw], frame_data
|
||||
;-----------------------------------
|
||||
call draw_PathShow
|
||||
;-----------------------------------
|
||||
|
||||
@@ -104,10 +104,26 @@ applyKeymap:
|
||||
cmp al, 9
|
||||
jnc @f
|
||||
push eax
|
||||
push esi edi
|
||||
shl eax,7
|
||||
lea eax,[eax*2+eax]
|
||||
mov [point],eax
|
||||
mcall 70,get_key
|
||||
lea edi,[eax*2+eax] ; offset of the layout = index*384
|
||||
cmp [keymap_file],0
|
||||
jnz .loaded
|
||||
mcall 68,27,keymap_path
|
||||
test eax,eax
|
||||
jz .fail
|
||||
mov [keymap_file],eax
|
||||
mov [keymap_size],edx
|
||||
.loaded:
|
||||
lea eax,[edi+384]
|
||||
cmp eax,[keymap_size]
|
||||
ja .fail
|
||||
mov esi,[keymap_file]
|
||||
add esi,edi
|
||||
mov edi,current_keymap
|
||||
mov ecx,384/4
|
||||
rep movsd
|
||||
pop edi esi
|
||||
mcall 21,2,1,current_keymap
|
||||
inc ecx
|
||||
mcall 21,,,current_keymap_shift
|
||||
@@ -118,6 +134,9 @@ applyKeymap:
|
||||
mcall 21,,9
|
||||
@@:
|
||||
ret
|
||||
.fail:
|
||||
pop edi esi eax
|
||||
ret
|
||||
;---------------------------------------------------------------
|
||||
align 4
|
||||
current_keymap rb 128
|
||||
@@ -132,13 +151,9 @@ point2 dd 0
|
||||
dd inicont
|
||||
db '/sys/settings/lang.ini',0
|
||||
|
||||
get_key:
|
||||
dd 0
|
||||
point dd 0
|
||||
dd 0
|
||||
dd 384
|
||||
dd current_keymap
|
||||
db '/sys/settings/keymap.key',0
|
||||
keymap_path db '/sys/settings/keymap.key',0
|
||||
keymap_file dd 0
|
||||
keymap_size dd 0
|
||||
|
||||
key_r db 0
|
||||
key_r2 db 0
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
-- @taskbar loads keymap.key with f68.27, which unpacks kpack'ed files.
|
||||
tup.rule("KEYMAP.KEY", "cp %f %o" .. tup.getconfig("KPACK_CMD"), "keymap.key.kpack")
|
||||
|
||||
if tup.getconfig("NO_FASM") ~= "" then return end
|
||||
HELPERDIR = (tup.getconfig("HELPERDIR") == "") and "../.." or tup.getconfig("HELPERDIR")
|
||||
tup.include(HELPERDIR .. "/use_fasm.lua")
|
||||
|
||||
@@ -28,7 +28,7 @@ include_debug_strings
|
||||
;-----------------------------------------------------------------------------
|
||||
l_libs_start:
|
||||
|
||||
library01 l_libs system_dir_Boxlib+9, library_path, system_dir_Boxlib, Box_lib_import
|
||||
library01 l_libs system_dir_Boxlib+9, library_path, system_dir_Boxlib, import_box_lib
|
||||
|
||||
library02 l_libs system_dir_ProcLib+9, library_path, system_dir_ProcLib, ProcLib_import
|
||||
|
||||
@@ -59,98 +59,7 @@ aOpenDialog_Start db 'OpenDialog_start',0
|
||||
;aColorDialog_Start db 'ColorDialog_start',0
|
||||
;aColorDialog_Version db 'Version_ColorDialog',0
|
||||
;-----------------------------------------------------------------------------
|
||||
align 4
|
||||
Box_lib_import:
|
||||
;init_lib dd a_init
|
||||
;version_lib dd a_version
|
||||
|
||||
|
||||
;edit_box_draw dd aEdit_box_draw
|
||||
;edit_box_key dd aEdit_box_key
|
||||
;edit_box_mouse dd aEdit_box_mouse
|
||||
;version_ed dd aVersion_ed
|
||||
|
||||
init_checkbox dd aInit_checkbox
|
||||
check_box_draw dd aCheck_box_draw
|
||||
check_box_mouse dd aCheck_box_mouse
|
||||
;version_ch dd aVersion_ch
|
||||
|
||||
;option_box_draw dd aOption_box_draw
|
||||
;option_box_mouse dd aOption_box_mouse
|
||||
;version_op dd aVersion_op
|
||||
|
||||
;scrollbar_ver_draw dd aScrollbar_ver_draw
|
||||
;scrollbar_ver_mouse dd aScrollbar_ver_mouse
|
||||
;scrollbar_hor_draw dd aScrollbar_hor_draw
|
||||
;scrollbar_hor_mouse dd aScrollbar_hor_mouse
|
||||
;version_scrollbar dd aVersion_scrollbar
|
||||
|
||||
;dinamic_button_draw dd aDbutton_draw
|
||||
;dinamic_button_mouse dd aDbutton_mouse
|
||||
;version_dbutton dd aVersion_dbutton
|
||||
|
||||
;menu_bar_draw dd aMenu_bar_draw
|
||||
;menu_bar_mouse dd aMenu_bar_mouse
|
||||
;menu_bar_activate dd aMenu_bar_activate
|
||||
;version_menu_bar dd aVersion_menu_bar
|
||||
|
||||
;FileBrowser_draw dd aFileBrowser_draw
|
||||
;FileBrowser_mouse dd aFileBrowser_mouse
|
||||
;FileBrowser_key dd aFileBrowser_key
|
||||
;Version_FileBrowser dd aVersion_FileBrowser
|
||||
|
||||
PathShow_prepare dd sz_PathShow_prepare
|
||||
PathShow_draw dd sz_PathShow_draw
|
||||
;Version_path_show dd szVersion_path_show
|
||||
|
||||
;Frame_draw dd sz_Frame_draw
|
||||
;Version_frame dd szVersion_frame
|
||||
|
||||
dd 0,0
|
||||
|
||||
;a_init db 'lib_init',0
|
||||
;a_version db 'version',0
|
||||
|
||||
;aEdit_box_draw db 'edit_box_draw',0
|
||||
;aEdit_box_key db 'edit_box_key',0
|
||||
;aEdit_box_mouse db 'edit_box_mouse',0
|
||||
;aVersion_ed db 'version_ed',0
|
||||
|
||||
aInit_checkbox db 'init_checkbox2',0
|
||||
aCheck_box_draw db 'check_box_draw2',0
|
||||
aCheck_box_mouse db 'check_box_mouse2',0
|
||||
;aVersion_ch db 'version_ch2',0
|
||||
|
||||
;aOption_box_draw db 'option_box_draw',0
|
||||
;aOption_box_mouse db 'option_box_mouse',0
|
||||
;aVersion_op db 'version_op',0
|
||||
|
||||
;aScrollbar_ver_draw db 'scrollbar_v_draw',0
|
||||
;aScrollbar_ver_mouse db 'scrollbar_v_mouse',0
|
||||
;aScrollbar_hor_draw db 'scrollbar_h_draw',0
|
||||
;aScrollbar_hor_mouse db 'scrollbar_h_mouse',0
|
||||
;aVersion_scrollbar db 'version_scrollbar',0
|
||||
|
||||
;aDbutton_draw db 'dbutton_draw',0
|
||||
;aDbutton_mouse db 'dbutton_mouse',0
|
||||
;aVersion_dbutton db 'version_dbutton',0
|
||||
|
||||
;aMenu_bar_draw db 'menu_bar_draw',0
|
||||
;aMenu_bar_mouse db 'menu_bar_mouse',0
|
||||
;aMenu_bar_activate db 'menu_bar_activate',0
|
||||
;aVersion_menu_bar db 'version_menu_bar',0
|
||||
|
||||
;aFileBrowser_draw db 'FileBrowser_draw',0
|
||||
;aFileBrowser_mouse db 'FileBrowser_mouse',0
|
||||
;aFileBrowser_key db 'FileBrowser_key',0
|
||||
;aVersion_FileBrowser db 'version_FileBrowser',0
|
||||
|
||||
sz_PathShow_prepare db 'PathShow_prepare',0
|
||||
sz_PathShow_draw db 'PathShow_draw',0
|
||||
;szVersion_path_show db 'version_PathShow',0
|
||||
|
||||
;sz_Frame_draw db 'frame_draw',0
|
||||
;szVersion_frame db 'version_frame',0
|
||||
include '../../develop/libraries/box_lib/import.inc'
|
||||
;-----------------------------------------------------------------------------
|
||||
PathShow_data:
|
||||
.type dd 0 ;+0
|
||||
|
||||
@@ -91,7 +91,8 @@ include '../../macros.inc'
|
||||
include '../../proc32.inc'
|
||||
;include '../../debug.inc'
|
||||
include '../../develop/libraries/box_lib/box_lib.mac'
|
||||
include '../../develop/libraries/box_lib/load_lib.mac'
|
||||
include '../../KOSfuncs.inc'
|
||||
include '../../load_lib.mac'
|
||||
include 'lang.inc' ; Language support for locales: it_IT, ru_RU (CP866), en_US
|
||||
@use_library
|
||||
;---------------------------------------------------------------------
|
||||
@@ -964,27 +965,12 @@ end if
|
||||
system_dir_Boxlib db '/sys/lib/box_lib.obj',0
|
||||
system_dir_ProcLib db '/sys/lib/proc_lib.obj',0
|
||||
;---------------------------------------------------------------------
|
||||
head_f_i:
|
||||
if lang eq it_IT
|
||||
head_f_l db 'Errore Sistema',0
|
||||
else
|
||||
head_f_l db 'System error',0
|
||||
end if
|
||||
|
||||
err_message_found_lib1 db 'box_lib.obj - Not found!',0
|
||||
err_message_found_lib2 db 'proc_lib.obj - Not found!',0
|
||||
|
||||
err_message_import1 db 'box_lib.obj - Wrong import!',0
|
||||
err_message_import2 db 'proc_lib.obj - Wrong import!',0
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
l_libs_start:
|
||||
|
||||
library01 l_libs system_dir_Boxlib+9, cur_dir_path, library_path, system_dir_Boxlib, \
|
||||
err_message_found_lib1, head_f_l, Box_lib_import, err_message_import1, head_f_i
|
||||
library01 l_libs system_dir_Boxlib+9, library_path, system_dir_Boxlib, import_box_lib
|
||||
|
||||
library02 l_libs system_dir_ProcLib+9, cur_dir_path, library_path, system_dir_ProcLib, \
|
||||
err_message_found_lib2, head_f_l, ProcLib_import, err_message_import2, head_f_i
|
||||
library02 l_libs system_dir_ProcLib+9, library_path, system_dir_ProcLib, ProcLib_import
|
||||
|
||||
end_l_libs:
|
||||
;---------------------------------------------------------------------
|
||||
@@ -1059,89 +1045,7 @@ aOpenDialog_Init db 'OpenDialog_init',0
|
||||
aOpenDialog_Start db 'OpenDialog_start',0
|
||||
;aOpenDialog_Version db 'Version_OpenDialog',0
|
||||
;---------------------------------------------------------------------
|
||||
align 4
|
||||
Box_lib_import:
|
||||
;init_lib dd a_init
|
||||
;version_lib dd a_version
|
||||
|
||||
|
||||
edit_box_draw dd aEdit_box_draw
|
||||
edit_box_key dd aEdit_box_key
|
||||
edit_box_mouse dd aEdit_box_mouse
|
||||
;version_ed dd aVersion_ed
|
||||
|
||||
;check_box_draw dd aCheck_box_draw
|
||||
;check_box_mouse dd aCheck_box_mouse
|
||||
;version_ch dd aVersion_ch
|
||||
|
||||
;option_box_draw dd aOption_box_draw
|
||||
;option_box_mouse dd aOption_box_mouse
|
||||
;version_op dd aVersion_op
|
||||
|
||||
;scrollbar_ver_draw dd aScrollbar_ver_draw
|
||||
;scrollbar_ver_mouse dd aScrollbar_ver_mouse
|
||||
;scrollbar_hor_draw dd aScrollbar_hor_draw
|
||||
;scrollbar_hor_mouse dd aScrollbar_hor_mouse
|
||||
;version_scrollbar dd aVersion_scrollbar
|
||||
|
||||
;dinamic_button_draw dd aDbutton_draw
|
||||
;dinamic_button_mouse dd aDbutton_mouse
|
||||
;version_dbutton dd aVersion_dbutton
|
||||
|
||||
;menu_bar_draw dd aMenu_bar_draw
|
||||
;menu_bar_mouse dd aMenu_bar_mouse
|
||||
;menu_bar_activate dd aMenu_bar_activate
|
||||
;version_menu_bar dd aVersion_menu_bar
|
||||
|
||||
;FileBrowser_draw dd aFileBrowser_draw
|
||||
;FileBrowser_mouse dd aFileBrowser_mouse
|
||||
;FileBrowser_key dd aFileBrowser_key
|
||||
;Version_FileBrowser dd aVersion_FileBrowser
|
||||
|
||||
;PathShow_prepare dd sz_PathShow_prepare
|
||||
;PathShow_draw dd sz_PathShow_draw
|
||||
;Version_path_show dd szVersion_path_show
|
||||
dd 0,0
|
||||
|
||||
;a_init db 'lib_init',0
|
||||
;a_version db 'version',0
|
||||
|
||||
aEdit_box_draw db 'edit_box_draw',0
|
||||
aEdit_box_key db 'edit_box_key',0
|
||||
aEdit_box_mouse db 'edit_box_mouse',0
|
||||
;aVersion_ed db 'version_ed',0
|
||||
|
||||
;aCheck_box_draw db 'check_box_draw',0
|
||||
;aCheck_box_mouse db 'check_box_mouse',0
|
||||
;aVersion_ch db 'version_ch',0
|
||||
|
||||
;aOption_box_draw db 'option_box_draw',0
|
||||
;aOption_box_mouse db 'option_box_mouse',0
|
||||
;aVersion_op db 'version_op',0
|
||||
|
||||
;aScrollbar_ver_draw db 'scrollbar_v_draw',0
|
||||
;aScrollbar_ver_mouse db 'scrollbar_v_mouse',0
|
||||
;aScrollbar_hor_draw db 'scrollbar_h_draw',0
|
||||
;aScrollbar_hor_mouse db 'scrollbar_h_mouse',0
|
||||
;aVersion_scrollbar db 'version_scrollbar',0
|
||||
|
||||
;aDbutton_draw db 'dbutton_draw',0
|
||||
;aDbutton_mouse db 'dbutton_mouse',0
|
||||
;aVersion_dbutton db 'version_dbutton',0
|
||||
|
||||
;aMenu_bar_draw db 'menu_bar_draw',0
|
||||
;aMenu_bar_mouse db 'menu_bar_mouse',0
|
||||
;aMenu_bar_activate db 'menu_bar_activate',0
|
||||
;aVersion_menu_bar db 'version_menu_bar',0
|
||||
|
||||
;aFileBrowser_draw db 'FileBrowser_draw',0
|
||||
;aFileBrowser_mouse db 'FileBrowser_mouse',0
|
||||
;aFileBrowser_key db 'FileBrowser_key',0
|
||||
;aVersion_FileBrowser db 'version_FileBrowser',0
|
||||
|
||||
;sz_PathShow_prepare db 'PathShow_prepare',0
|
||||
;sz_PathShow_draw db 'PathShow_draw',0
|
||||
;szVersion_path_show db 'version_PathShow',0
|
||||
include '../../develop/libraries/box_lib/import.inc'
|
||||
;---------------------------------------------------------------------
|
||||
; for EDITBOX
|
||||
align 4
|
||||
|
||||
Reference in new issue
Block a user