Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4349 | Serge | 1 | |
2 | |||
3 | |||
4 | |||
5 | |||
6 | main: |
||
7 | .argc equ ebp+8 |
||
8 | .argv equ ebp+12 |
||
9 | .envp equ ebp+16 |
||
10 | |||
11 | |||
12 | push ebp |
||
13 | mov ebp, esp |
||
14 | push ebx |
||
15 | |||
16 | |||
17 | cmp eax, 2 |
||
18 | jae @F |
||
19 | |||
20 | |||
21 | mov [input_file], eax |
||
22 | |||
23 | |||
24 | call [mpg123_init] |
||
25 | test eax, eax |
||
26 | jz @F |
||
27 | |||
28 | |||
29 | call [mpg123_plain_strerror] |
||
30 | |||
31 | |||
32 | push msg_init_fail |
||
33 | call [_printf] |
||
34 | add esp, 4 |
||
35 | jmp .fail |
||
36 | @@: |
||
37 | push dword error |
||
38 | push 0 |
||
39 | call [mpg123_new] |
||
40 | add esp, 8 |
||
41 | |||
42 | |||
43 | mov ebx, eax |
||
44 | test eax, eax |
||
45 | jz .err_1 |
||
46 | |||
47 | |||
48 | push eax |
||
49 | call [mpg123_open] |
||
50 | add esp, 8 |
||
51 | |||
52 | |||
53 | jnz .err_1 |
||
54 | |||
55 | |||
56 | push channels |
||
57 | push rate |
||
58 | push ebx |
||
59 | call [mpg123_getformat] |
||
60 | add esp, 16 |
||
61 | |||
62 | |||
63 | jnz .err_1 |
||
64 | |||
65 | |||
66 | call [mpg123_scan] |
||
67 | test eax, eax |
||
68 | jz @F |
||
69 | |||
70 | |||
71 | mov [esp], eax |
||
72 | push msg_print |
||
73 | call [_printf] |
||
74 | add esp, 8 |
||
75 | jmp .fail |
||
76 | |||
77 | |||
78 | call [mpg123_format_none] |
||
79 | mov ecx, [encoding] |
||
80 | mov [esp], ecx |
||
81 | push [channels] |
||
82 | push [rate] |
||
83 | push ebx |
||
84 | call [mpg123_format] |
||
85 | add esp, 16 |
||
86 | |||
87 | |||
88 | stdcall InitSound |
||
89 | test eax, eax |
||
90 | jz @F |
||
91 | |||
92 | |||
93 | jmp .fail |
||
94 | @@: |
||
95 | mov eax, [rate] |
||
96 | mov ecx, [channels] |
||
97 | |||
98 | |||
99 | mov [whdr.riff_format], 0x45564157 |
||
100 | mov [whdr.wFormatTag], 0x01 |
||
101 | mov [whdr.nSamplesPerSec], eax |
||
102 | mov [whdr.nChannels], cx |
||
103 | mov [whdr.wBitsPerSample], 16 |
||
104 | |||
105 | |||
106 | stdcall CreateBuffer, eax, 0, hBuff |
||
107 | test eax, eax |
||
108 | jz @F |
||
109 | |||
110 | |||
111 | jmp .fail |
||
112 | @@: |
||
113 | mov eax, [hBuff] |
||
114 | push esi |
||
115 | push edi |
||
116 | |||
117 | |||
118 | mov eax, 68 |
||
119 | mov ebx, 12 |
||
120 | int 0x40 |
||
121 | |||
122 | |||
123 | push count ;&count esp+12 |
||
124 | push 0x40000 ;remain esp+8 |
||
125 | push eax ;outPtr esp+4 |
||
126 | push [mh] ;mh esp |
||
127 | |||
128 | |||
129 | |||
130 | |||
131 | ; int3 |
||
132 | mov [count], 0 |
||
133 | call [mpg123_read] |
||
134 | mov ebx, [count] |
||
135 | test eax, eax |
||
136 | jz @F |
||
137 | test ebx, ebx |
||
138 | jz .done |
||
139 | @@: |
||
140 | .write_out: |
||
141 | add ebx, 4095 |
||
142 | and ebx, -4096 |
||
143 | mov esi, [esp+16] |
||
144 | stdcall WaveOut, [hBuff], esi, ebx |
||
145 | mov [esp+8], dword 0x40000 |
||
146 | mov edi, [esp+16] |
||
147 | mov [esp+4], edi |
||
148 | jmp .inner |
||
149 | .done: |
||
150 | mov edi, [esp+16] |
||
151 | mov ecx, 4096 |
||
152 | xor eax, eax |
||
153 | rep stosd |
||
154 | mov esi, [esp+16] |
||
155 | stdcall WaveOut, [hBuff], esi, 16384 |
||
156 | add esp, 20 |
||
157 | pop edi |
||
158 | pop esi |
||
159 | |||
160 | |||
161 | pop ebx |
||
162 | mov esp, ebp |
||
163 | pop ebp |
||
164 | ret |
||
165 | |||
166 | |||
167 | test ebx, ebx |
||
168 | jnz @F |
||
169 | |||
170 | |||
171 | call [mpg123_plain_strerror] |
||
172 | jmp .err_2 |
||
173 | @@: |
||
174 | push ebx |
||
175 | call [mpg123_strerror] |
||
176 | .err_2: |
||
177 | mov [esp], eax |
||
178 | push msg_trouble |
||
179 | call [_printf] |
||
180 | add esp, 8 |
||
181 | .fail: |
||
182 | mov eax, -1 |
||
183 | pop ebx |
||
184 | mov esp, ebp |
||
185 | pop ebp |
||
186 | ret |
||
187 | |||
188 | |||
189 | getprocaddress: |
||
190 | mov edx, [esp + 8] ; hlib |
||
191 | xor eax, eax |
||
192 | test edx, edx ; If hlib = 0 then goto .end |
||
193 | jz .end |
||
194 | |||
195 | |||
196 | cmp [edx], dword 0 ; If end of export table then goto .end |
||
197 | jz .end |
||
198 | |||
199 | |||
200 | mov esi, [edx] |
||
201 | mov edi, [esp + 4] ; name |
||
202 | |||
203 | |||
204 | lodsb |
||
205 | scasb |
||
206 | jne .fail |
||
207 | or al, al |
||
208 | jnz .next_ |
||
209 | jmp .ok |
||
210 | .fail: |
||
211 | add edx, 8 |
||
212 | jmp .next |
||
213 | |||
214 | |||
215 | mov eax, [edx + 4] |
||
216 | .end: |
||
217 | ret 8 |
||
218 | |||
219 | |||
220 | |||
221 | _get_moviefile: |
||
222 | |||
223 | |||
224 | mov eax, 68 |
||
225 | mov ebx, 19 |
||
226 | mov ecx, sz_proc_lib |
||
227 | int 0x40 |
||
228 | mov [proclib], eax |
||
229 | test eax, eax |
||
230 | jz .fail |
||
231 | |||
232 | |||
233 | push sz_OpenDialog_init |
||
234 | call getprocaddress |
||
235 | mov [opendialog_init], eax |
||
236 | |||
237 | |||
238 | push sz_OpenDialog_start |
||
239 | call getprocaddress |
||
240 | mov [opendialog_start], eax |
||
241 | |||
242 | |||
243 | mov ebx, 12 |
||
244 | mov ecx, 4096*3 |
||
245 | int 0x40 |
||
246 | |||
247 | |||
248 | |||
249 | |||
250 | mov [od.filename_area], eax |
||
251 | |||
252 | |||
253 | mov [od.opendir_path], eax |
||
254 | |||
255 | |||
256 | mov [od.openfile_path], eax |
||
257 | |||
258 | |||
259 | call [opendialog_init] |
||
260 | |||
261 | |||
262 | mov [eax], byte 0 ; end of ASCIIZ-string(may be don't need?) |
||
263 | |||
264 | |||
265 | call [opendialog_start] |
||
266 | |||
267 | |||
268 | mov eax, [od.openfile_path]; selected filePath |
||
269 | |||
270 | |||
271 | .fail: |
||
272 | xor eax, eax |
||
273 | ret |
||
274 | |||
275 | |||
276 | fake_on_redraw: |
||
277 | ret |
||
278 | |||
279 | |||
280 | |||
281 | SND_CREATE_BUFF equ 1 |
||
282 | SND_DESTROY_BUFF equ 2 |
||
283 | SND_SETFORMAT equ 3 |
||
284 | SND_GETFORMAT equ 4 |
||
285 | SND_RESET equ 5 |
||
286 | SND_SETPOS equ 6 |
||
287 | SND_GETPOS equ 7 |
||
288 | SND_SETBUFF equ 8 |
||
289 | SND_OUT equ 9 |
||
290 | SND_PLAY equ 10 |
||
291 | SND_STOP equ 11 |
||
292 | SND_SETVOLUME equ 12 |
||
293 | SND_GETVOLUME equ 13 |
||
294 | SND_SETPAN equ 14 |
||
295 | SND_GETPAN equ 15 |
||
296 | SND_GETBUFFSIZE equ 16 |
||
297 | SND_GETFREESPACE equ 17 |
||
298 | SND_SETTIMEBASE equ 18 |
||
299 | SND_GETTIMESTAMP equ 19 |
||
300 | |||
301 | |||
302 | |||
303 | InitSound: ;p_ver:dword |
||
304 | |||
305 | |||
306 | push ecx |
||
307 | |||
308 | |||
309 | mov ebx, 16 |
||
310 | mov ecx, szInfinity |
||
311 | int 0x40 |
||
312 | mov [hSound], eax |
||
313 | test eax, eax |
||
314 | jz .fail |
||
315 | |||
316 | |||
317 | mov ebx, 16 |
||
318 | mov ecx, szSound |
||
319 | int 0x40 |
||
320 | mov [hrdwSound], eax |
||
321 | |||
322 | |||
323 | xor ebx, ebx |
||
324 | |||
325 | |||
326 | push eax ;.output |
||
327 | push ebx ;.inp_size |
||
328 | push ebx ;.input |
||
329 | push SRV_GETVERSION ;.code |
||
330 | push [hSound] ;.handle |
||
331 | |||
332 | |||
333 | mov ebx, 17 |
||
334 | mov ecx, esp ;[handle] |
||
335 | int 0x40 |
||
336 | add esp, 24 |
||
337 | pop ecx |
||
338 | pop ebx |
||
339 | ret 4 |
||
340 | .fail: |
||
341 | or eax, -1 |
||
342 | pop ecx |
||
343 | pop ebx |
||
344 | ret 4 |
||
345 | |||
346 | |||
347 | |||
348 | CreateBuffer: ;format:dword,size:dword,p_str:dword |
||
349 | |||
350 | |||
351 | push ecx |
||
352 | lea eax, [esp+20] ;p_str |
||
353 | lea ebx, [esp+12] ;format |
||
354 | |||
355 | |||
356 | push eax ;.output |
||
357 | push 8 ;.inp_size |
||
358 | push ebx ;.input |
||
359 | push SND_CREATE_BUFF;.code |
||
360 | push [hSound] ;.handle |
||
361 | |||
362 | |||
363 | mov ebx, 17 |
||
364 | mov ecx, esp |
||
365 | int 0x40 |
||
366 | add esp, 24 ;io_cintrol |
||
367 | pop ecx |
||
368 | pop ebx |
||
369 | ret 12 |
||
370 | |||
371 | |||
372 | proc test_wav stdcall, hdr:dword |
||
373 | |||
374 | |||
375 | cmp dword [eax], 0x46464952 |
||
376 | jne .fail |
||
377 | |||
378 | |||
379 | jne .fail |
||
380 | |||
381 | |||
382 | jne .fail |
||
383 | |||
384 | |||
385 | mov edx, 22050 |
||
386 | cmp ecx, edx |
||
387 | ja .high |
||
388 | je .l_22 |
||
389 | |||
390 | |||
391 | je .l_8 |
||
392 | |||
393 | |||
394 | je .l_11 |
||
395 | |||
396 | |||
397 | je .l_12 |
||
398 | |||
399 | |||
400 | je .l_16 |
||
401 | .fail: |
||
402 | xor eax, eax |
||
403 | ret |
||
404 | .high: |
||
405 | cmp ecx, 24000 |
||
406 | je .LN56 |
||
407 | cmp ecx, 32000 |
||
408 | je .LN65 |
||
409 | cmp ecx, 44100 |
||
410 | je .LN74 |
||
411 | cmp ecx, 48000 |
||
412 | jne .fail |
||
413 | |||
414 | |||
415 | dec ecx |
||
416 | je .LN79 |
||
417 | dec ecx |
||
418 | jne .LN74 |
||
419 | |||
420 | |||
421 | jmp .done |
||
422 | .LN79: |
||
423 | mov edx, 20 |
||
424 | jmp .done |
||
425 | .LN74: |
||
426 | movzx ecx, word [eax+22] |
||
427 | dec ecx |
||
428 | je .LN70 |
||
429 | dec ecx |
||
430 | jne .LN65 |
||
431 | |||
432 | |||
433 | jmp .done |
||
434 | .LN70: |
||
435 | mov edx, 22 |
||
436 | jmp .done |
||
437 | .LN65: |
||
438 | movzx ecx, word [eax+22] |
||
439 | dec ecx |
||
440 | je .LN61 |
||
441 | dec ecx |
||
442 | jne .LN56 |
||
443 | |||
444 | |||
445 | jmp .done |
||
446 | .LN61: |
||
447 | mov edx, 24 |
||
448 | jmp .done |
||
449 | .LN56: |
||
450 | movzx ecx, word [eax+22] |
||
451 | dec ecx |
||
452 | je .LN52 |
||
453 | dec ecx |
||
454 | je .LN50 |
||
455 | .l_22: |
||
456 | movzx ecx, word [eax+22] |
||
457 | dec ecx |
||
458 | je .LN43 |
||
459 | dec ecx |
||
460 | je .LN41 |
||
461 | .l_16: |
||
462 | movzx ecx, word [eax+22] |
||
463 | dec ecx |
||
464 | je .LN34 |
||
465 | dec ecx |
||
466 | je .LN32 |
||
467 | .l_12: |
||
468 | movzx ecx, word [eax+22] |
||
469 | dec ecx |
||
470 | je .LN25 |
||
471 | dec ecx |
||
472 | je .LN23 |
||
473 | .l_11: |
||
474 | movzx ecx, word [eax+22] |
||
475 | dec ecx |
||
476 | je .LN16 |
||
477 | dec ecx |
||
478 | je .LN14 |
||
479 | .l_8: |
||
480 | movzx ecx, word [eax+22] |
||
481 | dec ecx |
||
482 | je .LN7 |
||
483 | dec ecx |
||
484 | jne .fail |
||
485 | |||
486 | |||
487 | jmp .done |
||
488 | .LN7: |
||
489 | mov edx, 36 |
||
490 | jmp .done |
||
491 | .LN14: |
||
492 | mov edx, 33 |
||
493 | jmp .done |
||
494 | .LN16: |
||
495 | mov edx, 34 |
||
496 | jmp .done |
||
497 | .LN23: |
||
498 | mov edx, 31 |
||
499 | jmp .done |
||
500 | .LN25: |
||
501 | mov edx, 32 |
||
502 | jmp .done |
||
503 | .LN32: |
||
504 | mov edx, 29 |
||
505 | jmp .done |
||
506 | .LN34: |
||
507 | mov edx, 30 |
||
508 | jmp .done |
||
509 | .LN41: |
||
510 | mov edx, 27 |
||
511 | jmp .done |
||
512 | .LN43: |
||
513 | mov edx, 28 |
||
514 | jmp .done |
||
515 | .LN50: |
||
516 | mov edx, 25 |
||
517 | jmp .done |
||
518 | .LN52: |
||
519 | mov edx, 26 |
||
520 | .done: |
||
521 | xor ecx, ecx |
||
522 | cmp word [eax+34], 16 |
||
523 | setne cl |
||
524 | dec ecx |
||
525 | and ecx, -18 |
||
526 | add ecx, edx |
||
527 | mov eax, ecx |
||
528 | ret |
||
529 | endp |
||
530 | |||
531 | |||
532 | WaveOut: ;str:dword, src:dword, size:dword |
||
533 | push ebx |
||
534 | push ecx |
||
535 | |||
536 | |||
537 | lea ebx, [esp+12] ;[stream] |
||
538 | |||
539 | |||
540 | push eax ;.output |
||
541 | push 12 ;.inp_size |
||
542 | push ebx ;.input |
||
543 | push SND_OUT ;.code |
||
544 | push dword [hSound] ;.handle |
||
545 | |||
546 | |||
547 | mov ebx, 17 |
||
548 | mov ecx, esp |
||
549 | int 0x40 |
||
550 | add esp, 24 |
||
551 | pop ecx |
||
552 | pop ebx |
||
553 | ret 12 |
||
554 | |||
555 | |||
556 | hSound dd ? |
||
557 | hrdwSound dd ? |
||
558 | |||
559 | |||
560 | szSound db 'SOUND',0 |
||
561 | |||
562 | |||
563 | od: |
||
564 | .mode dd 0 |
||
565 | .procinfo dd 0 |
||
566 | .com_area_name dd sz_com_area_name |
||
567 | .com_area dd 0 |
||
568 | .opendir_path dd 0 |
||
569 | .dir_default_path dd sz_dir_default_path |
||
570 | .start_path dd sz_start_path |
||
571 | .draw_window dd fake_on_redraw |
||
572 | .status dd 0 |
||
573 | .openfile_path dd 0 |
||
574 | .filename_area dd 0 |
||
575 | .filter_area dd filefilter |
||
576 | .x_size dw 512 |
||
577 | .x_start dw 512 |
||
578 | .y_size dw 512 |
||
579 | .y_start dw 512 |
||
580 | |||
581 | |||
582 | dd filefilter.end - filefilter |
||
583 | db 'mp3',0 |
||
584 | ; db 'flv',0 |
||
585 | ; db 'mov',0 |
||
586 | ; db 'mpg',0 |
||
587 | ; db 'mpeg',0 |
||
588 | ; db 'mkv',0 |
||
589 | ; db 'mp4',0 |
||
590 | ; db 'webm',0 |
||
591 | ; db 'wmv',0 |
||
592 | .end: |
||
593 | db 0 |
||
594 | |||
595 | |||
596 | |||
597 | |||
598 | |||
599 | sz_OpenDialog_init db "OpenDialog_init",0 |
||
600 | sz_OpenDialog_start db "OpenDialog_start",0 |
||
601 | sz_com_area_name db "FFFFFFFF_open_dialog",0 |
||
602 | sz_dir_default_path db "/rd/1",0 |
||
603 | sz_start_path db "/rd/1/File managers/opendial",0 |
||
604 | |||
605 | |||
606 | msg_init_fail db 'Cannot initialize mpg123 library: %s', 0x0D,0x0A,0 |
||
607 | msg_trouble db 'Trouble with mpg123: %s', 0x0D,0x0A,0 |
||
608 | msg_sound db 'Sound service not installed', 0x0D,0x0A,0 |
||
609 | msg_buffer db 'Unable to create a sound buffer',0x0D,0x0A,0 |
||
610 | |||
611 | |||
612 | __idata_start: |
||
613 | |||
614 | |||
615 | libmpg123, 'libmpg123.dll' |
||
616 | |||
617 | |||
618 | include 'include/libmpg123.inc' |
||
619 | |||
620 | |||
621 | __iend: |
||
622 | |||
623 | |||
624 | whdr: |
||
625 | .riff_id rd 1 |
||
626 | .riff_size rd 1 |
||
627 | .riff_format rd 1 |
||
628 | |||
629 | |||
630 | .fmt_size rd 1 |
||
631 | |||
632 | |||
633 | .nChannels rw 1 |
||
634 | .nSamplesPerSec rd 1 |
||
635 | .nAvgBytesPerSec rd 1 |
||
636 | .nBlockAlign rw 1 |
||
637 | .wBitsPerSample rw 1 |
||
638 | .data_id rd 1 |
||
639 | .data_size rd 1 |
||
640 | |||
641 | |||
642 | opendialog_init rd 1 |
||
643 | opendialog_start rd 1 |
||
644 | |||
645 | |||
646 | |||
647 | |||
648 | encoding rd 1 |
||
649 | channels rd 1 |
||
650 | rate rd 1 |
||
651 | |||
652 | |||
653 | count rd 1 |
||
654 | |||
655 | |||
656 | |||
657 | |||
658 | |||
659 | |||
660 | |||
661 | __pgmname: rb 1024 |
||
662 | rb 16 |
||
663 | __stack: |
||
664 | __bssend: |
||
665 |