Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
31 halyavin 1
thread:
139 diamond 2
        mov     edi, textbox_string
3
        or      ecx, -1
4
        xor     eax, eax
5
        repnz   scasb
6
        not     ecx
7
        dec     ecx
8
        mov     [textbox_position], cl
31 halyavin 9
        call    draw_window
10
        call    main_loop
11
        mov     [status], ST_EXIT
12
        mcall   MF_EXIT
13
 
14
;---------------------------------------------------------------------
15
 
16
main_loop:
17
        cmp     [status], ST_PLAY
18
        je      @f
19
        mcall   MF_WAIT_EVENT
20
        jmp     .handle_event
21
     @@:
22
        call    draw_progress_bar
23
        mcall   MF_WAIT_EVENT_TIMEOUT, 80
24
     .handle_event:
25
        cmp     eax, EV_REDRAW
26
        je      redraw
27
        cmp     eax, EV_BUTTON
28
        je      button
29
        cmp     eax, EV_KEY
30
        je      key
31
        jmp     main_loop
32
 
33
 redraw:
34
        call    draw_window
35
        jmp     main_loop
36
 
37
 key:
38
        mcall   MF_GETKEY
39
        cmp     [textbox_active], 1
40
        jne     main_loop
41
        cmp     ah, 13
42
        je      .enter
43
        cmp     ah, 8
44
        je      .backspace
45
        movzx   ecx, [textbox_position]
139 diamond 46
        cmp     ecx, 255
31 halyavin 47
        jae     .enter
48
        mov     [textbox_string + ecx], ah
49
        inc     [textbox_position]
50
        call    textbox_draw
51
        jmp     main_loop
52
  .enter:
53
        mov     [textbox_active], 0
54
        call    textbox_draw
55
        jmp     main_loop
56
  .backspace:
57
        movzx   ecx, [textbox_position]
58
        test    ecx, ecx
59
        jz      main_loop
60
        dec     [textbox_position]
139 diamond 61
        mov     [textbox_string + ecx - 1], byte 0
31 halyavin 62
        call    textbox_draw
63
        jmp     main_loop
64
 
65
 button:
66
        mcall   MF_GETBUTTON
67
        cmp     ah, 0x10
68
        je      play_button
69
        cmp     ah, 0x11
70
        je      stop_button
71
        cmp     ah, 0x12
72
        je      decr_button
73
        cmp     ah, 0x13
74
        je      incr_button
75
        cmp     ah, 0x14
76
        je      volm_button
77
        cmp     ah, 0x15
78
        je      volp_button
79
        cmp     ah, 0x20
80
        je      activate_textbox
81
        cmp     ah, 0x30
82
        je      progressbar_click
83
        cmp     ah, 1
84
        jne     main_loop
85
 
86
;        mov     [status], ST_STOP
87
;        mcall   MF_DELAY, 40
88
        ret
89
 
90
    play_button:
91
        xor     eax, eax
92
        xchg    al, [textbox_active]
93
        cmp     al, 0
94
        je      @f
95
        call    textbox_draw
96
      @@:
97
        mov     [status], ST_PLAY
98
        jmp     main_loop
99
    stop_button:
100
        mov     [status], ST_STOP
101
        jmp     main_loop
102
 
103
    decr_button:
104
;        mov     [status], ST_STOP
105
;       @@:
106
;        mcall   5, 1
107
;        cmp     [status], ST_DONE
108
;        jne     @b
109
;        movzx   esi, [textbox_position]
110
;        add     esi, textbox_string
111
;       @@:
112
;        cmp     byte [esi], '/'
113
;        je      @f
114
;        dec     esi
115
;        jmp     @b
116
;       @@:
117
;        mov     byte [esi+1], 0
118
;        mov     [fileinfo.first_block], 0
119
;        mov     [fileinfo.dest], WAV_BUFFER1
120
;        mcall   58, fileinfo
121
;        add     ebx, WAV_BUFFER1
122
;        mov     esi, WAV_BUFFER1+8
123
;      .next_file:
124
;        cmp     ebx, esi
125
;        jbe     .fin
126
;        cmp     word [esi], "WA"
127
;        jne     .next_file
128
;        cmp     byte [esi+1], "V"
129
;        jne     .next_file
130
;      .fin:
131
 
132
        ;mov     eax, [fileinfo.first_block]
133
        ;cmp     eax, 1000
134
        ;jnl     @f
135
        ;mov     [fileinfo.first_block], 0
136
        ;jmp     main_loop
137
       ;@@:
138
        ;sub     [fileinfo.first_block], 1000
139
        ;jmp     main_loop
140
 
141
    incr_button:
142
        ;add     [fileinfo.first_block], 1000
143
        jmp     main_loop
144
 
145
    volm_button:
146
        inc     byte [volume]
147
        and     byte [volume], 0x1f
148
        jz      volp_button
149
        or      [volume], 0x10000000
150
        jmp     _print_volume
151
;        jmp     main_loop
152
 
153
    volp_button:
154
        dec     byte [volume]
155
        and     byte [volume], 0x1f
156
        jz      volm_button
157
        or      [volume], 0x10000000
158
;        jmp     main_loop
159
 
160
    _print_volume:
161
        movzx   eax, byte [volume]
162
        neg     eax
163
        add     eax, 31
164
        dps     "Volume: "
165
        dpd     eax
166
        newline
167
        jmp     main_loop
168
 
169
    activate_textbox:
170
        cmp     [status], ST_DONE
171
        jne     main_loop
172
        mov     [textbox_active], 1
173
        call    textbox_draw
174
        jmp     main_loop
175
 
176
    progressbar_click:
177
        ;print  "click on progress bar"
178
        cmp     [status], ST_DONE
179
        je      main_loop
180
        mcall   MF_GETMOUSE, MS_COORDS_WINDOW
181
        shr     eax, 16 ; get mouse.x
182
        sub     eax, 7
183
        jz      @f
139 diamond 184
        imul    [file_size]
31 halyavin 185
        mov     ebx, 286
186
        div     ebx
187
     @@:
188
        ;dps "block: "
189
        ;dpd eax
190
        ;newline
156 diamond 191
        and     eax, not 511
139 diamond 192
        mov     [fileinfo.first_byte], eax
31 halyavin 193
        call    draw_progress_bar
194
        jmp     main_loop
195
ret
196
 
197
;---------------------------------------------------------------------
198
 
199
PBAR_WIDTH = 286
200
 
201
draw_window:
202
        mcall   MF_DRAWSTATUS, DS_BEGIN
203
 
204
        mcall   MF_WINDOW, <100,299>, <100,72>, 0x03404040
205
 
206
        ; create six buttons
207
        mov     edi, 6
208
        mpack   ebx, 7, 45
209
        mpack   ecx, 24, 13
210
        mov     edx, 0x10
211
        mov     esi, 0xA0A0A0
212
      @@:
213
        mcall   MF_BUTTON
214
        add     ebx, 48 shl 16
215
        inc     edx
216
        dec     edi
217
        jnz     @b
218
 
219
        mcall   MF_TEXT, <8,8>, 0x10FFFFFF, header, header.size
220
 
221
        mcall   ,<13,28>, 0x404040, buttons_text, buttons_text.size
222
        sub     ebx, 0x00010001
223
        mov     ecx, 0xFFFFFF
224
        mcall
225
 
226
        call    draw_progress_bar
227
        call    textbox_draw
228
 
229
        mcall   MF_DRAWSTATUS, DS_END
230
ret
231
 
232
;---------------------------------------------------------------------
233
 
234
textbox_draw:
235
        mcall   MF_BUTTON, <7,285>, <55,10>, 0x60000020
236
 
237
        mov     edx, 0x808080
238
        cmp     [textbox_active], 1
239
        jne     @f
240
        mov     edx, 0xA0A0A0
241
    @@:
242
        mcall   MF_BAR, <7,286>, <55,11>
243
 
244
        movzx   esi, [textbox_position]
245
        mcall   MF_TEXT, <10,56>, 0x404040, textbox_string
246
ret
247
 
248
;---------------------------------------------------------------------
249
 
250
draw_progress_bar:
251
        pushad
252
 
139 diamond 253
        mov     eax, PBAR_WIDTH
254
        mul     [fileinfo.first_byte]
31 halyavin 255
        div     [file_size]
256
 
257
        push    eax
258
        mcall   MF_BAR, <7,286>, <41,11>, 0x808080
259
        mcall   MF_BUTTON,     ,        , 0x60000030
260
        pop     eax
261
 
262
        mov     bx, ax
263
        mov     edx, 0xA0A0A0
264
        mcall   MF_BAR
265
 
266
        popad
267
ret
268
 
269
;---------------------------------------------------------------------
270
 
271
sz header,       "AC'97 WAV player -  all PCM audio"
272
sz buttons_text, " Play    Stop     <<      >>     Vol-    Vol+"
273
 
274
textbox_active    db 0
139 diamond 275
textbox_position  db 0;textbox_string.size-1
31 halyavin 276
file_size dd 100