Subversion Repositories Kolibri OS

Rev

Rev 205 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
165 serge 1
format MS COFF
2
 
3
include "proc32.inc"
4
 
5
section '.text' code readable executable
6
 
7
public _GetService@4
8
public _GetDevInfo@8
9
public _GetMasterVol@8
10
public _SetMasterVol@8
11
public _CreateBuffer@8
12
public _DestroyBuffer@8
13
public _SetBuffer@20
14
public _PlayBuffer@8
15
public _StopBuffer@8
16
 
17
public _InitHeap@4
18
public _UserAlloc@4
19
public _GetNotify@4
20
public _CreateThread@8
21
public _GetMousePos@4
22
public _get_fileinfo@8
23
public _read_file@20
24
public _get_key
25
public _get_button_id
26
public _DrawWindow@36
27
public _make_button@24
28
public _draw_bar@20
29
public _write_text@20
30
public _debug_out@4
31
public _debug_out_hex@4
32
 
33
public _memset
34
 
35
struc FILEIO
36
{   .cmd            dd ?
37
    .offset         dd ?
38
                    dd ?
39
    .count          dd ?
40
    .buff           dd ?
41
                    db ?
42
    .name           dd ?
43
};
44
 
45
struc CTRL_INFO
46
{   .pci_cmd        dd  ?
47
    .irq            dd  ?
48
    .glob_cntrl     dd  ?
49
    .glob_sta       dd  ?
228 serge 50
    .codec_io_base  dd  ?
51
    .ctrl_io_base   dd  ?
52
    .codec_mem_base dd  ?
53
    .ctrl_mem_base  dd  ?
165 serge 54
    .codec_id       dd  ?
55
}
56
CTRL_INFO_SIZE      equ 9*4
57
 
58
 
228 serge 59
SND_CREATE_DEV     equ  1
60
SND_CREATE_BUFF    equ  2
61
SND_PLAY           equ  3
62
SND_STOP           equ  4
63
SND_SETBUFF        equ  5
165 serge 64
SND_DESTROY_BUFF   equ  6
65
 
228 serge 66
DEV_SET_BUFF       equ  4
67
DEV_NOTIFY         equ  5
68
DEV_SET_MASTERVOL  equ  6
69
DEV_GET_MASTERVOL  equ  7
70
DEV_GET_INFO       equ  8
165 serge 71
 
72
 
73
align 4
74
proc _get_button_id
75
           mov   eax,17
76
           int   0x40
77
           test  al,al
78
           jnz   @F
79
           shr   eax,8
80
           ret
81
@@:
82
           xor   eax,eax
83
           dec   eax
84
           ret
85
endp
86
 
87
align 4
88
proc _get_fileinfo@8 stdcall, name:dword, info:dword
89
           push ebx
90
           push esi
91
           push edi
92
           xor eax, eax
93
           mov ebx, [name]
94
           mov ecx, [info]
95
 
96
           mov [fileio.cmd], 5
97
           mov [fileio.offset], eax
98
           mov [fileio.offset+4], eax
99
           mov [fileio.count], eax
100
           mov [fileio.buff], ecx
101
           mov byte [fileio.buff+4], al
102
           mov [fileio.name], ebx
103
 
104
           mov eax, 70
105
           lea ebx, [fileio]
106
           int 0x40
107
           pop edi
108
           pop esi
109
           pop ebx
110
           ret
111
endp
112
 
113
align 4
114
proc _read_file@20 stdcall,name:dword, buff:dword, offset:dword,\
115
                                     count:dword,reads:dword
116
           push ebx
117
           push esi
118
           push edi
119
           xor eax, eax
120
           mov ebx, [name]
121
           mov edx, [offset]
122
           mov esi, [buff]
123
           mov edi, [count]
124
 
125
           mov [fileio.cmd], eax
126
           mov [fileio.offset], edx
127
           mov [fileio.offset+4], eax
128
           mov [fileio.count], edi
129
           mov [fileio.buff], esi
130
           mov byte [fileio.buff+4], al
131
           mov [fileio.name], ebx
132
 
133
           mov eax, 70
134
           lea ebx, [fileio]
135
           int 0x40
136
           mov esi, [reads]
137
           test esi, esi
138
           jz @f
139
           mov [esi], ebx
140
@@:
141
           pop edi
142
           pop esi
143
           pop ebx
144
           ret
145
endp
146
 
147
align 4
148
proc _get_key
149
           mov eax, 2
150
           int 0x40
151
           shr eax, 8
152
           ret
153
endp
154
 
155
align 4
156
proc _InitHeap@4 stdcall, heap_size:dword
228 serge 157
                  push ebx
158
                  mov eax, 68
159
                  mov ebx, 11
165 serge 160
              mov ecx, [heap_size]
228 serge 161
                  int 0x40
162
                  pop ebx
163
                  ret
165 serge 164
endp
165
 
166
align 4
167
proc _UserAlloc@4 stdcall, alloc_size:dword
228 serge 168
                  push ebx
169
                  mov eax, 68
170
                  mov ebx, 12
165 serge 171
              mov ecx, [alloc_size]
228 serge 172
                  int 0x40
173
                  pop ebx
174
                  ret
165 serge 175
endp
176
 
228 serge 177
;align 4
178
;proc _GetNotify@4 stdcall, p_ev:dword
179
;                  push ebx
180
;                  mov eax, 68
181
;                  mov ebx, 14
182
;              mov ecx, [p_ev]
183
;                  int 0x40
184
;                  pop ebx
185
;                  ret
186
;endp
187
 
165 serge 188
align 4
189
proc _GetNotify@4 stdcall, p_ev:dword
228 serge 190
                  push ebx
191
                  mov eax, 68
192
                  mov ebx, 14
193
                  mov ecx, [p_ev]
194
                  int 0x40
195
                  pop ebx
196
                  ret
165 serge 197
endp
198
 
199
align 4
200
proc _CreateThread@8 stdcall, fn:dword, p_stack:dword
201
              push ebx
202
              mov eax, 51
203
              mov ebx, 1
204
              mov ecx, [fn]
205
              mov edx,[p_stack]
228 serge 206
                  int 0x40
207
                  pop ebx
208
                  ret
165 serge 209
endp
210
 
211
align 4
212
proc _GetMousePos@4 stdcall,rel_type:dword
213
           push ebx
214
           mov eax, 37
215
           mov ebx, [rel_type]
228 serge 216
               int 0x40
217
               pop ebx
218
               ret
165 serge 219
endp
220
 
221
align 4
222
proc CallServiceEx stdcall, ioctl:dword
228 serge 223
              push ebx
224
              mov eax, 68
225
              mov ebx, 17
165 serge 226
          mov ecx, [ioctl]
228 serge 227
              int 0x40
228
              pop ebx
229
              ret
165 serge 230
endp
231
 
232
align 4
233
proc _GetService@4 stdcall, name:dword
234
           push ebx
235
           mov eax, 68
228 serge 236
               mov ebx, 16
165 serge 237
           mov ecx, [name]
228 serge 238
               int 0x40
239
               pop ebx
240
               ret
165 serge 241
endp
242
 
243
align 4
244
proc _GetDevInfo@8 stdcall, hSrv:dword, p_info:dword
245
           locals
246
             handle     dd ?
247
             io_code    dd ?
248
             input      dd ?
249
             inp_size   dd ?
250
             output     dd ?
251
             out_size   dd ?
252
           endl
253
 
254
           push ebx
255
           mov eax, [hSrv]
256
           xor ebx, ebx
257
           mov ecx, [p_info]
258
 
259
           mov [handle], eax
260
           mov [io_code], DEV_GET_INFO
261
           mov [input], ebx
262
           mov [inp_size], ebx
263
           mov [output], ecx
264
           mov [out_size], CTRL_INFO_SIZE
265
 
266
           lea eax, [handle]
267
           stdcall CallServiceEx, eax
268
           pop ebx
228 serge 269
               ret
165 serge 270
endp
271
 
272
align 4
273
proc _GetMasterVol@8 stdcall, hSrv:dword,pvol:dword
274
           locals
275
             handle     dd ?
276
             io_code    dd ?
277
             input      dd ?
278
             inp_size   dd ?
279
             output     dd ?
280
             out_size   dd ?
281
           endl
282
 
283
           push ebx
284
           mov eax, [hSrv]
285
           mov ecx, [pvol]
286
           xor ebx, ebx
287
           mov [handle], eax
288
           mov [io_code], DEV_GET_MASTERVOL
289
           mov [input], ebx
290
           mov [inp_size], ebx
291
           mov [output], ecx
292
           mov [out_size], 4
293
 
294
           lea eax, [handle]
295
           stdcall CallServiceEx, eax
296
           pop ebx
228 serge 297
               ret
165 serge 298
endp
299
 
300
align 4
301
proc _SetMasterVol@8 stdcall,hSrv:dword,vol:dword
302
           locals
303
             handle     dd ?
304
             io_code    dd ?
305
             input      dd ?
306
             inp_size   dd ?
307
             output     dd ?
308
             out_size   dd ?
309
           endl
310
 
311
           push ebx
312
           mov eax, [hSrv]
313
           lea ecx, [vol]
314
           xor ebx, ebx
315
 
316
           mov [handle], eax
317
           mov [io_code], DEV_SET_MASTERVOL
318
           mov [input], ecx
319
           mov [inp_size], 4
320
           mov [output], ebx
321
           mov [out_size], 0
322
 
323
           lea eax, [handle]
324
           stdcall CallServiceEx, eax
325
           pop ebx
228 serge 326
               ret
165 serge 327
endp
328
 
329
align 4
330
proc _CreateBuffer@8 stdcall, hSound:dword,format:dword
331
           locals
332
             handle     dd ?
333
             io_code    dd ?
334
             input      dd ?
335
             inp_size   dd ?
336
             output     dd ?
337
             out_size   dd ?
338
           endl
339
 
340
           push ebx
341
           mov eax, [hSound]
342
           lea ecx, [format]
343
           xor ebx, ebx
344
 
345
           mov [handle], eax
346
           mov [io_code], SND_CREATE_BUFF
347
           mov [input], ecx
348
           mov [inp_size], 4
349
           mov [output], ebx
350
           mov [out_size], 0
351
 
352
           lea eax, [handle]
353
           stdcall CallServiceEx, eax
354
           pop ebx
228 serge 355
               ret
165 serge 356
endp
357
 
358
align 4
359
proc _DestroyBuffer@8 stdcall, hSound:dword, str:dword
360
           locals
361
             handle     dd ?
362
             io_code    dd ?
363
             input      dd ?
364
             inp_size   dd ?
365
             output     dd ?
366
             out_size   dd ?
367
           endl
368
 
369
           push ebx
370
           mov eax, [hSound]
371
           lea ecx, [str]
372
           xor ebx, ebx
373
 
374
           mov [handle], eax
375
           mov [io_code], SND_DESTROY_BUFF
376
           mov [input], ecx
377
           mov [inp_size], 4
378
           mov [output], ebx
379
           mov [out_size], 0
380
 
381
           lea eax, [handle]
382
           stdcall CallServiceEx, eax
383
           pop ebx
228 serge 384
               ret
165 serge 385
endp
386
 
387
align 4
388
proc _SetBuffer@20 stdcall,hSound:dword, str:dword, src:dword, offs:dword, size:dword
389
           locals
390
             handle     dd ?
391
             io_code    dd ?
392
             input      dd ?
393
             inp_size   dd ?
394
             output     dd ?
395
             out_size   dd ?
396
           endl
397
 
398
           push ebx
399
           mov eax, [hSound]
400
           lea ecx, [str]
401
           xor ebx, ebx
402
 
403
           mov [handle], eax
404
           mov [io_code], SND_SETBUFF
405
           mov [input], ecx
406
           mov [inp_size], 16
407
           mov [output], ebx
408
           mov [out_size], 0
409
 
410
           lea eax, [handle]
411
           stdcall CallServiceEx, eax
412
           pop ebx
228 serge 413
               ret
165 serge 414
endp
415
 
416
align 4
417
proc _PlayBuffer@8 stdcall, hSound:dword, str:dword
418
           locals
419
             handle     dd ?
420
             io_code    dd ?
421
             input      dd ?
422
             inp_size   dd ?
423
             output     dd ?
424
             out_size   dd ?
425
           endl
426
 
427
           push ebx
428
           mov eax, [hSound]
429
           lea ecx, [str]
430
           xor ebx, ebx
431
 
432
           mov [handle], eax
433
           mov [io_code], SND_PLAY
434
           mov [input], ecx
435
           mov [inp_size], 4
436
           mov [output], ebx
437
           mov [out_size], 0
438
 
439
           lea eax, [handle]
440
           stdcall CallServiceEx, eax
441
           pop ebx
228 serge 442
               ret
165 serge 443
endp
444
 
445
align 4
446
proc _StopBuffer@8 stdcall, hSound:dword, str:dword
447
           locals
448
             handle     dd ?
449
             io_code    dd ?
450
             input      dd ?
451
             inp_size   dd ?
452
             output     dd ?
453
             out_size   dd ?
454
           endl
455
 
456
           push ebx
457
           mov eax, [hSound]
458
           lea ecx, [str]
459
           xor ebx, ebx
460
 
461
           mov [handle], eax
462
           mov [io_code], SND_STOP
463
           mov [input], ecx
464
           mov [inp_size], 4
465
           mov [output], ebx
466
           mov [out_size], 0
467
 
468
           lea eax, [handle]
469
           stdcall CallServiceEx, eax
470
           pop ebx
471
           ret
472
endp
473
 
474
align 4
475
proc _DrawWindow@36 stdcall, x:dword, y:dword, sx:dword, sy:dword,\
476
                               workcolor:dword, style:dword, captioncolor:dword,\
477
                               windowtype:dword, bordercolor:dword
478
           push ebx edi esi
479
           mov ebx, [x]
480
           mov ecx, [y]
481
           shl ebx, 16
482
           shl ecx, 16
483
           mov bx, word [sx]
484
           mov cx,  word [sy]
485
           mov  edx,[style]
486
           shl  edx,24
487
           add  edx,[workcolor]
488
           mov  esi,[windowtype]
489
           shl  esi,24
490
           add  esi,[captioncolor]
491
           mov  edi,[bordercolor]
492
           xor  eax,eax
493
           int  0x40
494
           pop esi edi ebx
495
           ret
496
endp
497
 
498
align 4
499
_make_button@24:
500
;arg1 - x
501
;arg2 - y
502
;arg3 - xsize
503
;arg4 - ysize
504
;arg5 - id
505
;arg6 - color
506
 
507
  push  ebx esi
508
  mov   ebx,[esp+12]
509
  shl   ebx,16
510
  mov   bx,[esp+20]
511
  mov   ecx,[esp+16]
512
  shl   ecx,16
513
  mov   cx,[esp+24]
514
  mov   edx,[esp+28]
515
  mov   esi,[esp+32]
516
  mov   eax,8
517
  int   0x40
518
  pop   esi ebx
519
  ret   24
520
 
521
align 4
522
_draw_bar@20:
523
;arg1 - x
524
;arg2 - y
525
;arg3 - xsize
526
;arg4 - ysize
527
;arg5 - color
528
  push  ebx
529
  mov   eax,13
530
  mov   ebx,[esp+8]
531
  shl   ebx,16
532
  mov   bx,[esp+16]
533
  mov   ecx,[esp+12]
534
  shl   ecx,16
535
  mov   cx,[esp+20]
536
  mov   edx,[esp+24]
537
  int   0x40
538
  pop   ebx
539
  ret   20
540
 
541
_write_text@20:
542
;arg1 - x
543
;arg2 - y
544
;arg3 - color
545
;arg4 - text
546
;arg5 - len
547
  push  ebx esi
548
  mov   eax,4
549
  mov   ebx,[esp+12]
550
  shl   ebx,16
551
  mov   bx,[esp+16]
552
  mov   ecx,[esp+20]
553
  mov   edx,[esp+24]
554
  mov   esi,[esp+28]
555
  int   0x40
556
  pop   esi ebx
557
  ret   20
558
 
559
align 4
560
proc _debug_out@4 stdcall, val:dword
561
           push ebx
228 serge 562
           mov  ecx,[val]
563
           mov  ebx,1
564
           mov  eax,63
565
           int  0x40
165 serge 566
           pop ebx
567
           ret
568
endp
569
 
570
align 4
571
proc _debug_out_hex@4 stdcall val:dword
572
           locals
573
             count dd ?
574
           endl
575
 
576
           mov [count], 8
577
.new_char:
578
           rol [val], 4
579
           mov ecx, [val]
580
           and ecx, 0x0f
581
           mov cl,byte [__hexdigits+ecx]
582
           mov eax, 63
583
           mov ebx, 1
584
           int 0x40
585
           dec [count]
586
           jnz .new_char
587
           ret
588
endp
589
 
590
align 4
591
_memset:
592
           mov     edx,[esp + 0ch]
593
           mov     ecx,[esp + 4]
594
 
595
           test    edx,edx
596
           jz      short toend
597
 
598
           xor     eax,eax
599
           mov     al,[esp + 8]
600
 
601
           push    edi
602
           mov     edi,ecx
603
 
604
           cmp     edx,4
605
           jb      tail
606
 
607
           neg     ecx
608
           and     ecx,3
609
           jz      short dwords
610
 
611
           sub     edx,ecx
612
adjust_loop:
613
           mov     [edi],al
614
           add     edi,1
615
           sub     ecx,1
616
           jnz     adjust_loop
617
 
618
dwords:
619
        mov     ecx,eax
620
        shl     eax,8
621
        add     eax,ecx
622
        mov     ecx,eax
623
        shl     eax,10h
624
        add     eax,ecx
625
 
626
        mov     ecx,edx
627
        and     edx,3
628
        shr     ecx,2
629
        jz      tail
630
 
228 serge 631
                cld
165 serge 632
        rep     stosd
633
main_loop_tail:
634
        test    edx,edx
635
        jz      finish
636
 
637
 
638
tail:
639
        mov     [edi],al
640
        add     edi,1
641
 
642
        sub     edx,1
643
        jnz     tail
644
 
645
finish:
646
        mov     eax,[esp + 8]
647
        pop     edi
648
 
649
        ret
650
 
651
toend:
652
        mov     eax,[esp + 4]
653
 
654
        ret
655
 
228 serge 656
public _allmul
657
 
658
_allmul:
659
        mov eax, [esp+8]
660
        mov ecx, [esp+16]
661
        or ecx,eax
662
        mov ecx, [esp+12]
663
        jnz .hard
664
        mov eax, [esp+4]
665
        mul ecx
666
        ret 16
667
.hard:
668
        push ebx
669
        mul ecx
670
        mov ebx,eax
671
        mov eax, [esp+8]
672
        mul dword [esp+20]
673
        add ebx,eax
674
        mov eax,[esp+8]
675
        mul ecx
676
        add edx,ebx
677
        pop ebx
678
        ret 16
679
 
680
align 4
681
_allshr:
682
        cmp cl,64
683
        jae .sign
684
 
685
        cmp cl, 32
686
        jae .MORE32
687
        shrd eax,edx,cl
688
        sar edx,cl
689
        ret
690
.MORE32:
691
        mov     eax,edx
692
        sar     edx,31
693
        and     cl,31
694
        sar     eax,cl
695
        ret
696
.sign:
697
        sar     edx,31
698
        mov     eax,edx
699
        ret
700
 
165 serge 701
public __ftol2_sse
702
 
703
align 4
704
__ftol2_sse:
705
           push ebp
706
           mov ebp, esp
707
           sub esp, 20
708
           and esp, 0xFFFFFFF0
709
           fld st0
710
           fst dword [esp+18]
711
           fistp qword [esp+10]
712
           fild qword [esp+10]
713
           mov edx, [esp+18]
714
           mov eax, [esp+10]
715
           test eax, eax
716
           jz .QnaNZ
717
 
718
.not_QnaNZ:
719
           fsubp st1, st0
720
           test edx, edx
721
           jns .pos
722
           fstp dword [esp]
723
           mov ecx, [esp]
724
           xor ecx, 0x80000000
725
           add ecx, 0x7FFFFFFF
726
           adc eax, 0
727
           mov edx, [esp+14]
728
           adc edx, 0
729
           jmp .exit
730
.pos:
731
           fstp dword [esp]
732
           mov ecx, [esp]
733
           add ecx, 0x7FFFFFFF
734
           sbb eax, 0
735
           jmp .exit
736
.QnaNZ:
737
           mov edx, [esp+14]
738
           test edx, 0x7FFFFFFF
739
           jne .not_QnaNZ
740
           fstp dword [esp+18]
741
           fstp dword [esp+18]
742
.exit:
743
           leave
744
           ret
745
 
746
public __fltused
747
__fltused    dd 0
748
 
749
align 4
750
__hexdigits db '0123456789ABCDEF'
751
 
752
align 4
753
fileio FILEIO
754