Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
8346 IgorA 1
pb equ [esp + 4 + 8*4]
2
align 16
3
progressbar_draw:
4
        pushad
5
; draw frame
6
        mov    eax, pb
7
        mov    edx, [eax + PB_FRAME_COLOR]
8
        mov    ebx, [eax + PB_LEFT]
9
        mov    edi, [eax + PB_TOP]
10
        mov    ebp, [eax + PB_WIDTH]
11
        mov    esi, [eax + PB_HEIGHT]
12
        add    ebp, ebx
13
        add    esi, edi
14
        dec    ebp
15
        dec    esi
16
        mov    eax, SF_DRAW_LINE
17
        shl    ebx, 16
18
        mov    bx, bp
19
        shrd   ecx, edi, 16
20
        mov    cx, di
21
        int    64
22
        shrd   ecx, esi, 16
23
        mov    cx, si
24
        int    64
25
        shld   esi, ebx, 16
26
        mov    bx, si
27
        shrd   ecx, edi, 16
28
        int    64
29
        shrd   ebx, ebp, 16
30
        mov    bx, bp
31
        int    64
32
; if min > max then .skip
33
        mov    eax, pb
34
        mov    edx, [eax + PB_MAX]
35
        mov    ecx, [eax + PB_MIN]
36
        cmp    ecx, edx
37
        ; jg     .skip
38
        jne    .min_no_eq_max
39
        dec    edx
40
.min_no_eq_max:
41
; draw all progress rectangle
42
        call   get_progress_width
43
        mov    edi, eax
44
        mov    eax, pb
45
        mov    ebx, [eax + PB_LEFT]
46
        mov    ecx, [eax + PB_TOP]
47
        mov    edx, [eax + PB_PROGRESS_COLOR]
48
        inc    ebx
49
        inc    ecx
50
        shl    ebx, 16
51
        shl    ecx, 16
52
        add    ebx, edi
53
        add    ecx, [eax + PB_HEIGHT]
54
        dec    ecx
55
        mov    eax, SF_DRAW_RECT
56
        dec    ecx
57
        int    64
58
; draw last part of non-progress rectangle
59
; edi = pW, esi = W - 2
60
        sub    esi, edi ; width
61
        shr    ebx, 16
62
        add    ebx, edi
63
        shl    ebx, 16
64
        add    ebx, esi
65
        mov    esi, pb
66
        mov    edx, [esi + PB_BACK_COLOR]
67
        int    64
68
; .skip:
69
        popad
70
        ret    4
71
 
72
align 16
73
get_progress_width:
74
; pW = (W-2)(value - min) / (max - min)
75
        mov    esi, [eax + PB_WIDTH]
76
        mov    eax, [eax + PB_VALUE]
77
        dec    esi
78
        sub    eax, ecx
79
        dec    esi
80
        neg    ecx
81
        add    ecx, edx
82
        mul    esi
83
        div    ecx
84
        ret
85
 
86
align 16
87
progressbar_progress:
88
        pushad
89
; if min > max then .skip
90
        mov    eax, pb
91
        mov    edx, [eax + PB_MAX]
92
        mov    ecx, [eax + PB_MIN]
93
        cmp    ecx, edx
94
        ; jg     .skip
95
        jne    .min_no_eq_max1
96
        dec    edx
97
.min_no_eq_max1:
98
        call   get_progress_width
99
        mov    edi, eax
100
; increase value
101
        mov    eax, pb
102
        mov    ecx, [eax + PB_VALUE]
103
        mov    edx, [eax + PB_MAX]
104
        inc    ecx
105
; if value > max then value = max
106
        cmp    ecx, edx
107
        jng    .next
108
        mov    ecx, edx
109
.next:
110
        mov    [eax + PB_VALUE], ecx
111
; draw new part of progress rectangle
112
        mov    eax, pb
113
        mov    ecx, [eax + PB_MIN]
114
        cmp    ecx, edx
115
        jne    .min_no_eq_max2
116
        dec    edx
117
.min_no_eq_max2:
118
        call   get_progress_width
119
        mov    esi, eax
120
; edi = last pW, esi = new pW
121
        mov    eax, pb
122
        mov    ebx, [eax + PB_LEFT]
123
        mov    ecx, [eax + PB_TOP]
124
        mov    edx, [eax + PB_PROGRESS_COLOR]
125
        inc    ebx
126
        inc    ecx
127
        add    ebx, edi
128
        shl    ecx, 16
129
        shl    ebx, 16
130
        add    ecx, [eax + PB_HEIGHT]
131
        add    ebx, esi
132
        dec    ecx
133
        sub    ebx, edi
134
        mov    eax, SF_DRAW_RECT
135
        dec    ecx
136
        int    64
137
; .skip:
138
        popad
139
        ret    4
140
restore pb