2013-04-22 15:06:47 +04:00
|
|
|
macro use_progressbar
|
|
|
|
{
|
2013-10-28 15:50:01 +04:00
|
|
|
pb equ [esp + 4 + 8*4]
|
2013-04-22 15:06:47 +04:00
|
|
|
align 16
|
|
|
|
progressbar_draw:
|
|
|
|
pushad
|
|
|
|
; draw frame
|
|
|
|
mov eax, pb
|
2013-10-28 15:50:01 +04:00
|
|
|
mov edx, [eax + PB_FRAME_COLOR]
|
|
|
|
mov ebx, [eax + PB_LEFT]
|
2013-04-22 15:06:47 +04:00
|
|
|
mov edi, [eax + PB_TOP]
|
|
|
|
mov ebp, [eax + PB_WIDTH]
|
2013-10-28 15:50:01 +04:00
|
|
|
mov esi, [eax + PB_HEIGHT]
|
|
|
|
add ebp, ebx
|
|
|
|
add esi, edi
|
|
|
|
dec ebp
|
|
|
|
dec esi
|
2013-04-22 15:06:47 +04:00
|
|
|
mov eax, 38
|
|
|
|
shl ebx, 16
|
2013-10-28 15:50:01 +04:00
|
|
|
mov bx, bp
|
|
|
|
shrd ecx, edi, 16
|
|
|
|
mov cx, di
|
2013-04-22 15:06:47 +04:00
|
|
|
int 64
|
2013-10-28 15:50:01 +04:00
|
|
|
shrd ecx, esi, 16
|
|
|
|
mov cx, si
|
|
|
|
int 64
|
|
|
|
shld esi, ebx, 16
|
2013-04-22 15:06:47 +04:00
|
|
|
mov bx, si
|
2013-10-28 15:50:01 +04:00
|
|
|
shrd ecx, edi, 16
|
|
|
|
int 64
|
|
|
|
shrd ebx, ebp, 16
|
|
|
|
mov bx, bp
|
|
|
|
int 64
|
2013-04-22 15:06:47 +04:00
|
|
|
; if min > max then .skip
|
|
|
|
mov eax, pb
|
2013-10-28 15:50:01 +04:00
|
|
|
mov edx, [eax + PB_MAX]
|
|
|
|
mov ecx, [eax + PB_MIN]
|
|
|
|
cmp ecx, edx
|
|
|
|
; jg .skip
|
|
|
|
jne .min_no_eq_max
|
|
|
|
dec edx
|
|
|
|
.min_no_eq_max:
|
2013-04-22 15:06:47 +04:00
|
|
|
; draw all progress rectangle
|
2013-10-28 15:50:01 +04:00
|
|
|
call get_progress_width
|
|
|
|
mov edi, eax
|
|
|
|
mov eax, pb
|
2013-04-22 15:06:47 +04:00
|
|
|
mov ebx, [eax + PB_LEFT]
|
|
|
|
mov ecx, [eax + PB_TOP]
|
2013-10-28 15:50:01 +04:00
|
|
|
mov edx, [eax + PB_PROGRESS_COLOR]
|
|
|
|
inc ebx
|
|
|
|
inc ecx
|
|
|
|
shl ebx, 16
|
2013-04-22 15:06:47 +04:00
|
|
|
shl ecx, 16
|
2013-10-28 15:50:01 +04:00
|
|
|
add ebx, edi
|
2013-04-22 15:06:47 +04:00
|
|
|
add ecx, [eax + PB_HEIGHT]
|
2013-10-28 15:50:01 +04:00
|
|
|
dec ecx
|
|
|
|
mov eax, 13
|
|
|
|
dec ecx
|
2013-04-22 15:06:47 +04:00
|
|
|
int 64
|
|
|
|
; draw last part of non-progress rectangle
|
2013-10-28 15:50:01 +04:00
|
|
|
; edi = pW, esi = W - 2
|
2013-04-22 15:06:47 +04:00
|
|
|
sub esi, edi ; width
|
2013-10-28 15:50:01 +04:00
|
|
|
shr ebx, 16
|
2013-04-22 15:06:47 +04:00
|
|
|
add ebx, edi
|
|
|
|
shl ebx, 16
|
|
|
|
add ebx, esi
|
2013-10-28 15:50:01 +04:00
|
|
|
mov esi, pb
|
2013-04-22 15:06:47 +04:00
|
|
|
mov edx, [esi + PB_BACK_COLOR]
|
2013-10-28 15:50:01 +04:00
|
|
|
int 64
|
2013-04-22 15:06:47 +04:00
|
|
|
; .skip:
|
2013-10-28 15:50:01 +04:00
|
|
|
popad
|
2013-04-22 15:06:47 +04:00
|
|
|
ret 4
|
|
|
|
|
|
|
|
align 16
|
|
|
|
get_progress_width:
|
|
|
|
; pW = (W-2)(value - min) / (max - min)
|
|
|
|
mov esi, [eax + PB_WIDTH]
|
|
|
|
mov eax, [eax + PB_VALUE]
|
2013-10-28 15:50:01 +04:00
|
|
|
dec esi
|
2013-04-22 15:06:47 +04:00
|
|
|
sub eax, ecx
|
2013-10-28 15:50:01 +04:00
|
|
|
dec esi
|
2013-04-22 15:06:47 +04:00
|
|
|
imul eax, esi
|
|
|
|
neg ecx
|
|
|
|
add ecx, edx
|
|
|
|
xor edx, edx
|
|
|
|
div ecx
|
|
|
|
ret
|
|
|
|
|
|
|
|
align 16
|
|
|
|
progressbar_progress:
|
|
|
|
pushad
|
|
|
|
; if min > max then .skip
|
|
|
|
mov eax, pb
|
2013-10-28 15:50:01 +04:00
|
|
|
mov edx, [eax + PB_MAX]
|
|
|
|
mov ecx, [eax + PB_MIN]
|
|
|
|
cmp ecx, edx
|
|
|
|
; jg .skip
|
|
|
|
jne .min_no_eq_max1
|
|
|
|
dec edx
|
|
|
|
.min_no_eq_max1:
|
|
|
|
call get_progress_width
|
|
|
|
mov edi, eax
|
2013-04-22 15:06:47 +04:00
|
|
|
; increase value
|
|
|
|
mov eax, pb
|
2013-10-28 15:50:01 +04:00
|
|
|
mov ecx, [eax + PB_VALUE]
|
|
|
|
mov edx, [eax + PB_MAX]
|
|
|
|
inc ecx
|
2013-04-22 15:06:47 +04:00
|
|
|
; if value > max then value = max
|
|
|
|
cmp ecx, edx
|
2013-10-28 15:50:01 +04:00
|
|
|
jng .next
|
|
|
|
mov ecx, edx
|
|
|
|
.next:
|
|
|
|
mov [eax + PB_VALUE], ecx
|
2013-04-22 15:06:47 +04:00
|
|
|
; draw new part of progress rectangle
|
|
|
|
mov eax, pb
|
2013-10-28 15:50:01 +04:00
|
|
|
mov ecx, [eax + PB_MIN]
|
|
|
|
cmp ecx, edx
|
|
|
|
jne .min_no_eq_max2
|
|
|
|
dec edx
|
|
|
|
.min_no_eq_max2:
|
2013-04-22 15:06:47 +04:00
|
|
|
call get_progress_width
|
2013-10-28 15:50:01 +04:00
|
|
|
mov esi, eax
|
|
|
|
; edi = last pW, esi = new pW
|
|
|
|
mov eax, pb
|
2013-04-22 15:06:47 +04:00
|
|
|
mov ebx, [eax + PB_LEFT]
|
|
|
|
mov ecx, [eax + PB_TOP]
|
2013-10-28 15:50:01 +04:00
|
|
|
mov edx, [eax + PB_PROGRESS_COLOR]
|
|
|
|
inc ebx
|
|
|
|
inc ecx
|
|
|
|
add ebx, edi
|
2013-04-22 15:06:47 +04:00
|
|
|
shl ecx, 16
|
2013-10-28 15:50:01 +04:00
|
|
|
shl ebx, 16
|
2013-04-22 15:06:47 +04:00
|
|
|
add ecx, [eax + PB_HEIGHT]
|
2013-10-28 15:50:01 +04:00
|
|
|
add ebx, esi
|
|
|
|
dec ecx
|
|
|
|
sub ebx, edi
|
|
|
|
mov eax, 13
|
|
|
|
dec ecx
|
|
|
|
int 64
|
2013-04-22 15:06:47 +04:00
|
|
|
; .skip:
|
2013-10-28 15:50:01 +04:00
|
|
|
popad
|
2013-04-22 15:06:47 +04:00
|
|
|
ret 4
|
2013-10-28 15:50:01 +04:00
|
|
|
restore pb
|
2013-04-22 15:06:47 +04:00
|
|
|
}
|