Subversion Repositories Kolibri OS

Rev

Rev 837 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 837 Rev 860
Line 127... Line 127...
127
proc sb_play
127
proc sb_play
128
	and  [int_flip_flop],0
128
	and  [int_flip_flop],0
129
	mov  edx,[sb_base_port]
129
	mov  edx,[sb_base_port]
130
	add  dl,0xC
130
	add  dl,0xC
131
	sb_out 0xD1 ;turn speaker on
131
	sb_out 0xD1 ;turn speaker on
132
;        sb_out 0x48 ;set DSP transfer size  ;for older cards
132
;        sb_out 0x48 ;set DSP transfer size  ;for older cards, not supported
133
 
-
 
-
 
133
;                                            ;in this version
134
;        mov  ax,32767 ;(64k)/2-1
134
;        mov  ax,32767 ;(64k)/2-1
135
;@@:                 ;out the low byte...
135
;@@:                 ;out the low byte...
136
;        in   al,dx
136
;        in   al,dx
137
;        test al,al  ;is DSP busy?
137
;        test al,al  ;is DSP busy?
138
;        js   @b     ;it's busy
138
;        js   @b     ;it's busy
Line 160... Line 160...
160
;                ||
160
;                ||
161
	sb_out 00110000b ;bMode
161
	sb_out 00110000b ;bMode
162
;              ||  ||||
162
;              ||  ||||
163
;              ---------reserved
163
;              ---------reserved
164
;wSize is a number of 16bit samples less 1. For auto-init mode each half
164
;wSize is a number of 16bit samples less 1. For auto-init mode each half
165
;buffer is (64k)/2 bytes long and, obviously, contains ((64k)/2)/2 bytes
165
;buffer is (64k)/2 bytes long and, obviously, contains ((64k)/2)/2 samples
166
	sb_out (((sb_buffer_size/2/2)-1) and 0xFF) ;wSize.LowByte
166
	sb_out (((sb_buffer_size/2/2)-1) and 0xFF) ;wSize.LowByte
167
	sb_out (((sb_buffer_size/2/2)-1) shr 8)    ;wSize.HighByte
167
	sb_out (((sb_buffer_size/2/2)-1) shr 8)    ;wSize.HighByte
168
	ret
168
	ret
169
endp
169
endp
170
;-------------------------------------------------------------------------------
170
;-------------------------------------------------------------------------------
Line 190... Line 190...
190
	sti
190
	sti
191
end if
191
end if
192
	out  dx,al
192
	out  dx,al
193
	ret
193
	ret
194
endp
194
endp
-
 
195
 
195
;-------------------------------------------------------------------------------
196
;-------------------------------------------------------------------------------
196
;       set the rate for playing, enable stereo
197
;       set the rate for playing, enable stereo
197
;-------------------------------------------------------------------------------
198
;-------------------------------------------------------------------------------
198
proc sb_setup
199
proc sb_setup
199
	mov  edx,[sb_base_port]
200
	mov  edx,[sb_base_port]
Line 202... Line 203...
202
	sb_out sb_tc
203
	sb_out sb_tc
Line 203... Line 204...
203
 
204
 
204
	sb_out 41h  ;set sound rate, this can only SB16
205
	sb_out 41h  ;set sound rate, this can only SB16
205
	sb_out (sb_out_rate shr 8)    ;first high byte (MSB)
206
	sb_out (sb_out_rate shr 8)    ;first high byte (MSB)
-
 
207
	sb_out (sb_out_rate and 0xff) ;then low byte (LSB)
206
	sb_out (sb_out_rate and 0xff) ;then low byte (LSB)
208
 
207
;        mov  al,0xE
209
;        mov  al,0xE  ;for older cards, not supported in this version
208
;        sub  dl,(0xC-4) ;talk to SB's mixer
210
;        sub  dl,(0xC-4) ;talk to SB's mixer
209
;        out  dx,al      ;select this register of the mixer
211
;        out  dx,al      ;select this register of the mixer
210
;        mov  ecx,6      ;wait for the chip
212
;        mov  ecx,6      ;wait for the chip
211
;@@:
213
;@@:
Line 235... Line 237...
235
;@@:
237
;@@:
236
;        in   al,dx
238
;        in   al,dx
237
;        loop @b
239
;        loop @b
238
	ret
240
	ret
239
endp
241
endp
240
242
 
-
 
243
;-------------------------------------------------------------------------------
-
 
244
;       set master volume of SB mixer, note, not only SB16 but SBPro and older
-
 
245
;       this is the first step to more full support for hardware
-
 
246
;-------------------------------------------------------------------------------
-
 
247
;in: eax in range [-10000;0] - master volume for _both_ channels
-
 
248
;note that x*3*17/2000 and x*3/2000*17 are not the same numbers,
-
 
249
;because we count in integers
-
 
250
proc sb_set_master_vol
-
 
251
	mov  [sb_master_vol],eax
-
 
252
	add  eax,10000 ;SB sound level rise from 0 to MAX_LEVEL
-
 
253
	lea  eax,[eax+eax*2] ;*3
-
 
254
	mov  ebx,2000  ;divisor
-
 
255
	xor  edx,edx
-
 
256
	cmp  byte[sb_DSP_version_int],4
-
 
257
	jae  @f       ;SBPro's MAX_LEVEL is 15, but we *11 because
-
 
258
		      ;volume byte looks like that: 0xLR, where L - left
-
 
259
		      ;channel volume, R - right, 0<=R,L<=15
-
 
260
	div  ebx
-
 
261
	imul eax,17
-
 
262
	mov  edx,[sb_base_port]
-
 
263
	push eax      ;here for optimisation
-
 
264
	add  dl,4
-
 
265
	mov  al,0x22  ;write mixer register 0x22
-
 
266
	out  dx,al
-
 
267
	in   al,dx    ;wait for the chip ;6
-
 
268
	in   al,dx    ;wait for the chip ;5
-
 
269
	in   al,dx    ;wait for the chip ;4
-
 
270
	in   al,dx    ;wait for the chip ;3
-
 
271
	in   al,dx    ;wait for the chip ;2
-
 
272
	in   al,dx    ;wait for the chip ;1
-
 
273
	pop  eax			 ;go!
-
 
274
	inc  edx
-
 
275
	out  dx,al
-
 
276
	ret
-
 
277
@@:		      ;SB16's MAX_LEVEL is 255
-
 
278
	imul eax,17
-
 
279
	div  ebx
-
 
280
	mov  edx,[sb_base_port]
-
 
281
	push eax      ;here for optimisation
-
 
282
	add  dl,4
-
 
283
	mov  al,0x30  ;left speaker
-
 
284
	out  dx,al
-
 
285
	pop  eax      ;<--+
-
 
286
	inc  edx      ;   \/
-
 
287
	push eax      ;here for optimisation
-
 
288
	out  dx,al    ;write
-
 
289
	dec  edx
-
 
290
	mov  al,0x31  ;right speaker
-
 
291
	out  dx,al
-
 
292
	pop  eax
-
 
293
	inc  edx
-
 
294
	out  dx,al    ;write
-
 
295
	ret
-
 
296
endp
-
 
297
;-------------------------------------------------------------------------------
-
 
298
>