Soundblaster FM...

Programming, for all ages and all languages.
Post Reply
Christopher

Soundblaster FM...

Post by Christopher »

Hi! I wanna play a tune on the SB FM-chip-thing...
But my code isn't working? Can someone see why??


Bits 16
Org 0x0100

xor   ax, ax
int   0x16

call   fmReset

mov   bh, 0x20
mov   bl, 0x01
call   fmRegister

mov   bh, 0x40
mov   bl, 0x10
call   fmRegister

mov   bh, 0x60
mov   bl, 0xF0
call   fmRegister

mov   bh, 0x80
mov   bl, 0x77
call   fmRegister

mov   bh, 0xA0
mov   bl, 0x98
call   fmRegister

mov   bh, 0x23
mov   bl, 0x01
call   fmRegister

mov   bh, 0x43
mov   bl, 0x00
call   fmRegister

mov   bh, 0x63
mov   bl, 0xF0
call   fmRegister

mov   bh, 0x83
mov   bl, 0x77
call   fmRegister

mov   bh, 0xB0
mov   bl, 0x31
call   fmRegister

xor   ax, ax
int   0x16

xor   ax, ax
int   0x21

pAddress   dw   0x0330
pData      dw   0x0331

fmReset:
push   bx
push   cx

xor   bx, bx
mov   cx, 0xF6
fmResetLoop:
call   fmRegister
inc   bh
loop   fmResetLoop

pop   cx
pop   bx
ret

;--------------------------
; bh = register, bl = value
;--------------------------
fmRegister:
push   ax
push   cx
push   dx
mov   dx, pAddress
mov   al, bh
out   dx, al

mov   cx, 6
fmRegisterLoop1:
in   al, dx
loop   fmRegisterLoop1

mov   dx, pData
mov   al, bl
out   dx, al

mov   dx, pAddress
mov   cx, 35
fmRegisterLoop2:
in   al, dx
loop   fmRegisterLoop2
pop   dx
pop   cx
pop   ax
ret

(I use NASM)

Best Regards
/ Christopher
Post Reply