Subversion Repositories Kolibri OS

Rev

Rev 3478 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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