volume: add mute toggling, some fixes

git-svn-id: svn://kolibrios.org@5446 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
eAndrew 2015-02-22 10:55:51 +00:00
parent 0fb6c6aab6
commit 2fe34627a2

View File

@ -1,20 +1,24 @@
; 1.0.1
DEBUG equ 0
WIN_SIZE equ 120 WIN_SIZE equ 120
TIMER equ 60 TIMER equ 60
use32 use32
org 0 org 0
db 'MENUET01' db 'MENUET01'
dd 1, @entry, @end, @memory, @stack, @params, 0 dd 1, daemon_entry, @end, @memory, @stack, @params, 0
include "../../macros.inc" include "../../macros.inc"
include "../../proc32.inc" include "../../proc32.inc"
include "../../dll.inc" include "../../dll.inc"
; include "../../debug.inc"
include "macros.inc" include "macros.inc"
if DEBUG eq 1
include "../../debug.inc"
end if
;===================================================================== ;=====================================================================
@entry: daemon_entry:
mcall 68, 11 mcall 68, 11
mcall 68, 22, shm_name, 512, 5 mcall 68, 22, shm_name, 512, 5
mov [shm], eax mov [shm], eax
@ -26,9 +30,14 @@
@@: @@:
mcall 9, buffer, edi mcall 9, buffer, edi
cmpe dword[buffer + 30], esi, .next cmpe dword[buffer + 30], esi, .next
cmpe dword[buffer + 10], dword "@Vol", @open_1 cmpe dword[buffer + 10], dword "@Vol", open_1
cmpe dword[buffer + 10], dword "@VOL", @open_1 cmpe dword[buffer + 10], dword "@VOL", open_1
cmpe dword[buffer + 10], dword "@vol", @open_1 cmpe dword[buffer + 10], dword "@vol", open_1
if DEBUG eq 1
cmpe dword[buffer + 10], dword "Volu", open_1
cmpe dword[buffer + 10], dword "VOLu", open_1
cmpe dword[buffer + 10], dword "volu", open_1
end if
.next: .next:
dec edi dec edi
jnz @b jnz @b
@ -37,10 +46,12 @@
mov [eax], dword 0 mov [eax], dword 0
mcall 40, 10b mcall 40, 10b
mcall 66, 1, 1 mcall 66, 1, 1
;mcall 66, 4, 16, 0x110
mcall 66, 4, 77, 0x110 mcall 66, 4, 77, 0x110
mcall 66, 4, 75, 0x110 mcall 66, 4, 75, 0x110
mcall 66, 4, 80, 0x110 mcall 66, 4, 80, 0x110
if DEBUG eq 1
mcall 66, 4, 16, 0x110
end if
stdcall dll.Load, @imports stdcall dll.Load, @imports
stdcall dword[img.decode], icons, icons.size, 0 stdcall dword[img.decode], icons, icons.size, 0
@ -53,14 +64,21 @@
mov [snd_driver], eax mov [snd_driver], eax
cmpe eax, 0, exit cmpe eax, 0, exit
@update: mcall 70, is_load
mcall 23, 5 cmpe eax, 0, @f
cmpe al, EV_KEY, @key mov dword[volume], 5
mov eax, [shm] @@:
cmpne [eax], dword 0, @open_2 mcall 70, is_save
jmp @update call set_sound_proc
@open_1: update:
mcall 23, 5
cmpe al, EV_KEY, key
mov eax, [shm]
cmpne [eax], dword 0, open_2
jmp update
open_1:
mov ebx, 1 mov ebx, 1
cmpne [@params], byte '+', @f cmpne [@params], byte '+', @f
mov ebx, 2 mov ebx, 2
@ -70,32 +88,31 @@
@@: @@:
cmpne [@params], byte 'm', @f cmpne [@params], byte 'm', @f
mov ebx, 4 mov ebx, 4
@@:
cmpne [@params], byte 's', @f
mov ebx, 5
@@: @@:
mov eax, [shm] mov eax, [shm]
mov [eax], ebx mov [eax], ebx
jmp @exit jmp exit
@open_2: open_2:
mov eax, [shm] mov eax, [shm]
mov ebx, [eax] mov ebx, [eax]
mov [command], ebx mov [command], ebx
mov [eax], dword 0 mov [eax], dword 0
cmpne [win.pid], dword 0, @update cmpne [win.pid], dword 0, update
mcall 51, 1, _entry, _stack mcall 51, 1, _entry, _stack
jmp @update jmp update
@key: key:
mcall 2 mcall 2
;cmpe ah, 16, @exit if DEBUG
cmpe ah, 16, exit
end if
mov edx, [shm] mov edx, [shm]
cmpne ah, 77, @f cmpne ah, 77, @f
.cm_1: .cm_1:
cmpne [win.pid], 0, .else_1 cmpne [win.pid], 0, .else_1
mov [edx], dword 2 mov [edx], dword 2
jmp @open_2 jmp open_2
.else_1: .else_1:
mov [command], 2 mov [command], 2
@@: @@:
@ -103,18 +120,21 @@
.cm_2: .cm_2:
cmpne [win.pid], 0, .else_2 cmpne [win.pid], 0, .else_2
mov [edx], dword 3 mov [edx], dword 3
jmp @open_2 jmp open_2
.else_2: .else_2:
mov [command], 3 mov [command], 3
@@: @@:
cmpne ah, 80, @f cmpne ah, 80, @f
.cm_3: .cm_3:
mov [edx], dword 4 mov [edx], dword 4
jmp @open_2 jmp open_2
@@: @@:
jmp @update jmp update
@exit: exit:
if DEBUG eq 1
dps "EXIT"
end if
mcall -1 mcall -1
;===================================================================== ;=====================================================================
@ -166,11 +186,9 @@
jmp .apply jmp .apply
@@: @@:
cmpne [command], 4, @f cmpne [command], 4, @f
mov [mute], 1 mov eax, 1
jmp .apply sub eax, [mute]
@@: mov [mute], eax
cmpne [command], 5, @f
mov [mute], 0
jmp .apply jmp .apply
.apply: .apply:
@ -182,14 +200,17 @@
mov ecx, eax mov ecx, eax
mcall 9, buffer mcall 9, buffer
mov eax, dword[buffer + 30] mov eax, dword[buffer + 30]
cmpne [win.pid], eax, exit cmpne [win.pid], eax, _exit
dec dword[timer] dec dword[timer]
jnz _update jnz _update
;---------------------------- ;----------------------------
exit: _exit:
if DEBUG eq 1
dps "CLOSE"
end if
mov [win.pid], 0 mov [win.pid], 0
mcall 70, is_save mcall 70, is_save
mcall -1 mcall -1
@ -198,7 +219,7 @@
_button: _button:
mcall 17 mcall 17
cmpe ah, 1, exit cmpe ah, 1, _exit
cmpe ah, 3, toggle_mute cmpe ah, 3, toggle_mute
jmp _update jmp _update
@ -206,15 +227,13 @@
_key: _key:
mcall 2 mcall 2
cmpe ah, 027, exit cmpe ah, 027, _exit
cmpe ah, 176, dec_volume ; <- cmpe ah, 176, dec_volume ; <-
cmpe ah, 183, dec_volume ; PgDown cmpe ah, 183, dec_volume ; PgDown
cmpe ah, 179, inc_volume ; -> cmpe ah, 179, inc_volume ; ->
cmpe ah, 184, inc_volume ; PgUp cmpe ah, 184, inc_volume ; PgUp
cmpe ah, 178, unmute_volume ; ^ cmpe ah, 177, toggle_mute ; v
cmpe ah, 180, unmute_volume ; Home cmpe ah, 181, toggle_mute ; End
cmpe ah, 177, mute_volume ; v
cmpe ah, 181, mute_volume ; End
jmp _update jmp _update
@ -244,10 +263,7 @@
inc_volume: inc_volume:
cmpe dword[volume], 10, _update cmpe dword[volume], 10, _update
inc dword[volume] inc dword[volume]
jmp unmute_volume
unmute_volume:
mov [mute], 0
jmp @f
toggle_mute: toggle_mute:
mov eax, 1 mov eax, 1
@ -255,11 +271,18 @@
mov [mute], eax mov [mute], eax
jmp @f jmp @f
mute_volume: unmute_volume:
mov [mute], 1 mov dword[mute], 0
set_sound: set_sound:
@@: @@:
call set_sound_proc
mov dword[timer], TIMER
call draw_icon
call draw_bar
jmp _update
set_sound_proc:
mov [snd_driver.command], 6 mov [snd_driver.command], 6
mov [snd_driver.inputsz], 4 mov [snd_driver.inputsz], 4
mov [snd_driver.output], 0 mov [snd_driver.output], 0
@ -273,11 +296,7 @@
neg edi neg edi
mov dword[buffer], edi mov dword[buffer], edi
mcall 68, 17, snd_driver mcall 68, 17, snd_driver
ret
mov dword[timer], TIMER
call draw_icon
call draw_bar
jmp _update
;---------------------------- ;----------------------------