Subversion Repositories Kolibri OS

Rev

Rev 4116 | Go to most recent revision | Details | Compare with Previous | 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
        neg    ecx
83
        add    ecx, edx
7671 dunkaist 84
        mul    esi
3478 0CodErr 85
        div    ecx
86
        ret
87
 
88
align 16
89
progressbar_progress:
90
        pushad
91
; if min > max then .skip
92
        mov    eax, pb
4116 0CodErr 93
        mov    edx, [eax + PB_MAX]
94
        mov    ecx, [eax + PB_MIN]
95
        cmp    ecx, edx
96
        ; jg     .skip
97
        jne    .min_no_eq_max1
98
        dec    edx
99
.min_no_eq_max1:
100
        call   get_progress_width
101
        mov    edi, eax
3478 0CodErr 102
; increase value
103
        mov    eax, pb
4116 0CodErr 104
        mov    ecx, [eax + PB_VALUE]
105
        mov    edx, [eax + PB_MAX]
106
        inc    ecx
3478 0CodErr 107
; if value > max then value = max
108
        cmp    ecx, edx
4116 0CodErr 109
        jng    .next
110
        mov    ecx, edx
111
.next:
112
        mov    [eax + PB_VALUE], ecx
3478 0CodErr 113
; draw new part of progress rectangle
114
        mov    eax, pb
4116 0CodErr 115
        mov    ecx, [eax + PB_MIN]
116
        cmp    ecx, edx
117
        jne    .min_no_eq_max2
118
        dec    edx
119
.min_no_eq_max2:
3478 0CodErr 120
        call   get_progress_width
4116 0CodErr 121
        mov    esi, eax
122
; edi = last pW, esi = new pW
123
        mov    eax, pb
3478 0CodErr 124
        mov    ebx, [eax + PB_LEFT]
125
        mov    ecx, [eax + PB_TOP]
4116 0CodErr 126
        mov    edx, [eax + PB_PROGRESS_COLOR]
127
        inc    ebx
128
        inc    ecx
129
        add    ebx, edi
3478 0CodErr 130
        shl    ecx, 16
4116 0CodErr 131
        shl    ebx, 16
3478 0CodErr 132
        add    ecx, [eax + PB_HEIGHT]
4116 0CodErr 133
        add    ebx, esi
134
        dec    ecx
135
        sub    ebx, edi
136
        mov    eax, 13
137
        dec    ecx
138
        int    64
3478 0CodErr 139
; .skip:
4116 0CodErr 140
        popad
3478 0CodErr 141
        ret    4
4116 0CodErr 142
restore pb
3478 0CodErr 143
}