87c3f4bc8d
git-svn-id: svn://kolibrios.org@7461 a494cfbc-eb01-0410-851d-a64ba20cac60
883 lines
21 KiB
NASM
883 lines
21 KiB
NASM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
; Hot Angles ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
; Compile with FASM
|
|
; Version 0.3.7: Oct 14, 2018
|
|
|
|
; Copyright (c) 2018, Efremenkov Sergey aka TheOnlyMirage
|
|
; All rights reserved.
|
|
; Redistribution and use in source and binary forms, with or without modification,
|
|
; are permitted provided that the following conditions are met:
|
|
; * Redistributions of source code must retain the above copyright notice, this
|
|
; list of conditions and the following disclaimer.
|
|
; * Redistributions in binary form must reproduce the above copyright notice,
|
|
; this list of conditions and the following disclaimer in the documentation and/or
|
|
; other materials provided with the distribution.
|
|
; * Neither the name of the <organization> nor the names of its contributors may
|
|
; be used to endorse or promote products derived from this software without
|
|
; specific prior written permission.
|
|
|
|
; THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
; INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
; PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
; --------------------------------------------------------------------------------------
|
|
|
|
format binary as "" ;"kex"
|
|
use32
|
|
org 0x0 ; áàçîâûé àäðåñ ðàçìåùåíèÿ êîäà, âñåãäà 0x0
|
|
|
|
UNLOCKd = 0
|
|
LOCKd = 1
|
|
SUPERLOCKd = 2
|
|
|
|
; çàãîëîâîê
|
|
db 'MENUET01' ;ìàãè÷åñêèé èäåíòèôèêàòîð
|
|
dd 0x01 ;âåðñèÿ
|
|
dd START_DEBUG ;àäðåñ òî÷êè ñòàðòà ïðîãðàììû
|
|
dd I_END ;àäðåñ êîíöà, ïî ôàêòó ðàçìåð ôàéëà ïðîãðàììû
|
|
dd 0x100000 ;òðåáóåìîå êîë-âî ïàìÿòè äëÿ çàãðóçêè ïðîãðàììû
|
|
dd 0x7fff0 ;íà÷àëüíîå çíà÷åíèå ðåãèñòðà esp - àäðåñ êîíöà îáëàñòè ñòýêà òàê êàê ñòýê ðàñòåò â ñòîðîíó ìåíüøèõ àäðåñîâ
|
|
dd 0, 0 ;àäðåñ ñòðîêè ïàðàìåòðîâ è àäðåñ ñòðîêè ïóòè èñïîëíÿåìîãî ôàéëà
|
|
|
|
|
|
include '../../macros.inc'
|
|
|
|
START_DEBUG:
|
|
call copyKill ;ïðîñòåéøàÿ çàùèòà îò ïîâòîðíîãî çàïóñêà
|
|
mcall 68, 11 ;èíèöèàëèçàöèÿ êó÷è
|
|
call loadConfig ;çàãðóæàåì êîíôèãóðàöèþ ïðèëîæåíèÿ
|
|
|
|
cmp byte[mode], 0 ;ôóíêöèÿ îòêëþ÷åíà - âûõîä
|
|
jne @f
|
|
mcall -1
|
|
@@:
|
|
;ðåæèì æåñòà ïî ãîðÿ÷åé êëàâèøå?
|
|
cmp byte[mode], 3 ;ïîäïèñûâàåìñÿ íà èíòåðåñíûå íàì ñîáûòèÿ â çàâèñèìîñòè îò ðåæèìà ðàáîòû
|
|
jne @f
|
|
mov ebx, 00000100000000000000000000100010b ;åñëè äà, òî ïîäïèñûâàåìñÿ íà êëàâèøè
|
|
mcall 40
|
|
jmp init03
|
|
@@:
|
|
;ðåæèì àêòèâàöèè ãîðÿ÷åé êëàâèøåé?
|
|
cmp byte[mode], 2 ;ïîäïèñûâàåìñÿ íà èíòåðåñíûå íàì ñîáûòèÿ â çàâèñèìîñòè îò ðåæèìà ðàáîòû
|
|
jne @f
|
|
mov ebx, 00000100000000000000000000100010b ;åñëè äà, òî ïîäïèñûâàåìñÿ íà êëàâèøè
|
|
mcall 40
|
|
jmp init02
|
|
@@:
|
|
; âî âñåõ îñòàëüíûõ ñëó÷àÿõ - êëàññè÷åñêèé ðåæèì ðàáîòû
|
|
;mode=1 êëàññè÷åñêèé ðåæèì ðàáîòû - ðåàêöèÿ ïðè íàâåäåíèè â óãîë
|
|
mov byte[mode], 1
|
|
mov ebx, 00000100000000000000000000100000b
|
|
mcall 40
|
|
jmp init01
|
|
|
|
|
|
|
|
init02:
|
|
mov dword[backAdr], mode02
|
|
call setHotKey
|
|
mode02:
|
|
mcall 10
|
|
cmp eax, 2 ;îáðàáîòêà íàæàòèÿ êëàâèøè
|
|
je hotkey
|
|
|
|
cmp byte[keyState], 0
|
|
je mode02
|
|
cmp eax, 6 ;îáðàáîòêà ïåðåìåùåíèé è íàæàòèÿ ìûøè
|
|
je mouse
|
|
|
|
jmp mode02
|
|
|
|
|
|
setHotKey: ;óñòàíîâèòü ãîðÿ÷óþ êëàâèøó
|
|
push eax ebx ecx edx
|
|
xor ecx, ecx
|
|
mov cl, byte[keyActivate] ;íàæàòèå ãîðÿ÷åé êëàâèøè
|
|
mov edx, 0x000
|
|
mcall 66, 4, ecx, edx
|
|
|
|
;mov cl, byte[keyActivate]
|
|
add cl, 128 ;îòïóñêàíèå ãîðÿ÷åé êëàâèøè
|
|
;mov edx, 0x000
|
|
mcall 66, 4, ecx, edx
|
|
pop edx ecx ebx eax
|
|
ret
|
|
|
|
|
|
hotkey:
|
|
mcall 2
|
|
cmp eax, 1 ;áóôåð êëàâèø ïóñò?
|
|
je hotkey.end
|
|
|
|
cmp al, 2 ;íàñ èíòåðåñóåò òîëüêî ñêàí êîä ãîðÿ÷åé êëàâèøè, èíà÷å âûõîäèì
|
|
jne hotkey.end
|
|
|
|
cmp ah, byte[keyActivate] ;åñëè íàæàòà íàøà ãîðÿ÷àÿ êëàâèøà
|
|
jne @f
|
|
|
|
;ïðîâåðêè äëÿ mode 3
|
|
cmp byte[state], SUPERLOCKd
|
|
je hotkey.end
|
|
cmp byte[keyState], 1
|
|
je hotkey.end
|
|
|
|
push eax ebx
|
|
mcall 37, 0 ;çàïîìèíàåì òåêóùèå(íà÷àëüíûå) êîîðäèíàòû ìûøè
|
|
;mov dword[o.x], eax
|
|
mov word[o.y], ax
|
|
shr eax, 16
|
|
mov word[o.x], ax
|
|
pop ebx eax
|
|
|
|
mov byte[keyState], 1
|
|
mov byte[state], UNLOCKd
|
|
jmp hotkey.end
|
|
@@:
|
|
push edx
|
|
xor edx, edx
|
|
mov dl, byte[keyActivate]
|
|
add dl, 128
|
|
cmp ah, dl ;åñëè îòïóùåíà íàøà ãîðÿ÷àÿ êëàâèøà
|
|
jne @f ;hotkey.end
|
|
|
|
mov byte[keyState], 0
|
|
mov byte[state], LOCKd
|
|
@@:
|
|
pop edx
|
|
.end:
|
|
jmp dword[backAdr]
|
|
|
|
|
|
init01:
|
|
mov dword[backAdr], mode01
|
|
mode01:
|
|
mov eax, 10 ; function 10 : wait until event
|
|
mcall ; event type is returned in eax
|
|
|
|
cmp eax, 6 ;îáðàáîòêà ïåðåìåùåíèé è íàæàòèÿ ìûøè
|
|
je mouse
|
|
|
|
jmp mode01
|
|
|
|
|
|
mouse:
|
|
push ebx
|
|
mcall 37, 0 ;ïîëó÷àåì òåêóùèå êîîðäèíàòû ìûøè
|
|
pop ebx
|
|
|
|
cmp eax, 0 ;ëåâûé âåðõíèé óãîë
|
|
jne @f
|
|
; -- çäåñü âûçûâàåì ñîîòâ. âûçîâ äëÿ ëåâîãî âåðõíåãî óãëà (X=0, Y=0)
|
|
push ecx
|
|
mov ecx, 0
|
|
call run_command
|
|
pop ecx
|
|
|
|
jmp dword[backAdr] ;finish
|
|
@@:
|
|
call get_screen_size ;èíà÷å îáíîâëÿåì ðàçìåðû ýêðàíà
|
|
|
|
cmp ax, word[screen.height] ;Ymouse = Yscreen ?
|
|
je Ytrue
|
|
;åñëè Y íå ðàâíû, òî íàñ èíòåðåñóåò Y=0 è X=ScreenWidth (ïðàâûé âåðõíèé óãîë)
|
|
|
|
cmp ax, 0
|
|
jne unlockend
|
|
shr eax, 16
|
|
cmp ax, word[screen.width]
|
|
jne unlockend
|
|
; -- çäåñü âûçûâàåì äëÿ ïðàâîãî âåðõåíåãî óãëà
|
|
push ecx
|
|
mov ecx, 2
|
|
call run_command
|
|
pop ecx
|
|
|
|
jmp dword[backAdr]
|
|
Ytrue:
|
|
;åñëè Y ðàâíû, òî íàñ èíòåðåñóåò X=0 (ëåâûé íèæíèé óãîë) èëè X=ScreenWidth (ïðàâûé íèæíèé)
|
|
shr eax, 16
|
|
cmp ax, 0
|
|
jne @f
|
|
; -- X=0, Y = Height (ëåâûé íèæíèé óãîë)
|
|
push ecx
|
|
mov ecx, 1
|
|
call run_command
|
|
pop ecx
|
|
jmp dword[backAdr]
|
|
@@:
|
|
cmp ax, word[screen.width]
|
|
jne unlockend
|
|
; -- (ïðàâûé íèæíèé óãîë)
|
|
push ecx
|
|
mov ecx, 3
|
|
call run_command
|
|
pop ecx
|
|
|
|
jmp dword[backAdr]
|
|
|
|
unlockend:
|
|
mov byte[state], UNLOCKd
|
|
jmp dword[backAdr]
|
|
|
|
|
|
|
|
;ïîëó÷èòü ðàçìåð ýêðàíà
|
|
get_screen_size:
|
|
push eax
|
|
mcall 14
|
|
;òåïåðü â eax = [xsize]*65536 + [ysize]
|
|
;mov dword[screen], eax
|
|
mov word[screen.height], ax
|
|
shr eax, 16
|
|
mov word[screen.width], ax
|
|
pop eax
|
|
ret
|
|
|
|
|
|
|
|
|
|
|
|
;çàïóñê ïðèëîæåíèÿ: ecx - àêòèâíûé óãîë: lu=0, ld=1, ru=2, rd=3
|
|
run_command:
|
|
cmp byte[state], UNLOCKd
|
|
jne run_command.end
|
|
|
|
push eax ebx ecx
|
|
|
|
cmp ecx, 0
|
|
jne @f
|
|
mov eax, apps.path1
|
|
cmp byte[eax], 0 ;åñëè ïî àäðåñó ïóñòî (èëè ëåæàë ñèìâîë '-'), òî àäðåñ 0
|
|
je .set0
|
|
mov dword[struct70.path_adr], eax
|
|
mov eax, apps.param1
|
|
mov dword[struct70.param_adr], eax
|
|
jmp .end_set_path
|
|
@@:
|
|
cmp ecx, 1
|
|
jne @f
|
|
mov eax, apps.path2
|
|
cmp byte[eax], 0 ;åñëè ïî àäðåñó ïóñòî (èëè ëåæàë ñèìâîë '-'), òî àäðåñ 0
|
|
je .set0
|
|
mov dword[struct70.path_adr], eax
|
|
mov eax, apps.param2
|
|
mov dword[struct70.param_adr], eax
|
|
jmp .end_set_path
|
|
@@:
|
|
cmp ecx, 2
|
|
jne @f
|
|
mov eax, apps.path3
|
|
cmp byte[eax], 0 ;åñëè ïî àäðåñó ïóñòî (èëè ëåæàë ñèìâîë '-'), òî àäðåñ 0
|
|
je .set0
|
|
mov dword[struct70.path_adr], eax
|
|
mov eax, apps.param3
|
|
mov dword[struct70.param_adr], eax
|
|
jmp .end_set_path
|
|
@@:
|
|
cmp ecx, 3
|
|
jne .set0 ;.end_set_path
|
|
mov eax, apps.path4
|
|
cmp byte[eax], 0 ;åñëè ïî àäðåñó ïóñòî (èëè ëåæàë ñèìâîë '-'), òî àäðåñ 0
|
|
je .set0
|
|
mov dword[struct70.path_adr], eax
|
|
mov eax, apps.param4
|
|
mov dword[struct70.param_adr], eax
|
|
jmp .end_set_path
|
|
.set0:
|
|
;mov dword[struct70.path_adr], 0
|
|
;mov dword[struct70.param_adr], 0
|
|
jmp @f
|
|
.end_set_path:
|
|
mcall 70, struct70
|
|
@@:
|
|
mov byte[state], LOCKd
|
|
;mov byte[keyState], 0
|
|
pop ecx ebx eax
|
|
.end:
|
|
ret
|
|
|
|
struct70: ;Ôîðìàò èíôîðìàöèîííîé ñòðóêòóðû
|
|
.func dd 7 ; íîìåð ïîäôóíêöèè
|
|
.mask dd 0
|
|
.param_adr dd 0 ; óêàçàòåëü íà ASCIIZ-ñòðîêó ñ ïàðàìåòðàìè
|
|
.other dd 0, 0
|
|
.path db 0
|
|
.path_adr dd 0 ; óêàçàòåëü íà ñòðîêó ñ ïóò¸ì
|
|
|
|
;èìÿ êîíôèãóðàöèîííîãî ôàéëà
|
|
fileName: db 'SETTINGS/HOTANGLES.CFG', 0
|
|
|
|
|
|
;ïðîõîäèì äî êîíöà òåêóùåé ñòðîêè
|
|
gotoEndString:
|
|
cmp eax, edx ;åñëè ôàéë çàêîí÷èëñÿ, òî
|
|
ja @f ;âûõîäèì
|
|
cmp byte[eax], 10
|
|
je @f
|
|
cmp byte[eax], 0
|
|
je @f
|
|
cmp byte[eax], 13
|
|
je @f
|
|
;èíà÷å ïåðåõîäèì íà ñëåäóþùèé ñèìâîë
|
|
inc eax
|
|
jmp gotoEndString
|
|
@@:
|
|
ret
|
|
|
|
;ïðîïóñêàåì ïåðåíîñû â íà÷àëå ñòðîêè äî ïåðâîãî àäåêâàòíîãî ñèìâîëà
|
|
gotoStartString:
|
|
cmp eax, edx ;åñëè ôàéë çàêîí÷èëñÿ, òî
|
|
ja @f ;âûõîäèì
|
|
cmp byte[eax], 10
|
|
je .next
|
|
cmp byte[eax], 0
|
|
je .next
|
|
cmp byte[eax], 13
|
|
je .next
|
|
jmp @f ;åñëè ýòî äðóãîé ñèìâîë, òî âûõîäèì
|
|
.next: ;ïåðåõîäèì íà ñëåäóþùèé ñèìâîë
|
|
inc eax
|
|
jmp gotoStartString
|
|
@@:
|
|
ret
|
|
|
|
|
|
sep: db '|' ;ñèìâîë ðàçäåëèòåëü ñòðîêè ïóòè + ïàðàìåòðû çàïóñêà
|
|
readPath:
|
|
push ebx esi edi
|
|
mov bh, 0 ; 0 - çíàê òîãî, ÷òî ïàðàìåòðû åù¸ íå âñòðå÷àëèñü
|
|
mov byte[esi], 0 ;ïðîèíèöèàëèçèðóåì áóôåðû-ñòðîêè ïóñòîòîé (íà âñÿêèé ñëó÷àé)
|
|
mov byte[edi], 0
|
|
@@:
|
|
cmp eax, edx ;åñëè ôàéë çàêîí÷èëñÿ, òî
|
|
ja @f ;âûõîäèì
|
|
mov bl, byte[eax]
|
|
;åñëè î÷åðåäíîé ñèìâîë íå êîíåö ñòðîêè
|
|
cmp bl, 10
|
|
je @f ;èíà÷å âûõîä
|
|
cmp bl, 0
|
|
je @f
|
|
cmp bl, 13
|
|
je @f
|
|
;è íå íà÷àëî ïàðàìåòðîâ
|
|
cmp bl, byte[sep]
|
|
jne .read
|
|
;åñëè sep óæå âñòðå÷àëè ðàíåå, òî
|
|
cmp bh, 0
|
|
jne .read ;ïðîñòî ïðîäîëæàåì ñ÷èòûâàòü ïàðàìåòðû äàëüøå (â íèõ ìîæåò áûòü ÷òî óãîäíî)
|
|
;èíà÷å êëàä¸ì çàâåðøàþùèé 0 è ïåðåõîäèì ê áóôåðó ñ ïàðàìåòðàìè
|
|
mov byte[esi], 0
|
|
call trim ;åù¸ íå çàáóäåì óáðàòü ëèøíèå òàáóëÿöèè è ïðîáåëû íà êîíöå íàøåé ñòðîêè
|
|
mov esi, edi
|
|
mov bh, 1
|
|
inc eax
|
|
jmp @b
|
|
.read: ;òî çàïèñûâàåì ñèìâîë â íàø áóôåð è ïåðåõîäèì íà ñëåäóþùèé ñèìâîë
|
|
mov byte[esi], bl
|
|
inc esi
|
|
inc eax
|
|
jmp @b
|
|
@@:
|
|
mov byte[esi], 0 ;êëàä¸ì çàâåðøàþùèé íîëü
|
|
pop edi esi ebx
|
|
ret
|
|
|
|
trim: ;esi - ïîñëåäíèé íóëåâîé ñèìâîë ñòðîêè
|
|
;push esi
|
|
mov byte[esi], 0
|
|
dec esi
|
|
cmp byte[esi], 9 ;tab
|
|
je trim
|
|
cmp byte[esi], 32 ;space
|
|
je trim
|
|
inc esi
|
|
;pop esi
|
|
ret
|
|
|
|
|
|
cfgFileAdr: dd 0 ;àäðåñ êîíôèãóðàöèîííîãî ôàéëà â ïàìÿòè
|
|
|
|
loadConfig:
|
|
push eax ebx ecx edx
|
|
mcall 68, 27, fileName ;çàãðóæàåì êîíôèãóðàöèîííûé ôàéë â ÎÇÓ
|
|
mov dword[cfgFileAdr], eax
|
|
cmp eax, 0
|
|
je loadConfig.exit ;åñëè ôàéëà êîíôèãóðàöèè íåò, òî çàâåðøàåì ðàáîòó ïðèëîæåíèÿ
|
|
;èíà÷å äàííûå çàãðóæåíû â ÎÇÓ, ðàçìåð â edx
|
|
cmp edx, 0 ;åñëè ôàéë ïóñò, â í¸ì íåò äàííûõ, òî çàâåðøàåì ðàáîòó
|
|
je loadConfig.exit
|
|
|
|
add edx, eax ;èíà÷å êëàä¸ì â edx - àäðåñ êîíöà ôàéëà
|
|
|
|
mov byte[mode], 0
|
|
cmp byte[eax], '0' ;åñëè ïàðàìåòð àêòèâíîñòè ïðèëîæåíèÿ èìååò ñòàòóñ: íå àêòèâíî
|
|
je loadConfig.exit ;òî çàâåðøàåì ðàáîòó ïðèëîæåíèÿ
|
|
cmp byte[eax], 110 ;'n'
|
|
je loadConfig.exit
|
|
|
|
;èíà÷å âûñòàâëÿåì ðåæèì
|
|
cmp byte[eax], 121 ;'y' ;êëàññè÷åñêèé ðåæèì
|
|
jne @f
|
|
mov byte[mode], 1
|
|
jmp loadConfig.modeEnd
|
|
@@:
|
|
cmp byte[eax], '1' ;êëàññè÷åñêèé ðåæèì
|
|
jne @f
|
|
mov byte[mode], 1
|
|
jmp loadConfig.modeEnd
|
|
@@:
|
|
cmp byte[eax], '2' ;ðåæèì àêòèâàöèè ïî ãîðÿ÷åé êëàâèøå
|
|
jne @f
|
|
mov byte[mode], 2
|
|
jmp loadConfig.modeEnd
|
|
@@:
|
|
cmp byte[eax], '3' ;ðåæèì æåñòà ïðè çàæàòîé êëàâèøå
|
|
jne @f
|
|
mov byte[mode], 3
|
|
jmp loadConfig.modeEnd
|
|
@@:
|
|
mov byte[mode], 0 ;âî âñåõ îñòàëüíûõ ñëó÷àÿõ - îòêëþ÷åíî
|
|
jmp loadConfig.exit
|
|
.modeEnd:
|
|
|
|
;èä¸ì äî êîíöà ýòîé ñòðîêè
|
|
call gotoEndString
|
|
;íàõîäèì íà÷àëî ñëåäóþùåé ñòðîêè
|
|
call gotoStartString
|
|
|
|
push esi edi
|
|
|
|
;ñ÷èòûâàåì ïóòü äëÿ ëåâîãî âåðõíåãî óãëà
|
|
mov esi, apps.path1
|
|
mov edi, apps.param1
|
|
call readPath
|
|
call gotoStartString ;íàõîäèì íà÷àëî ñëåäóþùåé ñòðîêè
|
|
|
|
;ñ÷èòûâàåì ïóòü äëÿ ëåâîãî íèæíåãî óãëà
|
|
mov esi, apps.path2
|
|
mov edi, apps.param2
|
|
call readPath
|
|
call gotoStartString
|
|
|
|
;ñ÷èòûâàåì ïóòü äëÿ ïðàâîãî âåðõíåãî óãëà
|
|
mov esi, apps.path3
|
|
mov edi, apps.param3
|
|
call readPath
|
|
call gotoStartString
|
|
|
|
;ñ÷èòûâàåì ïóòü äëÿ ïðàâîãî íèæíåãî óãëà
|
|
mov esi, apps.path4
|
|
mov edi, apps.param4
|
|
call readPath
|
|
call gotoStartString
|
|
|
|
;ïðîâåðèì ñòðîêè íà '-'
|
|
call checkPathAdr
|
|
|
|
pop edi esi
|
|
|
|
;ïðîïóñêàåì ñòðîêó ñ èìåíåì êëàâèøè
|
|
call gotoEndString
|
|
call gotoStartString
|
|
|
|
;ñ÷èòûâàåì ñêàíêîä àêòèâàöèîííîé êëàâèøè
|
|
push esi edi ecx
|
|
mov esi, keystr
|
|
mov edi, keystr
|
|
call readPath
|
|
;ïðåîáðàçóåì ñòðîêó â ÷èñëî
|
|
mov esi, keystr
|
|
call strToInteger
|
|
mov byte[keyActivate], cl
|
|
pop ecx edi esi
|
|
call gotoStartString
|
|
|
|
;ñ÷èòûâàåì ðàäèóñ
|
|
push esi edi ecx
|
|
mov esi, radstr
|
|
mov edi, radstr
|
|
call readPath
|
|
;ïðåîáðàçóåì ñòðîêó â ÷èñëî
|
|
mov esi, radstr
|
|
call strToInteger
|
|
;òåïåðü ecx - çíà÷åíèå ðàäèóñà
|
|
;!!! äîáàâèòü ïðîâåðêó, ÷òîáû ÷èñëî íå áûëî áîëüøå îáëàñòè ýêðàíà
|
|
;íàñ èíòåðåñóåò êâàäðàò ÷èñëà
|
|
push eax edx
|
|
mov eax, ecx ;dword[radius2]
|
|
mul ecx
|
|
mov dword[radius2], eax
|
|
pop edx eax
|
|
|
|
pop ecx edi esi
|
|
|
|
;ñ÷èòûâàòü ðàçìåð ýëåìåíòîâ èíòåðôåéñà íàì íå íóæíî (ïîêà ÷òî ýòîò ïàðàìåòð òîëüêî äëÿ êîíôèãà)
|
|
jmp .end
|
|
.exit:
|
|
pop edx ecx ebx eax
|
|
mcall -1 ;çàêðûòü ýòó ïðîãðàììó
|
|
.end:
|
|
mov ecx, dword[cfgFileAdr] ;åñëè ôàéë áûë çàãðóæåí, òî
|
|
cmp ecx, 0
|
|
je @f
|
|
mcall 68, 13, ecx ;âûãðóæàåì ôàéë èç ïàìÿòè
|
|
@@:
|
|
pop edx ecx ebx eax
|
|
ret
|
|
|
|
|
|
checkPathAdr:
|
|
push eax ebx
|
|
xor eax, eax
|
|
|
|
mov ebx, apps.path1
|
|
cmp byte[ebx], '-'
|
|
jne @f
|
|
;cmp byte[ebx+1], 0
|
|
;jne @f
|
|
mov byte[ebx], 0
|
|
@@:
|
|
mov ebx, apps.path2
|
|
cmp byte[ebx], '-'
|
|
jne @f
|
|
;cmp byte[ebx+1], 0
|
|
;jne @f
|
|
mov byte[ebx], 0
|
|
@@:
|
|
mov ebx, apps.path3
|
|
cmp byte[ebx], '-'
|
|
jne @f
|
|
;cmp byte[ebx+1], 0
|
|
;jne @f
|
|
mov byte[ebx], 0
|
|
@@:
|
|
mov ebx, apps.path4
|
|
cmp byte[ebx], '-'
|
|
jne @f
|
|
;cmp byte[ebx+1], 0
|
|
;jne @f
|
|
mov byte[ebx], 0
|
|
@@:
|
|
pop ebx eax
|
|
ret
|
|
|
|
;ïðåîáðàçîâàíèå ñòðîêè â öåëîå ÷èñëî
|
|
strToInteger: ;âõîä: esi - óêàçàòåëü íà ñòðîêó ñ äåñÿòè÷íîé çàïèñüþ ÷èñëà, âûõîä: eñx - ÷èñëî
|
|
push eax ebx edx edi
|
|
xor eax, eax ;îáíóëÿåì eax
|
|
xor ecx, ecx
|
|
mov edi, esi
|
|
.get_last_symbol:
|
|
;÷èòàåì î÷åðåäíîé ñèìâîë
|
|
mov al, byte[edi]
|
|
|
|
;åñëè ýòî íîëü, òî ñòðîêà çàêîí÷èëàñü
|
|
cmp al, 0
|
|
je @f
|
|
|
|
;èíà÷å ïåðåõîäèì íà ñëåäóþùèé ñèìâîë
|
|
inc edi
|
|
jmp .get_last_symbol
|
|
@@: ;äîøëè äî ïîñëåäíåãî ñèìâîëà è êëàä¸ì àäðåñ íà íåãî â edi
|
|
dec edi
|
|
|
|
cmp edi, esi ;àäðåñ ïîñëåäíåãî ñèìâîëà äîëæåí áûòü äàëüøå àäðåñà ïåðâîãî ñèìâîëà
|
|
jae @f
|
|
jmp .error ;èíà÷å îøèáêà
|
|
@@:
|
|
;òåïåðü â edi ïîñëåäíèé ñèìâîë, à esi óêàçûâàåò íà íà÷àëî ñòðîêè (íà ïåðâé ñèìâîë ñòðîêè)
|
|
mov cl, byte[edi]
|
|
sub cl, 48 ;0x30 ;'0'
|
|
dec edi ;ïåðåõîäèì íà ñëåä ñèìâîë îò êîíöà
|
|
mov ebx, 10 ;ìíîæèòåëü ñòåïåíè
|
|
.tranform_cicle:
|
|
cmp edi, esi ;åñëè áîëüøå íåò ñèìâîëîâ ñòðîêå, òî ÷èñëî ïðåîáðàçîâàëè - âûõîäèì
|
|
jb .end
|
|
|
|
mov eax, 0
|
|
mov al, byte[edi]
|
|
sub al, 48 ;'0'
|
|
cmp al, 9 ;0x39 ;åñëè ÷èñëî áîëüøå 9, òî âèäèìî â ñòðîêå áûëî ÷òî-òî íå òàê
|
|
ja .error
|
|
cmp al, 0 ;0x30 ;åñëè ÷èñëî ìåíüøå 0, òî âèäèìî â ñòðîêå áûëî ÷òî-òî íå òàê
|
|
jb .error
|
|
mov edx, 0
|
|
mul ebx
|
|
|
|
add ecx, eax
|
|
|
|
dec edi
|
|
mov edx, 0
|
|
mov eax, 10
|
|
mul ebx
|
|
mov ebx, eax
|
|
jmp .tranform_cicle
|
|
.error:
|
|
mov ecx, 0
|
|
.end:
|
|
pop edi edx ebx eax
|
|
ret
|
|
|
|
|
|
;Âûíåñòè êîä íèæå â îòäåëüíûé îáùèé ìîäóëü
|
|
selfName db '@HOTANGLES',0
|
|
selfNameSize = 10 ;äî 11 byte
|
|
;
|
|
compareBytes:
|
|
push edi esi ecx ebx
|
|
xor eax, eax
|
|
mov ecx, selfNameSize ;max ðàçìåð ñòðîê 11
|
|
@@:
|
|
mov bl, byte[edi]
|
|
cmp bl, byte[esi]
|
|
jne compareBytes.no
|
|
inc edi
|
|
inc esi
|
|
cmp ecx, 0
|
|
je @f
|
|
dec ecx
|
|
jmp @b
|
|
.no:
|
|
mov eax, 1
|
|
@@:
|
|
pop ebx ecx esi edi
|
|
ret
|
|
;
|
|
copyKill:
|
|
push eax ebx ecx esi edi
|
|
|
|
;ñïåðâà ïðî÷ò¸ì ñâîþ èíôîðìàöèþ
|
|
mcall 9, buf, -1
|
|
mov eax, dword[buf+30]
|
|
mov dword[selfPID], eax
|
|
|
|
;óêàçàòåëè, êîòîðûå íèêîãäà íå ìåíÿþòñÿ:
|
|
mov esi, selfName ;ïåðâàÿ ñòðîêà - èìÿ òåêóùåãî ïðèëîæåíèÿ
|
|
mov edi, buf ;âòîðàÿ ñòðîêà - èìÿ òåêóùåãî ñëîòà
|
|
add edi, 10
|
|
|
|
mov ecx, 1
|
|
@@:
|
|
mcall 9, buf, ecx
|
|
mov dword[slotMax], eax
|
|
|
|
;åñëè ýòî ìû ñàìè, òî ïðîïóñêàåì ïðîâåðêó
|
|
mov eax, dword[buf+30]
|
|
cmp eax, dword[selfPID]
|
|
je copyKill.propusk
|
|
|
|
call compareBytes ;ñðàâíèâàåì 11 áàéò ñòðîê, ðåçóëüòàò â eax
|
|
|
|
cmp eax, 0
|
|
je copyKill.selfKill
|
|
|
|
.propusk:
|
|
inc ecx
|
|
cmp ecx, dword[slotMax]
|
|
ja @f
|
|
jmp @b
|
|
|
|
.selfKill:
|
|
pop edi esi ecx ebx eax
|
|
mcall -1
|
|
ret
|
|
@@:
|
|
pop edi esi ecx ebx eax
|
|
ret
|
|
|
|
|
|
;MODE 3
|
|
init03:
|
|
;mov dword[radius2], 100; 10*10
|
|
mov dword[backAdr], mode03
|
|
call setHotKey
|
|
mode03:
|
|
mcall 10
|
|
cmp eax, 2 ;îáðàáîòêà íàæàòèÿ êëàâèøè
|
|
je hotkey
|
|
|
|
;cmp byte[keyState], 0
|
|
;je mode03
|
|
cmp eax, 6 ;îáðàáîòêà ïåðåìåùåíèé è íàæàòèÿ ìûøè
|
|
je mouse03
|
|
|
|
jmp mode03
|
|
|
|
mouse03:
|
|
cmp byte[keyState], 0 ;åñëè êëàâèøà íå çàæàòà, òî îáíîâèì íà÷àëüíûå êîîðäèíàòû
|
|
je mouse03.updateCoord
|
|
|
|
cmp byte[state], LOCKd ;åñëè óãîë çàáëîêèðîâàí, òî îáíîâèì íà÷àëüíûå êîîðäèíàòû
|
|
je mouse03.updateCoord
|
|
|
|
cmp byte[state], SUPERLOCKd ;åñëè äåéñòâèå áûëî âûïîëíåíî è ïîëó÷èëè áëîêèðîâêó, òî æä¸ì îòïóñêàíèÿ êëàâèøè àêòèâàöèè
|
|
je @f
|
|
|
|
call checkPointInCircle ;èíà÷å åñëè ïðåîäîëåëè ðàäèóñ àêòèâàöèè, òî âûçûâàåì äåéñòâèå íóæíîãî óãëà
|
|
jmp @f
|
|
.updateCoord:
|
|
push eax ebx
|
|
mcall 37, 0 ;çàïîìèíàåì òåêóùèå(íà÷àëüíûå) êîîðäèíàòû ìûøè
|
|
;mov dword[o.x], eax
|
|
mov word[o.y], ax
|
|
shr eax, 16
|
|
mov word[o.x], ax
|
|
pop ebx eax
|
|
@@:
|
|
jmp dword[backAdr]
|
|
|
|
|
|
radius2 dd 0 ;êâàäðàò ðàäèóñà äëÿ mode 3
|
|
o: ;êîîðäèíàòû íà÷àëüíîé è òåêóùåé òî÷êè
|
|
.x: dw 0
|
|
.y: dw 0
|
|
.cx: dw 0
|
|
.cy: dw 0
|
|
|
|
;ïðîâåðêà âûõîäà çà ïðåäåëû êðóãà
|
|
; sqrt( (x2-x1)^2 + (y2-y1)^2 ) <= radius
|
|
; (x2-x1)^2 + (y2-y1)^2 <= radius^2
|
|
checkPointInCircle:
|
|
push eax ebx ecx edx
|
|
mcall 37, 0 ;ïîëó÷àåì òåêóùèå êîîðäèíàòû ìûøè
|
|
;mov dword[o.cx], eax
|
|
mov word[o.cy], ax
|
|
shr eax, 16
|
|
mov word[o.cx], ax
|
|
|
|
xor eax, eax
|
|
xor edx, edx
|
|
mov ax, word[o.x]
|
|
mov dx, word[o.cx]
|
|
cmp dx, ax
|
|
jae @f
|
|
sub ax, dx
|
|
mov dx, ax
|
|
jmp .xend
|
|
@@:
|
|
sub dx, ax
|
|
.xend:
|
|
mov eax, edx
|
|
mul dx
|
|
|
|
mov ebx, eax
|
|
|
|
xor eax, eax
|
|
xor edx, edx
|
|
mov ax, word[o.y]
|
|
mov dx, word[o.cy]
|
|
cmp dx, ax
|
|
jae @f
|
|
sub ax, dx
|
|
mov dx, ax
|
|
jmp .yend
|
|
@@:
|
|
sub dx, ax
|
|
.yend:
|
|
mov eax, edx
|
|
mul dx
|
|
|
|
add ebx, eax
|
|
|
|
cmp ebx, dword[radius2]
|
|
jbe @f
|
|
call activateCorner ;èíà÷å àêòèâèðóåì íóæíûé óãîë
|
|
@@:
|
|
pop edx ecx ebx eax
|
|
ret
|
|
|
|
;âûÿñíèòü â ñòîðîíó êàêîãî óãëà óøëè è àêòèâèðîâàòü åãî
|
|
activateCorner:
|
|
push eax ecx
|
|
xor eax, eax
|
|
|
|
mov ax, word[o.cx]
|
|
cmp ax, word[o.x]
|
|
je activateCorner.end ;åñëè êîîðäèíàòà ðàâíà, òî âûõîäèì (òàêîãî áûòü íå äîëæíî)
|
|
ja activateCorner.right
|
|
|
|
;èíà÷å ëåâàÿ ñòîðîíà
|
|
mov ax, word[o.cy]
|
|
cmp ax, word[o.y]
|
|
je activateCorner.end ;åñëè êîîðäèíàòà ðàâíà, òî âûõîäèì (òàêîãî áûòü íå äîëæíî)
|
|
jb activateCorner.leftup
|
|
|
|
;èíà÷å ëåâûé íèæíèé óãîë
|
|
mov ecx, 1
|
|
call run_command
|
|
mov byte[keyState], 0
|
|
mov byte[state], SUPERLOCKd
|
|
jmp activateCorner.end
|
|
|
|
.leftup:
|
|
;ëåâûé âåðõíèé óãîë
|
|
mov ecx, 0
|
|
call run_command
|
|
mov byte[keyState], 0
|
|
mov byte[state], SUPERLOCKd
|
|
jmp activateCorner.end
|
|
|
|
.right: ;ïðàâàÿ ñòîðîíà ýêðàíà
|
|
mov ax, word[o.cy]
|
|
cmp ax, word[o.y]
|
|
je activateCorner.end ;åñëè êîîðäèíàòà ðàâíà, òî âûõîäèì (òàêîãî áûòü íå äîëæíî)
|
|
jb activateCorner.rightup
|
|
|
|
;èíà÷å ïðàâûé íèæíèé óãîë
|
|
mov ecx, 3
|
|
call run_command
|
|
mov byte[keyState], 0
|
|
mov byte[state], SUPERLOCKd
|
|
jmp activateCorner.end
|
|
|
|
.rightup:
|
|
;ïðàâûé âåðõíèé óãîë
|
|
mov ecx, 2
|
|
call run_command
|
|
mov byte[keyState], 0
|
|
mov byte[state], SUPERLOCKd
|
|
jmp activateCorner.end
|
|
|
|
.end:
|
|
pop ecx eax
|
|
ret
|
|
|
|
|
|
|
|
keyActivate db 41 ;16 ;'Q' ;êëàâèøà àêòèâàöèè
|
|
keyState db 0 ;0-êëàâèøà íå àêòèâíà, 1 - êëàâèøà àêòèâíà
|
|
|
|
backAdr rd 1 ;àäðåñ äëÿ âîçâðàòà èç ïðîâåðêè ìûøè
|
|
slotMax rd 1
|
|
selfPID rd 1
|
|
buf rb 1024
|
|
|
|
;ñòðóêòóðêà äàííûõ äëÿ õðàíåíèÿ ïàðàìåòðîâ ýêðàíà
|
|
screen:
|
|
.width rw 1
|
|
.height rw 1
|
|
|
|
state: rb 1 ;ñîñòîÿíèå: 0=unlock, 1=lock, 2=superlock for mode 3
|
|
mode: rb 1 ;ðåæèì ðàáîòû ïðèëîæåíèÿ: 0=íå ðàáîòàåò, 1=êëàññè÷åñêèé, 2=ïî ãîðÿ÷åé êëàâèøå
|
|
|
|
|
|
keystr: rb 4 ;ñòðîêà ñî çíà÷åíèåì ñêàíêîäà àêòèâàöèîííîé êëàâèøè
|
|
radstr: rb 5 ;ñòðîêà ñî çíà÷åíèåì ðàäèóñà
|
|
apps:
|
|
.path1: rb 512
|
|
.path2: rb 512
|
|
.path3: rb 512
|
|
.path4: rb 512
|
|
.param1: rb 512
|
|
.param2: rb 512
|
|
.param3: rb 512
|
|
.param4: rb 512
|
|
appsEnd:
|
|
|
|
|
|
I_END:
|