Sound Blaster 16: Difference between revisions

Jump to navigation Jump to search
→‎Code: add assembly driver code
[unchecked revision][unchecked revision]
No edit summary
(→‎Code: add assembly driver code)
Line 124:
 
}
</source>
 
<source lang="asm">
%macro OUTB 2
mov dx, %1
mov al, %2
out dx, al
%endmacro
 
%macro INB 2
mov dx, %1
in al, dx
%endmacro
 
 
;SOUND BLASTER 16 driver in real mode
 
;reset sound blaster
OUTB 0x226, 1 ;reset port
mov ah, 86h
mov cx, 0x0000
mov dx, 0xFFFF
int 15h ;wait
OUTB 0x226, 0 ;reset port
 
;DMA channel 1
OUTB 0x0A, 5 ;disable channel 1 (number of channel + 0x04)
OUTB 0x0C, 1 ;flip flop
OUTB 0x0B, 0x49 ;transfer mode
OUTB 0x83, 0 ;PAGE TRANSFER - SET THIS VALUE FOR YOU
OUTB 0x02, 0x00 ;POSITION LOW BIT - SET THIS VALUE FOR YOU
OUTB 0x02, 0x00 ;POSITON HIGH BIT- SET THIS VALUE FOR YOU
OUTB 0x03, 0xFF ;COUNT LOW BIT (EXAMPLE 0x0FFF) - SET THIS VALUE FOR YOU
OUTB 0x03, 0x0F ;COUNT HIGH BIT (EXAMPLE 0x0FFF) - SET THIS VALUE FOR YOU
OUTB 0x0A, 1 ;enable channel 1
 
;program sound blaster 16
OUTB 0x22C, 0x40 ;set time constant
OUTB 0x22C, 165 ;10989 Hz
OUTB 0x22C, 0x14 ;mode DAC 8 bit
OUTB 0x22C, 0xFE ;COUNT LOW BIT (EXAMPLE 0x0FFF) - SET THIS VALUE FOR YOU
OUTB 0x22C, 0x0F ;COUNT HIGH BIT (EXAMPLE 0x0FFF) - SET THIS VALUE FOR YOU
 
;now transfer start - dont forget to handle irq
</source>
 
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.

Navigation menu