Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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