Subversion Repositories Kolibri OS

Rev

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

  1. format MS COFF
  2.  
  3. include "snd.inc"
  4. include "proc32.inc"
  5.  
  6. section '.text' align 16 code readable executable
  7.  
  8.  
  9. public _InitSound@0
  10. public _CreateBuffer@8
  11. public _DestroyBuffer@4
  12. public _SetBuffer@16
  13. public _WaveOut@12
  14. public _PlayBuffer@4
  15. public _StopBuffer@4
  16.  
  17. public _GetMasterVol@4
  18. public _SetMasterVol@4
  19.  
  20. align 4
  21. proc _InitSound@0
  22.            locals
  23.              handle     dd ?
  24.              io_code    dd ?
  25.              input      dd ?
  26.              inp_size   dd ?
  27.              output     dd ?
  28.              out_size   dd ?
  29.            endl
  30.  
  31.            push ebx
  32.            push ecx
  33.            mov eax, 68
  34.            mov ebx, 16
  35.            mov ecx, szInfinity
  36.            int 0x40
  37.            test eax, eax
  38.            jz .fail
  39.            
  40.            mov [hSound], eax
  41.            mov eax, 68
  42.            mov ebx, 16
  43.            mov ecx, szSound
  44.            int 0x40
  45.            mov [hrdwSound], eax
  46.            
  47.            mov eax, [hSound]
  48.            xor ebx, ebx
  49.  
  50.            mov [handle], eax
  51.            mov [io_code], SRV_GETVERSION
  52.            mov [input], ebx
  53.            mov [inp_size], ebx
  54.            mov [output], ebx
  55.            mov [out_size], ebx
  56.            
  57.            mov eax, 68
  58.            mov ebx, 17
  59.            lea ecx, [handle]
  60.            int 0x40
  61. .fail:          
  62.            pop ecx  
  63.            pop ebx
  64.            ret
  65. endp
  66.  
  67.  
  68. align 4
  69. proc _CreateBuffer@8 stdcall, format:dword, size:dword
  70.            locals
  71.              handle     dd ?
  72.              io_code    dd ?
  73.              input      dd ?
  74.              inp_size   dd ?
  75.              output     dd ?
  76.              out_size   dd ?
  77.            endl
  78.  
  79.            push ebx
  80.            push ecx
  81.            mov eax, [hSound]
  82.            lea ebx, [format]
  83.            xor ecx, ecx
  84.  
  85.            mov [handle], eax
  86.            mov [io_code], SND_CREATE_BUFF
  87.            mov [input], ebx
  88.            mov [inp_size], 4
  89.            mov [output], ecx
  90.            mov [out_size], ecx
  91.            
  92.            mov eax, 68
  93.            mov ebx, 17
  94.            lea ecx, [handle]
  95.            int 0x40
  96.            pop ecx
  97.            pop ebx
  98.            ret
  99. endp
  100.  
  101. align 4
  102. proc _DestroyBuffer@4 stdcall, str:dword
  103.            locals
  104.              handle     dd ?
  105.              io_code    dd ?
  106.              input      dd ?
  107.              inp_size   dd ?
  108.              output     dd ?
  109.              out_size   dd ?
  110.            endl
  111.  
  112.            push ebx
  113.            push ecx
  114.            
  115.            mov eax, [hSound]
  116.            lea ebx, [str]
  117.            xor ecx, ecx
  118.  
  119.            mov [handle], eax
  120.            mov [io_code], SND_DESTROY_BUFF
  121.            mov [input], ebx
  122.            mov [inp_size], 4
  123.            mov [output], ecx
  124.            mov [out_size], ecx
  125.  
  126.            mov eax, 68
  127.            mov ebx, 17
  128.            lea ecx, [handle]
  129.            int 0x40
  130.            pop ecx
  131.            pop ebx
  132.            ret
  133. endp
  134.  
  135.  
  136. align 4
  137. proc _SetBuffer@16 stdcall,str:dword, src:dword, offs:dword, size:dword
  138.            locals
  139.              handle     dd ?
  140.              io_code    dd ?
  141.              input      dd ?
  142.              inp_size   dd ?
  143.              output     dd ?
  144.              out_size   dd ?
  145.            endl
  146.  
  147.            push ebx
  148.            push ecx
  149.            mov eax, [hSound]
  150.            lea ebx, [str]
  151.            xor ecx, ecx
  152.  
  153.            mov [handle], eax
  154.            mov [io_code], SND_SETBUFF
  155.            mov [input], ebx
  156.            mov [inp_size], 16
  157.            mov [output], ecx
  158.            mov [out_size], ecx
  159.  
  160.            mov eax, 68
  161.            mov ebx, 17
  162.            lea ecx, [handle]
  163.            int 0x40
  164.            pop ecx
  165.            pop ebx
  166.            ret
  167. endp
  168.  
  169. align 4
  170. proc _WaveOut@12 stdcall,str:dword, src:dword, size:dword
  171.            locals
  172.              handle     dd ?
  173.              io_code    dd ?
  174.              input      dd ?
  175.              inp_size   dd ?
  176.              output     dd ?
  177.              out_size   dd ?
  178.            endl
  179.  
  180.            push ebx
  181.            push ecx
  182.            mov eax, [hSound]
  183.            lea ebx, [str]
  184.            xor ecx, ecx
  185.  
  186.            mov [handle], eax
  187.            mov [io_code], SND_OUT
  188.            mov [input], ebx
  189.            mov [inp_size], 12
  190.            mov [output], ecx
  191.            mov [out_size], ecx
  192.  
  193.            mov eax, 68
  194.            mov ebx, 17
  195.            lea ecx, [handle]
  196.            int 0x40
  197.            pop ecx
  198.            pop ebx
  199.            ret
  200. endp
  201.  
  202. align 4
  203. proc _PlayBuffer@4 stdcall, str:dword
  204.            locals
  205.              handle     dd ?
  206.              io_code    dd ?
  207.              input      dd ?
  208.              inp_size   dd ?
  209.              output     dd ?
  210.              out_size   dd ?
  211.            endl
  212.  
  213.            push ebx
  214.            push ecx
  215.            mov eax, [hSound]
  216.            lea ebx, [str]
  217.            xor ecx, ecx
  218.  
  219.            mov [handle], eax
  220.            mov [io_code], SND_PLAY
  221.            mov [input], ebx
  222.            mov [inp_size], 4
  223.            mov [output], ecx
  224.            mov [out_size], ecx
  225.  
  226.            mov eax, 68
  227.            mov ebx, 17
  228.            lea ecx, [handle]
  229.            int 0x40
  230.            pop ecx
  231.            pop ebx
  232.            ret
  233. endp
  234.  
  235. align 4
  236. proc _StopBuffer@4 stdcall, str:dword
  237.            locals
  238.              handle     dd ?
  239.              io_code    dd ?
  240.              input      dd ?
  241.              inp_size   dd ?
  242.              output     dd ?
  243.              out_size   dd ?
  244.            endl
  245.  
  246.            push ebx
  247.            push ecx
  248.            mov eax, [hSound]
  249.            lea ebx, [str]
  250.            xor ecx, ecx
  251.  
  252.            mov [handle], eax
  253.            mov [io_code], SND_STOP
  254.            mov [input], ebx
  255.            mov [inp_size], 4
  256.            mov [output], ecx
  257.            mov [out_size], ecx
  258.  
  259.            mov eax, 68
  260.            mov ebx, 17
  261.            lea ecx, [handle]
  262.            int 0x40
  263.            pop ecx
  264.            pop ebx
  265.            ret
  266. endp
  267.  
  268. align 4
  269. proc _GetMasterVol@4 stdcall, pvol:dword
  270.            locals
  271.              handle     dd ?
  272.              io_code    dd ?
  273.              input      dd ?
  274.              inp_size   dd ?
  275.              output     dd ?
  276.              out_size   dd ?
  277.            endl
  278.            
  279.            push ebx
  280.            push ecx
  281.            mov eax, [hrdwSound]
  282.            mov ecx, [pvol]
  283.            xor ebx, ebx
  284.            mov [handle], eax
  285.            mov [io_code], DEV_GET_MASTERVOL
  286.            mov [input], ebx
  287.            mov [inp_size], ebx
  288.            mov [output], ecx
  289.            mov [out_size], 4
  290.  
  291.            mov eax, 68
  292.            mov ebx, 17
  293.            lea ecx, [handle]
  294.            int 0x40
  295.            pop ecx
  296.            pop ebx
  297.            ret
  298. endp
  299.  
  300. align 4
  301. proc _SetMasterVol@4 stdcall,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.            push ecx
  313.            mov eax, [hrdwSound]
  314.            lea ebx, [vol]
  315.            xor ecx, ecx
  316.  
  317.            mov [handle], eax
  318.            mov [io_code], DEV_SET_MASTERVOL
  319.            mov [input], ebx
  320.            mov [inp_size], 4
  321.            mov [output], ecx
  322.            mov [out_size], ecx
  323.  
  324.            mov eax, 68
  325.            mov ebx, 17
  326.            lea ecx, [handle]
  327.            int 0x40
  328.            pop ecx
  329.            pop ebx
  330.            ret
  331. endp
  332.  
  333. if 0
  334. align 4
  335. proc _GetDevInfo@8 stdcall, hSrv:dword, p_info:dword
  336.            locals
  337.              handle     dd ?
  338.              io_code    dd ?
  339.              input      dd ?
  340.              inp_size   dd ?
  341.              output     dd ?
  342.              out_size   dd ?
  343.            endl
  344.            
  345.            push ebx
  346.            mov eax, [hSrv]
  347.            xor ebx, ebx
  348.            mov ecx, [p_info]
  349.  
  350.            mov [handle], eax
  351.            mov [io_code], DEV_GET_INFO
  352.            mov [input], ebx
  353.            mov [inp_size], ebx
  354.            mov [output], ecx
  355.            mov [out_size], CTRL_INFO_SIZE
  356.  
  357.            lea eax, [handle]
  358.            stdcall CallServiceEx, eax
  359.            pop ebx
  360.                ret
  361. endp
  362.  
  363. end if
  364.  
  365. section '.data' align 16 data readable writable
  366.  
  367. szInfinity  db 'INFINITY',0
  368. szSound     db 'SOUND',0
  369.  
  370. align 4
  371. hSound      dd ?
  372. hrdwSound   dd ?