Subversion Repositories Kolibri OS

Rev

Rev 109 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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