Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 5021 → Rev 5022

/contrib/sdk/sources/sound/Makefile
0,0 → 1,21
 
AR = kos32-ar
FASM:= fasm.exe
 
TARGET:= libsound
 
dirs := ./src
 
target_srcs:= $(foreach dir,$(dirs),$(wildcard $(dir)/*.asm))
 
target_objs:= $(subst .asm,.o,$(target_srcs))
 
 
all: $(TARGET).a
 
%.o: %.asm
$(FASM) $< $@
 
$(TARGET).a: $(target_objs) Makefile
$(AR) cvrs $@ $(target_objs)
mv -f $@ ../../lib
/contrib/sdk/sources/sound/include/snd.inc
0,0 → 1,42
 
struc CTRL_INFO
{ .pci_cmd dd ?
.irq dd ?
.glob_cntrl dd ?
.glob_sta dd ?
.codec_io_base dd ?
.ctrl_io_base dd ?
.codec_mem_base dd ?
.ctrl_mem_base dd ?
.codec_id dd ?
}
CTRL_INFO_SIZE equ 9*4
 
SRV_GETVERSION equ 0
SND_CREATE_BUFF equ 1
SND_DESTROY_BUFF equ 2
SND_SETFORMAT equ 3
SND_GETFORMAT equ 4
SND_RESET equ 5
SND_SETPOS equ 6
SND_GETPOS equ 7
SND_SETBUFF equ 8
SND_OUT equ 9
SND_PLAY equ 10
SND_STOP equ 11
SND_SETVOLUME equ 12
SND_GETVOLUME equ 13
SND_SETPAN equ 14
SND_GETPAN equ 15
SND_GETBUFFSIZE equ 16
SND_GETFREESPACE equ 17
SND_SETTIMEBASE equ 18
SND_GETTIMESTAMP equ 19
 
 
DEV_SET_BUFF equ 4
DEV_NOTIFY equ 5
DEV_SET_MASTERVOL equ 6
DEV_GET_MASTERVOL equ 7
DEV_GET_INFO equ 8
 
/contrib/sdk/sources/sound/include/sound.h
0,0 → 1,142
 
#ifndef _SOUND_H_
#define _SOUND_H_
 
#ifdef __cplusplus
extern "C"
{
#endif
 
#define SOUND_VERSION 0x0101
#define PCM_ALL 0
 
#define PCM_OUT 0x08000000
#define PCM_RING 0x10000000
#define PCM_STATIC 0x20000000
#define PCM_FLOAT 0x40000000
#define PCM_FILTER 0x80000000
 
#define PCM_2_16_48 1
#define PCM_1_16_48 2
#define PCM_2_16_44 3
#define PCM_1_16_44 4
#define PCM_2_16_32 5
#define PCM_1_16_32 6
#define PCM_2_16_24 7
#define PCM_1_16_24 8
#define PCM_2_16_22 9
#define PCM_1_16_22 10
#define PCM_2_16_16 11
#define PCM_1_16_16 12
#define PCM_2_16_12 13
#define PCM_1_16_12 14
#define PCM_2_16_11 15
#define PCM_1_16_11 16
#define PCM_2_16_8 17
#define PCM_1_16_8 18
#define PCM_2_8_48 19
#define PCM_1_8_48 20
#define PCM_2_8_44 21
#define PCM_1_8_44 22
#define PCM_2_8_32 23
#define PCM_1_8_32 24
#define PCM_2_8_24 25
#define PCM_1_8_24 26
#define PCM_2_8_22 27
#define PCM_1_8_22 28
#define PCM_2_8_16 29
#define PCM_1_8_16 30
#define PCM_2_8_12 31
#define PCM_1_8_12 32
#define PCM_2_8_11 33
#define PCM_1_8_11 34
#define PCM_2_8_8 35
#define PCM_1_8_8 36
 
#define SRV_GETVERSION 0
#define SND_CREATE_BUFF 1
#define SND_DESTROY_BUFF 2
#define SND_SETFORMAT 3
#define SND_GETFORMAT 4
#define SND_RESET 5
#define SND_SETPOS 6
#define SND_GETPOS 7
#define SND_SETBUFF 8
#define SND_OUT 9
#define SND_PLAY 10
#define SND_STOP 11
#define SND_SETVOLUME 12
#define SND_GETVOLUME 13
#define SND_SETPAN 14
#define SND_GETPAN 15
#define SND_GETBUFFSIZE 16
#define SND_GETFREESPACE 17
#define SND_SETTIMEBASE 18
#define SND_GETTIMESTAMP 19
 
 
#define PLAY_SYNC 0x80000000
 
typedef unsigned int SNDBUF;
 
int _stdcall InitSound(int *version);
 
int _stdcall CreateBuffer(unsigned int format,int size,SNDBUF *buf);
int _stdcall DestroyBuffer(SNDBUF hBuff);
 
int _stdcall SetFormat(SNDBUF hBuff, unsigned int format);
int _stdcall GetFormat(SNDBUF hBuff, unsigned int *format);
 
int _stdcall ResetBuffer(SNDBUF hBuff, unsigned int flags);
int _stdcall SetBufferPos(SNDBUF hBuff, int offset);
int _stdcall GetBufferPos(SNDBUF hBuff, int *offset);
int _stdcall GetBufferSize(SNDBUF hBuff, int *size);
int _stdcall GetBufferFree(SNDBUF hBuff, int *free);
 
int _stdcall SetBuffer(SNDBUF hBuff,void* buff,
int offs, int size);
int _stdcall WaveOut(SNDBUF hBuff,void *buff, int size);
int _stdcall PlayBuffer(SNDBUF hBuff,unsigned int flags);
int _stdcall StopBuffer(SNDBUF hBuff);
 
int _stdcall SetVolume(SNDBUF hBuff, int left, int right);
int _stdcall GetVolume(SNDBUF hBuff, int *left, int *right);
int _stdcall SetPan(SNDBUF hBuff, int pan);
int _stdcall GetPan(SNDBUF hBuff, int *pan);
 
int _stdcall GetMasterVol(int* vol);
int _stdcall SetMasterVol(int vol);
 
int _stdcall SetTimeBase(SNDBUF hBuff, double base);
int _stdcall GetTimeStamp(SNDBUF hBuff, double *stamp);
int _stdcall GetDevTime(int *stamp);
 
 
typedef struct
{
unsigned int riff_id;
unsigned int riff_size;
unsigned int riff_format;
 
unsigned int fmt_id;
unsigned int fmt_size;
 
unsigned short int wFormatTag;
unsigned short int nChannels;
unsigned int nSamplesPerSec;
unsigned int nAvgBytesPerSec;
unsigned short int nBlockAlign;
unsigned short int wBitsPerSample;
unsigned int data_id;
unsigned int data_size;
} WAVEHEADER;
 
 
unsigned int _stdcall test_wav(WAVEHEADER *hdr);
 
#ifdef __cplusplus
extern "C"
}
#endif
 
#endif //_SOUND_H_
/contrib/sdk/sources/sound/src/init.asm
0,0 → 1,118
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
public _InitSound@4
public _CreateBuffer@12
public _DestroyBuffer@4
 
align 4
_InitSound@4: ;p_ver:dword
 
push ebx
push ecx
 
mov eax, 68
mov ebx, 16
mov ecx, szInfinity
int 0x40
mov [hSound], eax
test eax, eax
jz .fail
 
mov eax, 68
mov ebx, 16
mov ecx, szSound
int 0x40
mov [hrdwSound], eax
 
lea eax, [esp+12] ;p_ver
xor ebx, ebx
 
push 4 ;.out_size
push eax ;.output
push ebx ;.inp_size
push ebx ;.input
push SRV_GETVERSION ;.code
push [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp ;[handle]
int 0x40
add esp, 24
pop ecx
pop ebx
ret 4
.fail:
or eax, -1
pop ecx
pop ebx
ret 4
 
 
align 4
_CreateBuffer@12: ;format:dword,size:dword,p_str:dword
 
push ebx
push ecx
lea eax, [esp+20] ;p_str
lea ebx, [esp+12] ;format
 
push 4 ;.out_size
push eax ;.output
push 8 ;.inp_size
push ebx ;.input
push SND_CREATE_BUFF;.code
push [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24 ;io_cintrol
pop ecx
pop ebx
ret 12
 
align 4
_DestroyBuffer@4: ;str:dword
 
push ebx
push ecx
 
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 4 ;.inp_size
push ebx ;.input
push SND_DESTROY_BUFF;.code
push [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp ;[handle]
int 0x40
add esp, 24
pop ecx
pop ebx
ret 4
 
 
section '.data' align 16 data readable writable
 
public hSound
public hrdwSound
 
hSound dd ?
hrdwSound dd ?
 
szInfinity db 'INFINITY',0
szSound db 'SOUND',0
 
 
/contrib/sdk/sources/sound/src/proc32.inc
0,0 → 1,268
 
; Macroinstructions for defining and calling procedures
 
macro stdcall proc,[arg] ; directly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call proc }
 
macro invoke proc,[arg] ; indirectly call STDCALL procedure
{ common
if ~ arg eq
reverse
pushd arg
common
end if
call [proc] }
 
macro ccall proc,[arg] ; directly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call proc
if size@ccall
add esp,size@ccall
end if }
 
macro cinvoke proc,[arg] ; indirectly call CDECL procedure
{ common
size@ccall = 0
if ~ arg eq
reverse
pushd arg
size@ccall = size@ccall+4
common
end if
call [proc]
if size@ccall
add esp,size@ccall
end if }
 
macro proc [args] ; define procedure
{ common
match name params, args>
\{ define@proc name,<params \} }
 
prologue@proc equ prologuedef
 
macro prologuedef procname,flag,parmbytes,localbytes,reglist
{ if parmbytes | localbytes
push ebp
mov ebp,esp
if localbytes
sub esp,localbytes
end if
end if
irps reg, reglist \{ push reg \} }
 
epilogue@proc equ epiloguedef
 
macro epiloguedef procname,flag,parmbytes,localbytes,reglist
{ irps reg, reglist \{ reverse pop reg \}
if parmbytes | localbytes
leave
end if
if flag and 10000b
retn
else
retn parmbytes
end if }
 
macro define@proc name,statement
{ local params,flag,regs,parmbytes,localbytes,current
if used name
name:
match =stdcall args, statement \{ params equ args
flag = 11b \}
match =stdcall, statement \{ params equ
flag = 11b \}
match =c args, statement \{ params equ args
flag = 10001b \}
match =c, statement \{ params equ
flag = 10001b \}
match =params, params \{ params equ statement
flag = 0 \}
virtual at ebp+8
match =uses reglist=,args, params \{ regs equ reglist
params equ args \}
match =regs =uses reglist, regs params \{ regs equ reglist
params equ \}
match =regs, regs \{ regs equ \}
match =,args, params \{ defargs@proc args \}
match =args@proc args, args@proc params \{ defargs@proc args \}
parmbytes = $ - (ebp+8)
end virtual
name # % = parmbytes/4
all@vars equ
current = 0
match prologue:reglist, prologue@proc:<regs> \{ prologue name,flag,parmbytes,localbytes,reglist \}
macro locals
\{ virtual at ebp-localbytes+current
macro label . \\{ deflocal@proc .,:, \\}
struc db [val] \\{ \common deflocal@proc .,db,val \\}
struc dw [val] \\{ \common deflocal@proc .,dw,val \\}
struc dp [val] \\{ \common deflocal@proc .,dp,val \\}
struc dd [val] \\{ \common deflocal@proc .,dd,val \\}
struc dt [val] \\{ \common deflocal@proc .,dt,val \\}
struc dq [val] \\{ \common deflocal@proc .,dq,val \\}
struc rb cnt \\{ deflocal@proc .,rb cnt, \\}
struc rw cnt \\{ deflocal@proc .,rw cnt, \\}
struc rp cnt \\{ deflocal@proc .,rp cnt, \\}
struc rd cnt \\{ deflocal@proc .,rd cnt, \\}
struc rt cnt \\{ deflocal@proc .,rt cnt, \\}
struc rq cnt \\{ deflocal@proc .,rq cnt, \\} \}
macro endl
\{ purge label
restruc db,dw,dp,dd,dt,dq
restruc rb,rw,rp,rd,rt,rq
restruc byte,word,dword,pword,tword,qword
current = $-(ebp-localbytes)
end virtual \}
macro ret operand
\{ match any, operand \\{ retn operand \\}
match , operand \\{ match epilogue:reglist, epilogue@proc:<regs>
\\\{ epilogue name,flag,parmbytes,localbytes,reglist \\\} \\} \}
macro finish@proc \{ localbytes = (((current-1) shr 2)+1) shl 2
end if \} }
 
macro defargs@proc [arg]
{ common
if ~ arg eq
forward
local ..arg,current@arg
match argname:type, arg
\{ current@arg equ argname
label ..arg type
argname equ ..arg
if dqword eq type
dd ?,?,?,?
else if tbyte eq type
dd ?,?,?
else if qword eq type | pword eq type
dd ?,?
else
dd ?
end if \}
match =current@arg,current@arg
\{ current@arg equ arg
arg equ ..arg
..arg dd ? \}
common
args@proc equ current@arg
forward
restore current@arg
common
end if }
 
macro deflocal@proc name,def,[val]
{ common
match vars, all@vars \{ all@vars equ all@vars, \}
all@vars equ all@vars name
forward
local ..var,..tmp
..var def val
match =?, val \{ ..tmp equ \}
match any =dup (=?), val \{ ..tmp equ \}
match tmp : value, ..tmp : val
\{ tmp: end virtual
initlocal@proc ..var,def value
virtual at tmp\}
common
match first rest, ..var, \{ name equ first \} }
 
macro initlocal@proc name,def
{ virtual at name
def
size@initlocal = $ - name
end virtual
position@initlocal = 0
while size@initlocal > position@initlocal
virtual at name
def
if size@initlocal - position@initlocal < 2
current@initlocal = 1
load byte@initlocal byte from name+position@initlocal
else if size@initlocal - position@initlocal < 4
current@initlocal = 2
load word@initlocal word from name+position@initlocal
else
current@initlocal = 4
load dword@initlocal dword from name+position@initlocal
end if
end virtual
if current@initlocal = 1
mov byte [name+position@initlocal],byte@initlocal
else if current@initlocal = 2
mov word [name+position@initlocal],word@initlocal
else
mov dword [name+position@initlocal],dword@initlocal
end if
position@initlocal = position@initlocal + current@initlocal
end while }
 
macro endp
{ purge ret,locals,endl
finish@proc
purge finish@proc
restore regs@proc
match all,args@proc \{ restore all \}
restore args@proc
match all,all@vars \{ restore all \} }
 
macro local [var]
{ common
locals
forward done@local equ
match varname[count]:vartype, var
\{ match =BYTE, vartype \\{ varname rb count
restore done@local \\}
match =WORD, vartype \\{ varname rw count
restore done@local \\}
match =DWORD, vartype \\{ varname rd count
restore done@local \\}
match =PWORD, vartype \\{ varname rp count
restore done@local \\}
match =QWORD, vartype \\{ varname rq count
restore done@local \\}
match =TBYTE, vartype \\{ varname rt count
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
rq count+count
restore done@local \\}
match , done@local \\{ virtual
varname vartype
end virtual
rb count*sizeof.\#vartype
restore done@local \\} \}
match :varname:vartype, done@local:var
\{ match =BYTE, vartype \\{ varname db ?
restore done@local \\}
match =WORD, vartype \\{ varname dw ?
restore done@local \\}
match =DWORD, vartype \\{ varname dd ?
restore done@local \\}
match =PWORD, vartype \\{ varname dp ?
restore done@local \\}
match =QWORD, vartype \\{ varname dq ?
restore done@local \\}
match =TBYTE, vartype \\{ varname dt ?
restore done@local \\}
match =DQWORD, vartype \\{ label varname dqword
dq ?,?
restore done@local \\}
match , done@local \\{ varname vartype
restore done@local \\} \}
match ,done@local
\{ var
restore done@local \}
common
endl }
/contrib/sdk/sources/sound/src/setbuf.asm
0,0 → 1,62
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
extrn hSound
 
public _SetBuffer@16
public _PlayBuffer@8
 
align 4
_SetBuffer@16: ;str:dword, src:dword, offs:dword, size:dword
 
push ebx
push ecx
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 16 ;.inp_size
push ebx ;.input
push SND_SETBUFF ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 16
align 4
_PlayBuffer@8: ;str:dword,flags:dword
 
push ebx
push ecx
 
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 8 ;.inp_size
push ebx ;.input
push SND_PLAY ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 8
 
/contrib/sdk/sources/sound/src/snd.inc
0,0 → 1,41
 
struc CTRL_INFO
{ .pci_cmd dd ?
.irq dd ?
.glob_cntrl dd ?
.glob_sta dd ?
.codec_io_base dd ?
.ctrl_io_base dd ?
.codec_mem_base dd ?
.ctrl_mem_base dd ?
.codec_id dd ?
}
CTRL_INFO_SIZE equ 9*4
 
SRV_GETVERSION equ 0
SND_CREATE_BUFF equ 1
SND_DESTROY_BUFF equ 2
SND_SETFORMAT equ 3
SND_GETFORMAT equ 4
SND_RESET equ 5
SND_SETPOS equ 6
SND_GETPOS equ 7
SND_SETBUFF equ 8
SND_OUT equ 9
SND_PLAY equ 10
SND_STOP equ 11
SND_SETVOLUME equ 12
SND_GETVOLUME equ 13
SND_SETPAN equ 14
SND_GETPAN equ 15
SND_GETBUFFSIZE equ 16
SND_GETFREESPACE equ 17
SND_SETTIMEBASE equ 18
SND_GETTIMESTAMP equ 19
 
DEV_SET_BUFF equ 4
DEV_NOTIFY equ 5
DEV_SET_MASTERVOL equ 6
DEV_GET_MASTERVOL equ 7
DEV_GET_INFO equ 8
 
/contrib/sdk/sources/sound/src/sndgetfmt.asm
0,0 → 1,35
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
extrn hSound
 
public _GetFormat@8
 
align 4
_GetFormat@8: ;str:dword, p_fmt:dword
push ebx
push ecx
lea eax, [esp+16] ;p_fmt
lea ebx, [esp+12] ;[stream]
 
push 4 ;.out_size
push eax ;.output
push 4 ;.inp_size
push ebx ;.input
push SND_GETFORMAT ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 8
/contrib/sdk/sources/sound/src/sndgetmvol.asm
0,0 → 1,74
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
public _GetMasterVol@4
 
extrn hrdwSound
 
align 4
proc _GetMasterVol@4 stdcall, pvol:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx
push ecx
mov eax, [hrdwSound]
mov ecx, [pvol]
xor ebx, ebx
mov [handle], eax
mov [io_code], DEV_GET_MASTERVOL
mov [input], ebx
mov [inp_size], ebx
mov [output], ecx
mov [out_size], 4
 
mov eax, 68
mov ebx, 17
lea ecx, [handle]
int 0x40
pop ecx
pop ebx
ret
endp
 
if 0
align 4
proc _GetDevInfo@8 stdcall, hSrv:dword, p_info:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx
mov eax, [hSrv]
xor ebx, ebx
mov ecx, [p_info]
 
mov [handle], eax
mov [io_code], DEV_GET_INFO
mov [input], ebx
mov [inp_size], ebx
mov [output], ecx
mov [out_size], CTRL_INFO_SIZE
 
lea eax, [handle]
stdcall CallServiceEx, eax
pop ebx
ret
endp
 
end if
/contrib/sdk/sources/sound/src/sndgetpan.asm
0,0 → 1,35
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
public _GetPan@8
 
extrn hSound
 
align 4
_GetPan@8: ;str:dword, p_pan:dword
push ebx
push ecx
lea eax, [esp+16]
lea ebx, [esp+12] ;[stream]
 
push 4 ;.out_size
push eax ;.output
push 4 ;.inp_size
push ebx ;.input
push SND_GETPAN ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 8
 
/contrib/sdk/sources/sound/src/sndgetpos.asm
0,0 → 1,36
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
extrn hSound
 
public _GetBufferPos@8
 
align 4
_GetBufferPos@8: ;str:dword, p_pos:dword
 
push ebx
push ecx
lea eax, [esp+16]
lea ebx, [esp+12] ;[stream]
 
push 4 ;.out_size
push eax ;.output
push 4 ;.inp_size
push ebx ;.input
push SND_GETPOS ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 8
/contrib/sdk/sources/sound/src/sndgetsize.asm
0,0 → 1,63
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
public _GetBufferSize@8
public _GetBufferFree@8
 
extrn hSound
 
align 4
_GetBufferSize@8: ;str:dword, p_size:dword
push ebx
push ecx
lea eax, [esp+16]
lea ebx, [esp+12] ;[stream]
 
push 4 ;.out_size
push eax ;.output
push 4 ;.inp_size
push ebx ;.input
push SND_GETBUFFSIZE;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 8
align 4
_GetBufferFree@8: ;str:dword, p_free:dword
push ebx
push ecx
lea ebx, [esp+12] ;[stream]
push 0 ;storage for free_space
mov eax, esp
 
push 4 ;.out_size
push eax ;.output
push 4 ;.inp_size
push ebx ;.input
push SND_GETFREESPACE ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
mov ecx, [esp+20] ; p_free
pop dword [ecx]
pop ecx
pop ebx
ret 8
/contrib/sdk/sources/sound/src/sndgetvol.asm
0,0 → 1,44
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
public _GetVolume@12
 
extrn hSound
 
align 4
proc _GetVolume@12 stdcall, str:dword, pleft:dword,pright:dword
locals
handle dd ?
io_code dd ?
input dd ?
inp_size dd ?
output dd ?
out_size dd ?
endl
push ebx
push ecx
mov eax, [hSound]
lea ebx, [str]
lea ecx, [pleft]
mov [handle], eax
mov [io_code], SND_GETVOLUME
mov [input], ebx
mov [inp_size], 4
mov [output], ecx
mov [out_size], 8
 
mov eax, 68
mov ebx, 17
lea ecx, [handle]
int 0x40
pop ecx
pop ebx
ret
endp
 
 
/contrib/sdk/sources/sound/src/sndout.asm
0,0 → 1,34
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
extrn hSound
 
public _WaveOut@12
 
align 4
_WaveOut@12: ;str:dword, src:dword, size:dword
push ebx
push ecx
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 12 ;.inp_size
push ebx ;.input
push SND_OUT ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 12
/contrib/sdk/sources/sound/src/sndreset.asm
0,0 → 1,36
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
extrn hSound
 
public _ResetBuffer@8
 
align 4
_ResetBuffer@8: ;str:dword, flags:dword
 
push ebx
push ecx
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 12 ;.inp_size
push ebx ;.input
push SND_RESET ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 8
/contrib/sdk/sources/sound/src/sndsetfmt.asm
0,0 → 1,35
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
extrn hSound
 
public _SetFormat@8
 
align 4
_SetFormat@8: ;str:dword, fmt:dword
 
push ebx
push ecx
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 8 ;.inp_size
push ebx ;.input
push SND_SETFORMAT ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 8
/contrib/sdk/sources/sound/src/sndsetmvol.asm
0,0 → 1,36
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
public _SetMasterVol@4
 
extrn hrdwSound
 
align 4
_SetMasterVol@4: ;vol:dword
push ebx
push ecx
 
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 4 ;.inp_size
push ebx ;.input
push DEV_SET_MASTERVOL ;.code
push dword [hrdwSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 4
 
/contrib/sdk/sources/sound/src/sndsetpan.asm
0,0 → 1,34
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
public _SetPan@8
 
extrn hSound
 
align 4
_SetPan@8: ;str:dword, pan:dword
push ebx
push ecx
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 12 ;.inp_size
push ebx ;.input
push SND_SETPAN ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 8
/contrib/sdk/sources/sound/src/sndsetpos.asm
0,0 → 1,36
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
extrn hSound
 
public _SetBufferPos@8
 
align 4
_SetBufferPos@8: ;str:dword, offs:dword
 
push ebx
push ecx
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 8 ;.inp_size
push ebx ;.input
push SND_SETPOS ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 8
/contrib/sdk/sources/sound/src/sndsetvol.asm
0,0 → 1,36
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
public _SetVolume@12
 
extrn hSound
 
align 4
_SetVolume@12: ;str:dword, lvol:dword,rvol:dword
push ebx
push ecx
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 12 ;.inp_size
push ebx ;.input
push SND_SETVOLUME ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 12
 
/contrib/sdk/sources/sound/src/sndtime.asm
0,0 → 1,90
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
public _SetTimeBase@12
public _GetTimeStamp@8
public _GetDevTime@4
 
extrn hSound
extrn hrdwSound
 
align 4
_SetTimeBase@12: ;stdcall str:dword, timebase:qword
 
push ebx
push ecx
 
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 12 ;.inp_size
push ebx ;.input
push SND_SETTIMEBASE ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 12
 
align 4
_GetTimeStamp@8: ; stdcall, str:dword, pstamp:dword
 
push ebx
push ecx
 
lea ebx, [esp+12] ;[stream]
mov eax, [esp+16] ;[pstamp]
 
push 8 ;.out_size
push eax ;.output
push 4 ;.inp_size
push ebx ;.input
push SND_GETTIMESTAMP ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 8
 
align 4
_GetDevTime@4: ; pstamp:dword
 
push ebx
push ecx
 
xor ebx, ebx
mov eax, [esp+12] ;[pstamp]
 
push 4 ;.out_size
push eax ;.output
push ebx ;.inp_size
push ebx ;.input
push 9 ;.code
push dword [hrdwSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 4
 
 
/contrib/sdk/sources/sound/src/stopbuf.asm
0,0 → 1,37
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
extrn hSound
 
public _StopBuffer@4
 
align 4
_StopBuffer@4: ;str:dword
 
push ebx
push ecx
 
xor eax, eax
lea ebx, [esp+12] ;[stream]
 
push eax ;.out_size
push eax ;.output
push 4 ;.inp_size
push ebx ;.input
push SND_STOP ;.code
push dword [hSound] ;.handle
 
mov eax, 68
mov ebx, 17
mov ecx, esp
int 0x40
add esp, 24
pop ecx
pop ebx
ret 4
/contrib/sdk/sources/sound/src/wavhdr.asm
0,0 → 1,170
format MS COFF
 
include "snd.inc"
include "proc32.inc"
 
section '.text' align 16 code readable executable
 
public _test_wav@4
 
; convert WAVEHEADER into PCM_x_xx_xx constant
 
align 4
proc _test_wav@4 stdcall, hdr:dword
 
mov eax, [hdr]
cmp dword [eax], 0x46464952
jne .fail
 
cmp dword [eax+8], 0x45564157
jne .fail
 
cmp word [eax+20], 1
jne .fail
 
mov ecx, dword [eax+24]
mov edx, 22050
cmp ecx, edx
ja .high
je .l_22
 
cmp ecx, 8000
je .l_8
 
cmp ecx, 11025
je .l_11
 
cmp ecx, 12000
je .l_12
 
cmp ecx, 16000
je .l_16
.fail:
xor eax, eax
ret
.high:
cmp ecx, 24000
je .LN56
cmp ecx, 32000
je .LN65
cmp ecx, 44100
je .LN74
cmp ecx, 48000
jne .fail
 
movzx ecx, word [eax+22]
dec ecx
je .LN79
dec ecx
jne .LN74
 
mov edx, 19
jmp .done
.LN79:
mov edx, 20
jmp .done
.LN74:
movzx ecx, word [eax+22]
dec ecx
je .LN70
dec ecx
jne .LN65
 
mov edx, 21
jmp .done
.LN70:
mov edx, 22
jmp .done
.LN65:
movzx ecx, word [eax+22]
dec ecx
je .LN61
dec ecx
jne .LN56
 
mov edx, 23
jmp .done
.LN61:
mov edx, 24
jmp .done
.LN56:
movzx ecx, word [eax+22]
dec ecx
je .LN52
dec ecx
je .LN50
.l_22:
movzx ecx, word [eax+22]
dec ecx
je .LN43
dec ecx
je .LN41
.l_16:
movzx ecx, word [eax+22]
dec ecx
je .LN34
dec ecx
je .LN32
.l_12:
movzx ecx, word [eax+22]
dec ecx
je .LN25
dec ecx
je .LN23
.l_11:
movzx ecx, word [eax+22]
dec ecx
je .LN16
dec ecx
je .LN14
.l_8:
movzx ecx, word [eax+22]
dec ecx
je .LN7
dec ecx
jne .fail
 
mov edx, 35
jmp .done
.LN7:
mov edx, 36
jmp .done
.LN14:
mov edx, 33
jmp .done
.LN16:
mov edx, 34
jmp .done
.LN23:
mov edx, 31
jmp .done
.LN25:
mov edx, 32
jmp .done
.LN32:
mov edx, 29
jmp .done
.LN34:
mov edx, 30
jmp .done
.LN41:
mov edx, 27
jmp .done
.LN43:
mov edx, 28
jmp .done
.LN50:
mov edx, 25
jmp .done
.LN52:
mov edx, 26
.done:
xor ecx, ecx
cmp word [eax+34], 16
setne cl
dec ecx
and ecx, -18
add ecx, edx
mov eax, ecx
ret
endp