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