Added libraries/ufmod source code.

git-svn-id: svn://kolibrios.org@1845 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Yogev Ezra 2011-02-04 20:13:33 +00:00
parent 32e469b81f
commit d21a6e85e7
26 changed files with 7353 additions and 0 deletions

View File

@ -0,0 +1,142 @@
; FRMWRK.ASM
; ----------
; A set of common GUI code used in uFMOD examples for KolibriOS.
; Feel free to reuse it in your own projects if you like it ;)
; ---------------------------------------------------------------
; void _cdecl _MessageBox (szCap, lpString, cbString);
; void _cdecl _MessageBoxCB(szCap, lpString, cbString, cbProc);
; ---------------------------------------------------------------
; This is similar to a Win32 MessageBox. The box is centered
; on screen. It contains a single-line text message and an
; "OK" button. This function returns when user closes the
; box (via the X button or via the OK button). An optional
; callback subroutine may be specified to be called when no
; events are pending in the event queue.
; NOTE: Doesn't work if you already have defined a window
; in the current process! Doesn't modify the event mask. So,
; make sure keyboard events are enabled before calling this
; function. This function doesn't check the validity of the
; supplied parameters!
; Parameters:
; szCap - A pointer to the ASCIIz string containing the
; caption. A trailing zero char IS required.
; lpString - A pointer to an ASCII string containing a single
; line message to pop up in the box. No trailing
; zero char is required.
; cbString - number of characters in string.
; cbProc - Address of the callback subroutine. Can be NULL.
sOK db "OK"
if FRMWRK_CALLBACK_ON
_MessageBoxCB:
else
_MessageBox:
end if
push ebp
push esi
push edi
push ebx
xor ebp,ebp ; global 0
mov esi,[esp+28] ; cbString
mov edi,[esp+20] ; szCap
; Get screen metrics.
lea eax,[ebp+14]
int 40h
mov ecx,eax
movzx eax,ax
shr ecx,16 ; screen w
xchg eax,edx ; screen h
lea ebx,[esi*2+esi]
lea ebx,[ebx*2+28] ; w = string len * 6 + 28
sub ecx,ebx
shr ecx,1
shl ecx,16
or ebx,ecx
lea ecx,[ebp+52h] ; h = 52h
sub edx,ecx
shr edx,1
shl edx,16
or ecx,edx ; y = (screen h - window h) / 2
mov edx,ebx ; x = (screen w - window w) / 2
_MessageBoxCB_redraw:
; Start redraw.
push edx
lea eax,[ebp+12]
lea ebx,[ebp+1]
int 40h
; Define and draw window.
xor eax,eax
mov ebx,edx ; x, w (ECX: y, h)
mov edx,34C0C0C0h ; style and BG color
int 40h
; Define the OK button.
push esi
lea eax,[ebp+8]
sub ebx,28+0Ah
shr bx,1
shl ebx,16 ; x = (window w - button w) / 2
mov bx,18+0Ah ; w = 18 + 0Ah
mov ecx,001C0012h ; y = 1Ch, h = 12h
lea edx,[ebp+1] ; ID = close
mov esi,0C0C0C0h ; color
int 40h
; Draw the OK label.
lea eax,[ebp+4]
add ebx,90000h ; x = button x + 9
mov bx,22h ; y = 22h
xor ecx,ecx ; style, font and color
mov edx,sOK ; string
lea esi,[ebp+2] ; length
int 40h
pop esi
; Draw text string.
lea eax,[ebp+4]
mov ebx,000A000Ah ; x = 0Ah, y = 0Ah
xor ecx,ecx ; style, font and color
mov edx,[esp+28] ; lpString
int 40h
; End redraw.
lea eax,[ebp+12]
lea ebx,[ebp+2]
int 40h
if FRMWRK_CALLBACK_ON
_MessageBoxCB_eventloop:
mov edx,[esp+36] ; cbProc
test edx,edx
lea eax,[ebp+10]
jz _MessageBoxCB_peekevent
; Invoke the callback.
call edx
lea eax,[ebp+23]
lea ebx,[ebp+10] ; wait for at most 0.1 sec
_MessageBoxCB_peekevent:
int 40h
dec eax
js _MessageBoxCB_eventloop
else
lea eax,[ebp+10]
int 40h
dec eax
end if
pop edx
jz _MessageBoxCB_redraw
pop ebx
pop edi
pop esi
pop ebp
ret

View File

@ -0,0 +1,239 @@
; JMP2PAT.ASM
; -----------
; Sometimes it makes sense merging various XM tracks
; sharing the same instruments in a single XM file.
; This example program uses such an XM file actually
; containing 3 tracks and the _uFMOD_Jump2Pattern
; function to play all 3 tracks in the same file.
; A precompiled version (not packed or whatever) is
; available in bin\
use32
org 0
db 'MENUET01'
dd 1
dd START ; Entry point
dd uFMOD_IMG_END ; End of code and initialized data
dd MEMORY_END ; End of uninitialized (BSS) data
dd STACK_B ; Bottom of the stack
dd 0 ; Args
dd 0 ; Reserved
; uFMOD setup:
UF_FREQ equ 48000 ; Set sampling rate to 48KHz (22050, 44100, 48000)
UF_RAMP equ STRONG ; Select STRONG interpolation (NONE, WEAK, STRONG)
UD_MODE equ UNSAFE ; Select UNSAFE mode (NORMAL, UNSAFE)
DEBUG equ 0 ; Skip debug-board messages
NOLINKER equ 1 ; Select "no linker" mode
; uFMOD constants:
XM_MEMORY = 1
XM_FILE = 2
XM_NOLOOP = 8
XM_SUSPENDED = 16
uFMOD_MIN_VOL = 0
uFMOD_MAX_VOL = 25
uFMOD_DEFAULT_VOL = 25
; BLITZXMK.XM tracked by Kim (aka norki):
; [00:07] - track #1
; [08:10] - track #2
; [11:13] - track #3
xm file '..\ufmodlib\media\BLITZXMK.XM'
xm_length = $ - xm
; Optimization:
; This header file is suitable for blitzxmk.xm track only!
; If you change the track, update the optimization header.
; (Use the standart eff.inc file for a general purpose player app.)
include '..\ufmodlib\media\blitz.eff.inc'
; Include the GUI framework.
FRMWRK_CALLBACK_ON equ 0 ; Disable callback
include 'frmwrk.asm'
; UI text messages.
vals dd 0,8,11 ; Preset pattern indexes
wnd_btns1 db "1 2 3 Pause "
wnd_btns2 db "1 2 3 Resume"
wnd_btns_l = $ - wnd_btns2
wnd_cap db "Jump2Pattern",0
err_txt db "Error"
err_txt_l = $ - err_txt
err_cap db ":-(",0
START:
; Start playback.
push XM_MEMORY
push xm_length
push xm
call _uFMOD_LoadSong
; Stack fixing is required here, but in this simple
; example leaving ESP as it is won't harm. In a real
; application you should uncomment the following line:
; add esp,12
test eax,eax
jz error
xor ebp,ebp ; global 0
mov [wnd_btns],wnd_btns1
; Switch keyboard mode to SCANCODE.
lea ebx,[ebp+1]
lea eax,[ebp+66]
mov ecx,ebx
int 40h
; Get screen metrics.
lea eax,[ebp+14]
int 40h
mov ecx,eax
movzx eax,ax
shr ecx,16 ; screen w
xchg eax,edx ; screen h
mov ebx,wnd_btns_l*6+42
sub ecx,ebx
shr ecx,1
shl ecx,16
or ebx,ecx
lea ecx,[ebp+40h] ; h = 40h
sub edx,ecx
shr edx,1
shl edx,16
or ecx,edx ; y = (screen h - window h) / 2
mov edx,ebx ; x = (screen w - window w) / 2
redraw:
; Start redraw.
push edx
lea eax,[ebp+12]
lea ebx,[ebp+1]
int 40h
; Define and draw window.
xor eax,eax
mov ebx,edx ; x, w (ECX: y, h)
mov edx,34C0C0C0h ; style and BG color
mov edi,wnd_cap
int 40h
; Define the 1 2 3 Pause/Resume buttons.
lea eax,[ebp+8]
mov ebx,0A0012h ; x = 0Ah, w = 12h
mov ecx,0A0012h ; y = 0Ah, h = 10h
lea edx,[ebp+10] ; ID = #10
mov esi,0C0C0C0h ; color
int 40h
mov ebx,280012h ; x = 28h, w = 12h
inc edx ; ID = #11
int 40h
mov ebx,460012h ; x = 46h, w = 12h
inc edx ; ID = #12
int 40h
mov ebx,640030h ; x = 64h, w = 30h
inc edx ; ID = #13
int 40h
; Draw the labels.
lea eax,[ebp+4]
mov ebx,120011h ; x = 12h, y = 11h
xor ecx,ecx ; style, font and color
mov edx,[wnd_btns] ; string
lea esi,[ebp+wnd_btns_l] ; length
int 40h
; End redraw.
lea eax,[ebp+12]
lea ebx,[ebp+2]
int 40h
eventloop:
; Update the PCM buffer.
call _uFMOD_WaveOut
lea eax,[ebp+23]
lea ebx,[ebp+10] ; wait for at most 0.1 sec
int 40h
dec eax
js eventloop ; 0 = idle
jz redraw ; 1 = redraw
dec eax ; 2 = keyboard event
jnz chk_eventbutton
; Get key scancode.
lea eax,[ebp+2]
int 40h
cmp ah,19h ; P
je do_PauseResume
cmp ah,13h ; R
je do_PauseResume
chk_kb123:
movzx eax,ah
sub eax,2
jmp do_Jump2Pat123
chk_eventbutton: ; 3 = button event
lea eax,[ebp+17]
int 40h
cmp ah,1 ; Close
je break_loop
cmp ah,13 ; Pause/Resume
jne chk_btn123
do_PauseResume:
cmp BYTE [paused],1
mov edx,_uFMOD_Resume
mov ebx,wnd_btns1
je do_Resume
mov edx,_uFMOD_Pause
mov ebx,wnd_btns2
do_Resume:
call edx
xor BYTE [paused],1
mov [wnd_btns],ebx
jmp redraw
chk_btn123: ; 1 2 3
movzx eax,ah
sub eax,10
do_Jump2Pat123:
cmp eax,3
jae eventloop
push DWORD [vals+eax*4]
call _uFMOD_Jump2Pattern
pop eax ; fix stack
jmp eventloop
break_loop:
; Stop playback.
call _uFMOD_StopSong
r: ; Exit.
xor eax,eax
dec eax
int 40h
error:
push err_txt_l ; cbString
push err_txt ; lpString
push err_cap ; szCap
call _MessageBox
; add esp,16
jmp r
; Include the whole uFMOD sources here. (Right after
; your main code to avoid naming conflicts, but still
; inside your code section.)
macro PUBLIC symbol {} ; hide all publics
include '..\ufmodlib\src\fasm.asm'
wnd_btns dd ?
paused db ?
align 4
rb 1020
STACK_B dd ? ; Stack bottom
MEMORY_END: ; End of uninitialized (BSS) data

View File

@ -0,0 +1,20 @@
@echo off
rem Make the uFMOD examples.
rem Compiler: FASM
rem Target OS: KolibriOS
rem FASM Path:
SET UF_FASM=\fasm
if not exist "%UF_FASM%\fasm.exe" goto Err1
"%UF_FASM%\fasm" mini.asm mini
"%UF_FASM%\fasm" jmp2pat.asm jmp2pat
goto TheEnd
:Err1
echo Couldn't find fasm.exe in %UF_FASM%\
:TheEnd
pause
@echo on
cls

View File

@ -0,0 +1,109 @@
; MINI.ASM
; --------
; Minimalistic uFMOD usage example.
; Shows how to play an XM track in memory,
; including proper error handling.
; A precompiled version (not packed or whatever) is
; available in bin\
use32
org 0
db 'MENUET01'
dd 1
dd START ; Entry point
dd uFMOD_IMG_END ; End of code and initialized data
dd MEMORY_END ; End of uninitialized (BSS) data
dd STACK_B ; Bottom of the stack
dd 0 ; Args
dd 0 ; Reserved
; uFMOD setup:
UF_FREQ equ 48000 ; Set sampling rate to 48KHz (22050, 44100, 48000)
UF_RAMP equ STRONG ; Select STRONG interpolation (NONE, WEAK, STRONG)
UD_MODE equ UNSAFE ; Select UNSAFE mode (NORMAL, UNSAFE)
DEBUG equ 0 ; Skip debug-board messages
NOLINKER equ 1 ; Select "no linker" mode
; uFMOD constants:
XM_MEMORY = 1
XM_FILE = 2
XM_NOLOOP = 8
XM_SUSPENDED = 16
uFMOD_MIN_VOL = 0
uFMOD_MAX_VOL = 25
uFMOD_DEFAULT_VOL = 25
; The XM track.
xm file '..\ufmodlib\media\mini.xm'
xm_length = $ - xm
; Optimization:
; This header file is suitable for mini.xm track only!
; If you change the track, update the optimization header.
; (Use the standart eff.inc file for a general purpose player app.)
include '..\ufmodlib\media\mini.eff.inc'
; Include the GUI framework.
FRMWRK_CALLBACK_ON equ 1 ; Enable callback
include 'frmwrk.asm'
; UI text messages.
msg_txt db "uFMOD ruleZ!"
msg_txt_l = $ - msg_txt
msg_cap db "FASM",0
err_txt db "Error"
err_txt_l = $ - err_txt
err_cap db ":-(",0
START:
; Start playback.
push XM_MEMORY
push xm_length
push xm
call _uFMOD_LoadSong
; Stack fixing is required here, but in this simple
; example leaving ESP as it is won't harm. In a real
; application you should uncomment the following line:
; add esp,12
test eax,eax
jz error
; Wait for user input.
push _uFMOD_WaveOut ; cbProc <- continue fetching data!
push msg_txt_l ; cbString
push msg_txt ; lpString
push msg_cap ; szCap
call _MessageBoxCB
; add esp,16
; Stop playback.
call _uFMOD_StopSong
r: ; Exit.
xor eax,eax
dec eax
int 40h
error:
push 0 ; cbProc <- no callback
push err_txt_l ; cbString
push err_txt ; lpString
push err_cap ; szCap
call _MessageBoxCB
; add esp,16
jmp r
; Include the whole uFMOD sources here. (Right after
; your main code to avoid naming conflicts, but still
; inside your code section.)
macro PUBLIC symbol {} ; hide all publics
include '..\ufmodlib\src\fasm.asm'
align 4
rb 1020
STACK_B dd ? ; Stack bottom
MEMORY_END: ; End of uninitialized (BSS) data

View File

@ -0,0 +1,35 @@
@echo off
rem Set compiler location:
SET MASM32=\masm32
SET UF_FASM=\fasm
if not exist "%MASM32%\bin\ml.exe" goto Err1
if not exist "%UF_FASM%\fasm.exe" goto Err2
"%MASM32%\bin\ml" /c /coff mini.asm
"%MASM32%\bin\link" /DRIVER /SUBSYSTEM:NATIVE /BASE:-0x10000 /ALIGN:0x10000 /MERGE:.data=.text -ignore:4078 mini.obj ufmod.obj
del mini.obj
echo virtual at 0 >tmp.asm
echo file 'mini.exe':3Ch,4 >>tmp.asm
echo load pehea dword from 0 >>tmp.asm
echo file 'mini.exe':pehea+0F8h,28h >>tmp.asm
echo load physofs dword from 4+14h >>tmp.asm
echo load mem dword from 4+8 >>tmp.asm
echo file 'mini.exe':physofs+16,4 >>tmp.asm
echo load sz dword from $-4 >>tmp.asm
echo end virtual >>tmp.asm
echo file 'mini.exe':physofs,sz >>tmp.asm
echo store dword mem at 14h >>tmp.asm
"%UF_FASM%\fasm" tmp.asm mini
del mini.exe
del tmp.asm
goto TheEnd
:Err1
echo Couldn't find ml.exe in %MASM32%\bin
goto TheEnd
:Err2
echo Couldn't find fasm.exe in %UF_FASM%\
:TheEnd
pause
cls

View File

@ -0,0 +1,266 @@
; MINI.ASM
; --------
; Shows how to place data and code inside (!!!) the XM track.
.386
.model flat
include ufmod.inc ; uFMOD API
.CODE
PE_BASE db "MENUET01"
dd 1
dd OFFSET _START ; Entry point
dd OFFSET BSS_START ; End of code and initialized data
dd OFFSET BSS_END ; End of uninitialized (BSS) data
dd OFFSET STACK_B ; Bottom of the stack
dd 0 ; Args
dd 0 ; Reserved
err_txt db "Error"
err_txt_l EQU $ - err_txt
_START:
; Start playback.
push XM_MEMORY
push xm_length
push BYTE PTR xm
; Let's place the stream right inside the code section.
xm_length EQU 905
xm EQU $ - PE_BASE
xm_unused_000 LABEL BYTE
; *** The following 60 bytes are not used. So, we'll place
; *** some code here.
; (the actual size and location of such gaps may be
; found out using the Eff utility)
call uFMOD_LoadSong
xor ebp,ebp ; global 0
; Stack fixing is required here, but in this simple
; example leaving ESP as it is won't harm. In a real
; application you should uncomment the following line:
; add esp,12
test eax,eax
jz error
; Wait for user input.
push uFMOD_WaveOut ; cbProc <- continue fetching data!
push BYTE PTR msg_txt_l ; cbString
push OFFSET msg_txt ; lpString
push OFFSET msg_cap ; szCap
call MessageBoxCB
; add esp,16
; Stop playback.
call uFMOD_StopSong
r: ; Exit.
lea eax,[ebp-1]
int 40h
error:
push ebp ; cbProc <- no callback
push BYTE PTR err_txt_l ; cbString
push BYTE PTR (err_txt - PE_BASE) ; lpString
push OFFSET err_cap ; szCap
call MessageBoxCB
; add esp,16
jmp r
org xm_unused_000 + 60
db 034h,000h,000h,000h,020h,000h,000h,000h,002h,000h,00Dh,000h,001h,000h,001h,000h
db 00Ah,000h,091h,000h,000h,001h,002h,003h,004h,005h,006h,007h,000h,001h,002h,003h
db 004h,005h,006h,007h,008h,009h,00Ah,00Bh,008h,009h,00Ch,00Bh,008h,009h,00Ah,00Bh
db 008h,009h,00Ch,00Bh,009h,000h,000h,000h,000h,004h,000h,001h,000h,083h,016h,001h
db 080h,080h,02Eh,001h,000h,00Eh,060h,080h,03Ah,001h,000h,00Eh,062h,081h,061h,083h
db 035h,001h,009h,000h,000h,000h,000h,004h,000h,001h,000h,083h,016h,001h,080h,080h
db 02Eh,001h,000h,00Eh,060h,080h,035h,001h,000h,00Eh,062h,081h,061h,083h,038h,001h
db 009h,000h,000h,000h,000h,004h,000h,001h,000h,083h,016h,001h,080h,080h,02Eh,001h
db 000h,00Eh,060h,080h,038h,001h,000h,00Eh,062h,080h,083h,033h,001h,009h,000h,000h
db 000h,000h,006h,000h,001h,000h,083h,016h,001h,080h,080h,02Eh,001h,000h,00Eh,060h
db 080h,033h,001h,000h,00Eh,061h,081h,061h,083h,035h,001h,083h,00Dh,001h,083h,036h
db 001h,080h,083h,036h,001h,009h,000h,000h,000h,000h,004h,000h,001h,000h,083h,00Fh
db 001h,080h,080h,02Eh,001h,000h,00Eh,060h,080h,036h,001h,000h,00Eh,062h,081h,061h
db 083h,033h,001h,009h,000h,000h,000h,000h,006h,000h,001h,000h,083h,00Fh,001h,080h
db 080h,02Eh,001h,000h,00Eh,060h,080h,033h,001h,000h,00Eh,061h,081h,061h,083h,02Eh
db 001h,083h,012h,001h,083h,033h,001h,080h,083h,035h,001h,009h,000h,000h,000h,000h
db 006h,000h,001h,000h,083h,016h,001h,080h,080h,02Eh,001h,000h,00Eh,060h,080h,035h
db 001h,000h,00Eh,061h,081h,061h,083h,02Eh,001h,083h,00Dh,001h,083h,031h,001h,080h
db 083h,02Eh,001h,009h,000h,000h,000h,000h,008h,000h,001h,000h,083h,012h,001h,098h
db 00Ah,001h,083h,019h,001h,088h,00Ah,083h,01Eh,001h,081h,061h,083h,012h,001h,080h
db 083h,014h,001h,080h,083h,01Bh,001h,080h,083h,020h,001h,080h,083h,014h,001h,080h
db 009h,000h,000h,000h,000h,008h,000h,001h,000h,083h,012h,001h,081h,061h,083h,019h
db 001h,080h,083h,01Eh,001h,080h,083h,012h,001h,080h,083h,019h,001h,083h,031h,001h
db 083h,01Eh,001h,080h,083h,012h,001h,083h,031h,001h,083h,019h,001h,080h,009h,000h
db 000h,000h,000h,008h,000h,001h,000h,083h,014h,001h,083h,033h,001h,083h,01Bh,001h
db 080h,083h,020h,001h,083h,031h,001h,083h,014h,001h,080h,083h,01Bh,001h,083h,030h
db 001h,083h,020h,001h,080h,083h,014h,001h,083h,031h,001h,083h,01Bh,001h,080h,009h
db 000h,000h,000h,000h,008h,000h,001h,000h,083h,016h,001h,083h,030h,001h,083h,01Dh
db 001h,083h,031h,001h,083h,022h,001h,083h,035h,001h,083h,016h,001h,098h,00Ah,001h
db 083h,01Dh,001h,088h,00Ah,083h,022h,001h,081h,061h,083h,016h,001h,080h,083h,01Dh
db 001h,080h,009h,000h,000h,000h,000h,008h,000h,001h,000h,083h,016h,001h,080h,083h
db 01Dh,001h,080h,083h,022h,001h,080h,083h,016h,001h,080h,083h,018h,001h,080h,083h
db 01Dh,001h,080h,083h,011h,001h,080h,083h,018h,001h,080h,009h,000h,000h,000h,000h
db 008h,000h,001h,000h,083h,016h,001h,083h,030h,001h,083h,01Dh,001h,083h,031h,001h
db 083h,019h,001h,083h,02Eh,001h,083h,016h,001h,098h,00Ah,001h,083h,01Dh,001h,088h
db 00Ah,083h,019h,001h,081h,061h,083h,016h,001h,080h,083h,01Dh,001h,080h,0F1h,000h
db 000h,000h
xm_unused_001 LABEL BYTE
; The following 23 bytes are not used.
; So, let's place the MessageBox text and caption instead.
; UI text messages.
msg_txt db "uFMOD ruleZ!"
msg_txt_l equ $ - msg_txt
msg_cap db "MASM32",0
err_cap db ":-(",0
org xm_unused_001 + 23
db 001h,000h,012h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h,000h
db 000h,000h,000h,000h,000h,000h,000h,000h,040h,000h,008h,000h,02Ch,000h,00Eh,000h
db 008h,000h,018h,000h,016h,000h,020h,000h,008h,000h,02Dh,000h,00Dh,000h,032h,000h
db 004h,000h,03Ch,000h,007h,000h,044h,000h,004h,000h,05Ah,000h,000h,000h,064h,000h
db 000h,000h,06Eh,000h,000h,000h,000h,000h,020h,000h,00Ah,000h,028h,000h,01Eh,000h
db 018h,000h,032h,000h,020h,000h,03Ch,000h,020h,000h,046h,000h,020h,000h,050h,000h
db 020h,000h,05Ah,000h,020h,000h,064h,000h,020h,000h,06Eh,000h,020h,000h,078h,000h
db 020h,000h,082h,000h,020h,000h,009h,006h,001h,002h,004h,002h,003h,005h,001h,000h
db 000h,000h,000h,000h,080h,000h,00Ch,000h,000h,000h,000h,000h,000h,000h,00Ch,000h
db 000h,000h,040h,000h,001h,080h,0F9h,000h,0BFh,000h,0C3h,000h,00Ah,000h,057h,000h
db 06Eh,000h,023h,000h
; ----------------------------------------------------------
; void MessageBoxCB(szCap, lpString, cbString, cbProc);
; ----------------------------------------------------------
; This is similar to a Win32 MessageBox. The box is centered
; on screen. It contains a single-line text message and an
; "OK" button. This function returns when user closes the
; box (via the X button or via the OK button). An optional
; callback subroutine may be specified to be called when no
; events are pending in the event queue.
; NOTE: Doesn't work if you already have defined a window
; in the current process! Doesn't modify the event mask. So,
; make sure keyboard events are enabled before calling this
; function. This function doesn't check the validity of the
; supplied parameters!
; Parameters:
; szCap - A pointer to the ASCIIz string containing the
; caption. A trailing zero char IS required.
; lpString - A pointer to an ASCII string containing a single
; line message to pop up in the box. No trailing
; zero char is required.
; cbString - number of characters in string.
; cbProc - Address of the callback subroutine. Can be NULL.
sOK db "OK"
MessageBoxCB:
; EBP = 0
mov esi,[esp+12] ; cbString
mov edi,[esp+4] ; szCap
; Get screen metrics.
lea eax,[ebp+14]
int 40h
mov ecx,eax
movzx eax,ax
shr ecx,16 ; screen w
xchg eax,edx ; screen h
lea ebx,[esi*2+esi]
lea ebx,[ebx*2+28] ; w = string len * 6 + 28
sub ecx,ebx
shr ecx,1
shl ecx,16
or ebx,ecx
lea ecx,[ebp+52h] ; h = 52h
sub edx,ecx
shr edx,1
shl edx,16
or ecx,edx ; y = (screen h - window h) / 2
mov edx,ebx ; x = (screen w - window w) / 2
_MessageBoxCB_redraw:
; Start redraw.
push edx
lea eax,[ebp+12]
lea ebx,[ebp+1]
int 40h
; Define and draw window.
xor eax,eax
mov ebx,edx ; x, w (ECX: y, h)
mov edx,34C0C0C0h ; style and BG color
int 40h
; Define the OK button.
push esi
lea eax,[ebp+8]
sub ebx,28+0Ah
shr bx,1
shl ebx,16 ; x = (window w - button w) / 2
mov bx,18+0Ah ; w = 18 + 0Ah
mov ecx,001C0012h ; y = 1Ch, h = 12h
lea edx,[ebp+1] ; ID = close
mov esi,0C0C0C0h ; color
int 40h
; Draw the OK label.
lea eax,[ebp+4]
add ebx,90000h ; x = button x + 9
mov bx,22h ; y = 22h
xor ecx,ecx ; style, font and color
mov edx,OFFSET sOK ; string
lea esi,[ebp+2] ; length
int 40h
pop esi
; Draw text string.
lea eax,[ebp+4]
mov ebx,000A000Ah ; x = 0Ah, y = 0Ah
xor ecx,ecx ; style, font and color
mov edx,[esp+12] ; lpString
int 40h
; End redraw.
lea eax,[ebp+12]
lea ebx,[ebp+2]
int 40h
_MessageBoxCB_eventloop:
mov edx,[esp+20] ; cbProc
test edx,edx
lea eax,[ebp+10]
jz _MessageBoxCB_peekevent
; Invoke the callback.
call edx
lea eax,[ebp+23]
lea ebx,[ebp+10] ; wait for at most 0.1 sec
_MessageBoxCB_peekevent:
int 40h
dec eax
js _MessageBoxCB_eventloop
pop edx
jz _MessageBoxCB_redraw
ret
.DATA?
BSS_START LABEL BYTE
db 1020 dup (?)
STACK_B dd ? ; Stack bottom
BSS_END LABEL BYTE
END _START

View File

@ -0,0 +1,241 @@
; uFMOD header file
; Target OS: KolibriOS
; Compiler: MASM32
; HANDLE uFMOD_LoadSong(
; void *lpXM,
; void *param,
; int fdwSong
; )
; ---
; Description:
; ---
; Loads the given XM song and starts playing it as soon as you
; call uFMOD_WaveOut for the first time. Playback won't begin
; if XM_SUSPENDED flag is specified. It will stop any currently
; playing song before loading the new one.
; ---
; Parameters:
; ---
; lpXM
; Specifies the song to load. If this parameter is 0, any
; currently playing song is stopped. In such a case, function
; does not return a meaningful value. fdwSong parameter
; determines whether this value is interpreted as a filename
; or as a pointer to an image of the song in memory.
; param
; If XM_MEMORY is specified, this parameter should be the size
; of the image of the song in memory.
; If XM_FILE is specified, this parameter is ignored.
; fdwSong
; Flags for playing the song. The following values are defined:
; XM_FILE lpXM points to filename. param is ignored.
; XM_MEMORY lpXM points to an image of a song in memory.
; param is the image size. Once, uFMOD_LoadSong
; returns, it's safe to free/discard the memory
; buffer.
; XM_NOLOOP An XM track plays repeatedly by default. Specify
; this flag to play it only once.
; XM_SUSPENDED The XM track is loaded in a suspended state,
; and will not play until the uFMOD_Resume function
; is called. This is useful for preloading a song
; or testing an XM track for validity.
; ---
; Return Values:
; ---
; On success, returns the handle of the Infinity Sound driver.
; Returns 0 on failure.
uFMOD_LoadSong PROTO C :DWORD,:DWORD,:DWORD
; int uFMOD_WaveOut(void)
; ---
; Description:
; ---
; Updates the internal playback buffer.
; ---
; Remarks:
; ---
; This function should be called from the same thread
; uFMOD_LoadSong was previously called. Playback doesn't actually
; begin when calling uFMOD_LoadSong, but when calling uFMOD_WaveOut
; after a successful uFMOD_LoadSong call. Afterwards, you should
; call uFMOD_WaveOut repeatedly at least once every 250 ms to
; prevent "buffer underruns".
; uFMOD_WaveOut is a non-blocking function. The accuracy of the
; InfoAPI functions (uFMOD_GetStats, uFMOD_GetRowOrder and
; uFMOD_GetTime) depends on the periodicity of this function being
; invoked.
; ---
; Return Values:
; ---
; Returns non zero on error.
uFMOD_WaveOut PROTO C
; void uFMOD_StopSong(void)
; ---
; Description:
; ---
; Stops the currently playing song, freeing the associated
; resources.
; ---
; Remarks:
; ---
; Does nothing if no song is playing at the time the call is made.
uFMOD_StopSong PROTO C
; void uFMOD_Jump2Pattern(
; unsigned int pat
; )
; ---
; Description:
; ---
; Jumps to the specified pattern index.
; ---
; Parameters:
; ---
; pat
; Next zero based pattern index.
; ---
; Remarks:
; ---
; uFMOD doesn't automatically perform Note Off effects before jumping
; to the target pattern. In other words, the original pattern will
; remain in the mixer until it fades out. You can use this feature to
; your advantage. If you don't like it, just insert leading Note Off
; commands in all patterns intended to be used as uFMOD_Jump2Pattern
; targets.
; if the pattern index lays outside of the bounds of the pattern order
; table, calling this function jumps to pattern 0, effectively
; rewinding playback.
uFMOD_Jump2Pattern PROTO C :DWORD
; void uFMOD_Pause(void)
; ---
; Description:
; ---
; Pauses the currently playing song, if any.
; ---
; Remarks:
; ---
; While paused you can still control the volume (uFMOD_SetVolume) and
; the pattern order (uFMOD_Jump2Pattern). The RMS volume coefficients
; (uFMOD_GetStats) will go down to 0 and the progress tracker
; (uFMOD_GetTime) will "freeze" while the song is paused.
; uFMOD_Pause doesn't perform the request immediately. Instead, it
; signals to pause when playback reaches next chunk of data.
; This way, uFMOD_Pause performs asynchronously and returns very fast.
; It is not cumulative. So, calling uFMOD_Pause many times in a row
; has the same effect as calling it once.
; You shouldn't stop calling uFMOD_WaveOut while the song is paused!
uFMOD_Pause PROTO C
; void uFMOD_Resume(void)
; ---
; Description:
; ---
; Resumes the currently paused song, if any.
; ---
; Remarks:
; ---
; uFMOD_Resume doesn't perform the request immediately. Instead, it
; signals to resume when uFMOD_WaveOut is called again. uFMOD_Resume
; is not cumulative. So, calling it many times in a row has the same
; effect as calling it once.
uFMOD_Resume PROTO C
; unsigned int uFMOD_GetStats(void)
; ---
; Description:
; ---
; Returns the current RMS volume coefficients in (L)eft and (R)ight
; channels.
; low-order word: RMS volume in R channel
; hi-order word: RMS volume in L channel
; Range from 0 (silence) to $7FFF (maximum) on each channel.
; ---
; Remarks:
; ---
; This function is useful for updating a VU meter. It's recommended
; to rescale the output to log10 (decibels or dB for short), because
; human ears track volume changes in a dB scale. You may call
; uFMOD_GetStats() as often as you like, but take in mind that uFMOD
; updates both channel RMS volumes at the same rate uFMOD_WaveOut
; function is called. In other words, you should call uFMOD_WaveOut
; more often to increase the accuracy of uFMOD_GetStats.
uFMOD_GetStats PROTO C
; unsigned int uFMOD_GetRowOrder(void)
; ---
; Description:
; ---
; Returns the currently playing row and order.
; low-order word: row
; hi-order word: order
; ---
; Remarks:
; ---
; This function is useful for synchronization. uFMOD updates both
; row and order values at the same rate uFMOD_WaveOut function is
; called. In other words, you should call uFMOD_WaveOut more often
; to increase the accuracy of uFMOD_GetRowOrder.
uFMOD_GetRowOrder PROTO C
; unsigned int uFMOD_GetTime(void)
; ---
; Description:
; ---
; Returns the time in milliseconds since the song was started.
; ---
; Remarks:
; ---
; This function is useful for synchronizing purposes. Multimedia
; applications can use uFMOD_GetTime to synchronize GFX to sound,
; for example. An XM player can use this function to update a progress
; meter.
uFMOD_GetTime PROTO C
; unsigned char* uFMOD_GetTitle(void)
; ---
; Description:
; ---
; Returns the current song's title.
; ---
; Remarks:
; ---
; Not every song has a title, so be prepared to get an empty string.
uFMOD_GetTitle PROTO C
; void uFMOD_SetVolume(
; unsigned int vol
; )
; ---
; Description:
; ---
; Sets the global volume. The volume scale is linear.
; ---
; Parameters:
; ---
; vol
; New volume. Range: from uFMOD_MIN_VOL (muting) to uFMOD_MAX_VOL
; (maximum volume). Any value above uFMOD_MAX_VOL maps to maximum
; volume.
; ---
; Remarks:
; ---
; uFMOD internally converts the given values to a logarithmic scale (dB).
; Maximum volume is set by default. The volume value is preserved across
; uFMOD_LoadSong calls. You can set the desired volume level before
; actually starting to play a song.
; You can use Infinity Sound API to control the L and R channels volumes
; separately. It also has a wider range than uFMOD_SetVolume, sometimes
; allowing to amplify the sound volume as well, as opposed to
; uFMOD_SetVolume only being able to attenuate it.
uFMOD_SetVolume PROTO C :DWORD
XM_MEMORY EQU 1
XM_FILE EQU 2
XM_NOLOOP EQU 8
XM_SUSPENDED EQU 16
uFMOD_MIN_VOL EQU 0
uFMOD_MAX_VOL EQU 25
uFMOD_DEFAULT_VOL EQU 25

Binary file not shown.

View File

@ -0,0 +1,18 @@
@echo off
rem Compiler: NASM
rem Target OS: KolibriOS
rem NASM Path:
SET UF_NASM=\nasm
if not exist "%UF_NASM%\nasmw.exe" goto Err1
"%UF_NASM%\nasmw" -fbin -t -O5 -i..\ufmodlib\src\ mini.asm
goto TheEnd
:Err1
echo Couldn't find nasmw.exe in %UF_NASM%\
:TheEnd
pause
@echo on
cls

View File

@ -0,0 +1,225 @@
; MINI.ASM
; --------
; Minimalistic uFMOD usage example.
; Shows how to play an XM track in memory,
; including proper error handling.
BITS 32
org 0
db "MENUET01"
dd 1
dd START ; Entry point
dd uFMOD_IMG_END ; End of code and initialized data
dd MEMORY_END ; End of uninitialized (BSS) data
dd STACK_B ; Bottom of the stack
dd 0 ; Args
dd 0 ; Reserved
; uFMOD setup:
%define f48000 ; Set sampling rate to 48KHz (22050, 44100, 48000)
%define STRONG ; Select STRONG interpolation (NONE, WEAK, STRONG)
%define UNSAFE ; Select UNSAFE mode (NORMAL, UNSAFE)
%define NODEBUG ; Skip debug-board messages
%define NOLINKER ; Select "no linker" mode
; uFMOD constants:
%define uFMOD_MIN_VOL 0
%define uFMOD_MAX_VOL 25
%define uFMOD_DEFAULT_VOL 25
; The XM track.
xm incbin "..\ufmodlib\media\mini.xm"
xm_length equ $ - xm
; Optimization:
; This header file is suitable for mini.xm track only!
; If you change the track, update the optimization header.
; (Use the standart eff.inc file for a general purpose player app.)
%include "..\ufmodlib\media\mini.eff.inc"
; UI text messages.
msg_txt db "uFMOD ruleZ!"
msg_txt_l equ $ - msg_txt
msg_cap db "NASM",0
err_txt db "Error"
err_txt_l equ $ - err_txt
err_cap db ":-(",0
START:
; Start playback.
push XM_MEMORY
push xm_length
push xm
call _uFMOD_LoadSong
; Stack fixing is required here, but in this simple
; example leaving ESP as it is won't harm. In a real
; application you should uncomment the following line:
; add esp,12
test eax,eax
jz error
; Wait for user input.
push _uFMOD_WaveOut ; cbProc <- continue fetching data!
push msg_txt_l ; cbString
push msg_txt ; lpString
push msg_cap ; szCap
call _MessageBoxCB
; add esp,16
; Stop playback.
call _uFMOD_StopSong
r: ; Exit.
xor eax,eax
dec eax
int 40h
error:
push 0 ; cbProc <- no callback
push err_txt_l ; cbString
push err_txt ; lpString
push err_cap ; szCap
call _MessageBoxCB
; add esp,16
jmp r
; ---------------------------------------------------------------
; void _cdecl _MessageBoxCB(szCap, lpString, cbString, cbProc);
; ---------------------------------------------------------------
; This is similar to a Win32 MessageBox. The box is centered
; on screen. It contains a single-line text message and an
; "OK" button. This function returns when user closes the
; box (via the X button or via the OK button). An optional
; callback subroutine may be specified to be called when no
; events are pending in the event queue.
; NOTE: Doesn't work if you already have defined a window
; in the current process! Doesn't modify the event mask. So,
; make sure keyboard events are enabled before calling this
; function. This function doesn't check the validity of the
; supplied parameters!
; Parameters:
; szCap - A pointer to the ASCIIz string containing the
; caption. A trailing zero char IS required.
; lpString - A pointer to an ASCII string containing a single
; line message to pop up in the box. No trailing
; zero char is required.
; cbString - number of characters in string.
; cbProc - Address of the callback subroutine. Can be NULL.
sOK db "OK"
_MessageBoxCB:
push ebp
push esi
push edi
push ebx
xor ebp,ebp ; global 0
mov esi,[esp+28] ; cbString
mov edi,[esp+20] ; szCap
; Get screen metrics.
lea eax,[ebp+14]
int 40h
mov ecx,eax
movzx eax,ax
shr ecx,16 ; screen w
xchg eax,edx ; screen h
lea ebx,[esi*2+esi]
lea ebx,[ebx*2+28] ; w = string len * 6 + 28
sub ecx,ebx
shr ecx,1
shl ecx,16
or ebx,ecx
lea ecx,[ebp+52h] ; h = 52h
sub edx,ecx
shr edx,1
shl edx,16
or ecx,edx ; y = (screen h - window h) / 2
mov edx,ebx ; x = (screen w - window w) / 2
_MessageBoxCB_redraw:
; Start redraw.
push edx
lea eax,[ebp+12]
lea ebx,[ebp+1]
int 40h
; Define and draw window.
xor eax,eax
mov ebx,edx ; x, w (ECX: y, h)
mov edx,34C0C0C0h ; style and BG color
int 40h
; Define the OK button.
push esi
lea eax,[ebp+8]
sub ebx,28+0Ah
shr bx,1
shl ebx,16 ; x = (window w - button w) / 2
mov bx,18+0Ah ; w = 18 + 0Ah
mov ecx,001C0012h ; y = 1Ch, h = 12h
lea edx,[ebp+1] ; ID = close
mov esi,0C0C0C0h ; color
int 40h
; Draw the OK label.
lea eax,[ebp+4]
add ebx,90000h ; x = button x + 9
mov bx,22h ; y = 22h
xor ecx,ecx ; style, font and color
mov edx,sOK ; string
lea esi,[ebp+2] ; length
int 40h
pop esi
; Draw text string.
lea eax,[ebp+4]
mov ebx,000A000Ah ; x = 0Ah, y = 0Ah
xor ecx,ecx ; style, font and color
mov edx,[esp+28] ; lpString
int 40h
; End redraw.
lea eax,[ebp+12]
lea ebx,[ebp+2]
int 40h
_MessageBoxCB_eventloop:
mov edx,[esp+36] ; cbProc
test edx,edx
lea eax,[ebp+10]
jz _MessageBoxCB_peekevent
; Invoke the callback.
call edx
lea eax,[ebp+23]
lea ebx,[ebp+10] ; wait for at most 0.1 sec
_MessageBoxCB_peekevent:
int 40h
dec eax
js _MessageBoxCB_eventloop
pop edx
jz _MessageBoxCB_redraw
pop ebx
pop edi
pop esi
pop ebp
ret
; Include the whole uFMOD sources here. (Right after
; your main code to avoid naming conflicts, but still
; inside your code section.)
%include "nasm.asm"
alignb 4
resb 1020
STACK_B resd 1 ; Stack bottom
MEMORY_END: ; End of uninitialized (BSS) data

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,60 @@
; XM-file: full.xm
; uFMOD optional features:
INFO_API_ON equ 1 ; enable InfoAPI
NOLOOP_ON equ 1 ; enable XM_NOLOOP
PAUSE_RESUME_ON equ 1 ; enable pause/resume and XM_SUSPENDED
VOL_CONTROL_ON equ 1 ; enable volume control
JUMP_TO_PAT_ON equ 1 ; enable Jump2Pattern
XM_FILE_ON equ 1 ; enable file loading
; Special flags:
INSTRUMENTVIBRATO_ON equ 1
VOLUMEENVELOPE_ON equ 1
PANENVELOPE_ON equ 1
VOLUMEBYTE_ON equ 1
ADPCM_ON equ 1
AMIGAPERIODS_ON equ 1
; XM effects:
ARPEGGIO_ON equ 1
PORTAUP_ON equ 1
PORTADOWN_ON equ 1
PORTATO_ON equ 1
VIBRATO_ON equ 1
PORTATOVOLSLIDE_ON equ 1
VIBRATOVOLSLIDE_ON equ 1
TREMOLO_ON equ 1
SETPANPOSITION_ON equ 1
SETSAMPLEOFFSET_ON equ 1
VOLUMESLIDE_ON equ 1
PATTERNJUMP_ON equ 1
SETVOLUME_ON equ 1
PATTERNBREAK_ON equ 1
SETSPEED_ON equ 1
SETGLOBALVOLUME_ON equ 1
GLOBALVOLSLIDE_ON equ 1
KEYOFF_ON equ 1
SETENVELOPEPOS_ON equ 1
PANSLIDE_ON equ 1
MULTIRETRIG_ON equ 1
TREMOR_ON equ 1
EXTRAFINEPORTA_ON equ 1
FINEPORTAUP_ON equ 1
FINEPORTADOWN_ON equ 1
SETVIBRATOWAVE_ON equ 1
SETFINETUNE_ON equ 1
PATTERNLOOP_ON equ 1
SETTREMOLOWAVE_ON equ 1
SETPANPOSITION16_ON equ 1
RETRIG_ON equ 1
NOTECUT_ON equ 1
NOTEDELAY_ON equ 1
PATTERNDELAY_ON equ 1
PORTAUP_OR_DOWN_ON equ 1
VIBRATO_OR_VOLSLIDE equ 1
VIBRATO_OR_TREMOLO equ 1
PORTATO_OR_VOLSLIDE equ 1
VOLUME_OR_PANENVELOPE equ 1
ROWCOMMANDS_ON equ 1
FINEVOLUMESLIDE_ON equ 1

View File

@ -0,0 +1,342 @@
; FASM.ASM
; --------
; uFMOD public source code release. Provided as-is.
; *** This stub allows compiling uFMOD sources using FASM.
; *** CONSTANTS ***
if UF_FREQ eq 44100
FSOUND_MixRate = 44100
FREQ_40HZ_p = 1DB8Bh
FREQ_40HZ_f = 3B7160h
PCM_format = 3 ; PCM_2_16_44
else
if UF_FREQ eq 22050
FSOUND_MixRate = 22050
FREQ_40HZ_p = 3B716h
FREQ_40HZ_f = 76E2C0h
PCM_format = 9 ; PCM_2_16_22
else
if UF_FREQ eq 48000
else
display 'UF_FREQ not specified (defaulting to 48KHz)',13,10
end if
FSOUND_MixRate = 48000
FREQ_40HZ_p = 1B4E8h
FREQ_40HZ_f = 369D00h
PCM_format = 1 ; PCM_2_16_48
end if
end if
if UF_RAMP eq NONE
RAMP_NONE = 1
RAMP_WEAK = 0
RAMP_STRONG = 0
else
if UF_RAMP eq WEAK
RAMP_NONE = 0
RAMP_WEAK = 1
RAMP_STRONG = 0
else
if UF_RAMP eq STRONG
else
display 'UF_RAMP not specified (defaulting to STRONG)',13,10
end if
RAMP_NONE = 0
RAMP_WEAK = 0
RAMP_STRONG = 1
end if
end if
UCODE equ 0
if UF_MODE eq UNSAFE
display 'WARNING! Unsafe mod is ON. Library may crash while loading damaged XM tracks!',13,10
CHK4VALIDITY = 0
AC97SND_ON = 0
else
CHK4VALIDITY = 1
if UF_MODE eq AC97SND
AC97SND_ON = 1
else
AC97SND_ON = 0
end if
end if
if NOLINKER
else
format MS COFF
section '.text' code readable executable
end if
; *** STRUCTS ***
; Sample type - contains info on sample
struc FSOUND_SAMPLE{
; Don't change order .:.
._length dd ? ; sample length
.loopstart dd ? ; loop start
.looplen dd ? ; loop length
.defvol db ? ; default volume
.finetune db ? ; finetune value from -128 to 127
.bytes db ? ; type [b 0-1] : 0 - no loop
; 1 - forward loop
; 2 - bidirectional loop (aka ping-pong)
; [b 4] : 0 - 8-bit sample data
; 1 - 16-bit sample data
.defpan db ? ; default pan value from 0 to 255
.relative db ? ; relative note (signed value)
.Resved db ? ; reserved, known values: 00h - regular delta packed sample data
; ADh - ModPlug 4-bit ADPCM packed sample data
; .:.
.loopmode db ?
._align db ?
.buff db ?,? ; sound data
}
virtual at 0
FSOUND_SAMPLE FSOUND_SAMPLE
FSOUND_SAMPLE_size = $-FSOUND_SAMPLE
end virtual
; Channel type - contains information on a mixing channel
struc FSOUND_CHANNEL{
.actualvolume dd ? ; driver level current volume
.actualpan dd ? ; driver level panning value
.fsampleoffset dd ? ; sample offset (sample starts playing from here)
.leftvolume dd ? ; mixing information. adjusted volume for left channel (panning involved)
.rightvolume dd ? ; mixing information. adjusted volume for right channel (panning involved)
.mixpos dd ? ; mixing information. high part of 32:32 fractional position in sample
.speedlo dd ? ; mixing information. playback rate - low part fractional
.speedhi dd ? ; mixing information. playback rate - high part fractional
.ramp_lefttarget dw ?
.ramp_righttarget dw ?
.ramp_leftspeed dd ?
.ramp_rightspeed dd ?
; Don't change order .:.
.fsptr dd ? ; pointer to FSOUND_SAMPLE currently playing sample
.mixposlo dd ? ; mixing information. low part of 32:32 fractional position in sample
.ramp_leftvolume dd ?
.ramp_rightvolume dd ?
.ramp_count dw ?
.speeddir db ?,? ; mixing information. playback direction - forwards or backwards
; .:.
}
virtual at 0
FSOUND_CHANNEL FSOUND_CHANNEL
FSOUND_CHANNEL_size = $-FSOUND_CHANNEL
end virtual
; Single note type - contains info on 1 note in a pattern
struc FMUSIC_NOTE{
.unote db ? ; note to play at (0-97) 97=keyoff
.number db ? ; sample being played (0-128)
.uvolume db ? ; volume column value (0-64) 255=no volume
.effect db ? ; effect number (0-1Ah)
.eparam db ? ; effect parameter (0-255)
}
virtual at 0
FMUSIC_NOTE FMUSIC_NOTE
FMUSIC_NOTE_size = $-FMUSIC_NOTE
end virtual
; Pattern data type
struc FMUSIC_PATTERN{
.rows dw ?
.patternsize dw ?
.data dd ? ; pointer to FMUSIC_NOTE
}
virtual at 0
FMUSIC_PATTERN FMUSIC_PATTERN
FMUSIC_PATTERN_size = $-FMUSIC_PATTERN
end virtual
; Multi sample extended instrument
struc FMUSIC_INSTRUMENT{
.sample rd 16 ; 16 pointers to FSOUND_SAMPLE per instrument
; Don't change order .:.
.keymap rb 96 ; sample keymap assignments
.VOLPoints rw 24 ; volume envelope points
.PANPoints rw 24 ; panning envelope points
.VOLnumpoints db ? ; number of volume envelope points
.PANnumpoints db ? ; number of panning envelope points
.VOLsustain db ? ; volume sustain point
.VOLLoopStart db ? ; volume envelope loop start
.VOLLoopEnd db ? ; volume envelope loop end
.PANsustain db ? ; panning sustain point
.PANLoopStart db ? ; panning envelope loop start
.PANLoopEnd db ? ; panning envelope loop end
.VOLtype db ? ; type of envelope,bit 0:On 1:Sustain 2:Loop
.PANtype db ? ; type of envelope,bit 0:On 1:Sustain 2:Loop
.VIBtype db ? ; instrument vibrato type
.VIBsweep db ? ; time it takes for vibrato to fully kick in
.iVIBdepth db ? ; depth of vibrato
.VIBrate db ? ; rate of vibrato
.VOLfade dw ? ; fade out value
; .:.
}
virtual at 0
FMUSIC_INSTRUMENT FMUSIC_INSTRUMENT
FMUSIC_INSTRUMENT_size = $-FMUSIC_INSTRUMENT
end virtual
; Channel type - contains information on a mod channel
struc FMUSIC_CHANNEL{
.note db ? ; last note set in channel
.samp db ? ; last sample set in channel
.notectrl db ? ; flags for DoFlags proc
.inst db ? ; last instrument set in channel
.cptr dd ? ; pointer to FSOUND_CHANNEL system mixing channel
.freq dd ? ; current mod frequency period for this channel
.volume dd ? ; current mod volume for this channel
.voldelta dd ? ; delta for volume commands... tremolo/tremor, etc
.freqdelta dd ? ; delta for frequency commands... vibrato/arpeggio, etc
.pan dd ? ; current mod pan for this channel
; Don't change order .:.
.envvoltick dd ? ; tick counter for envelope position
.envvolpos dd ? ; envelope position
.envvoldelta dd ? ; delta step between points
.envpantick dd ? ; tick counter for envelope position
.envpanpos dd ? ; envelope position
.envpandelta dd ? ; delta step between points
.ivibsweeppos dd ? ; instrument vibrato sweep position
.ivibpos dd ? ; instrument vibrato position
.keyoff db ?,? ; flag whether keyoff has been hit or not
.envvolstopped db ? ; flag to say whether envelope has finished or not
.envpanstopped db ? ; flag to say whether envelope has finished or not
; .:.
.envvolfrac dd ? ; fractional interpolated envelope volume
.envvol dd ? ; final interpolated envelope volume
.fadeoutvol dd ? ; volume fade out
.envpanfrac dd ? ; fractional interpolated envelope pan
.envpan dd ? ; final interpolated envelope pan
.period dd ? ; last period set in channel
.sampleoffset dd ? ; sample offset for this channel in SAMPLES
.portatarget dd ? ; note to porta to
.patloopno db ?,?,?,? ; pattern loop variables for effect E6x
.patlooprow dd ?
.realnote db ? ; last realnote set in channel
.recenteffect db ? ; previous row's effect... used to correct tremolo volume
.portaupdown db ? ; last porta up/down value
db ? ; unused
.xtraportadown db ? ; last porta down value
.xtraportaup db ? ; last porta up value
.volslide db ? ; last volume slide value
.panslide db ? ; pan slide parameter
.retrigx db ? ; last retrig volume slide used
.retrigy db ? ; last retrig tick count used
.portaspeed db ? ; porta speed
.vibpos db ? ; vibrato position
.vibspeed db ? ; vibrato speed
.vibdepth db ? ; vibrato depth
.tremolopos db ? ; tremolo position
.tremolospeed db ? ; tremolo speed
.tremolodepth db ? ; tremolo depth
.tremorpos db ? ; tremor position
.tremoron db ? ; remembered parameters for tremor
.tremoroff db ? ; remembered parameters for tremor
.wavecontrol db ? ; waveform type for vibrato and tremolo (4bits each)
.finevslup db ? ; parameter for fine volume slide down
.fineportaup db ? ; parameter for fine porta slide up
.fineportadown db ? ; parameter for fine porta slide down
}
virtual at 0
FMUSIC_CHANNEL FMUSIC_CHANNEL
FMUSIC_CHANNEL_size = $-FMUSIC_CHANNEL
end virtual
; Song type - contains info on song
struc FMUSIC_MODULE{
; Don't change order .:.
.pattern dd ? ; pointer to FMUSIC_PATTERN array for this song
.instrument dd ? ; pointer to FMUSIC_INSTRUMENT array for this song
.mixer_samplesleft dd ?
.globalvolume dd ? ; global mod volume
.tick dd ? ; current mod tick
.speed dd ? ; speed of song in ticks per row
.order dd ? ; current song order position
.row dd ? ; current row in pattern
.patterndelay dd ? ; pattern delay counter
.nextorder dd ? ; current song order position
.nextrow dd ? ; current row in pattern
.unused1 dd ?
.numchannels dd ? ; number of channels
.Channels dd ? ; channel pool
.uFMOD_Ch dd ? ; channel array for this song
.mixer_samplespertick dd ?
.numorders dw ? ; number of orders (song length)
.restart dw ? ; restart position
.numchannels_xm db ?
.globalvsl db ? ; global mod volume
.numpatternsmem dw ? ; number of allocated patterns
.numinsts dw ? ; number of instruments
.flags dw ? ; flags such as linear frequency, format specific quirks, etc
.defaultspeed dw ?
.defaultbpm dw ?
.orderlist rb 256 ; pattern playing order list
; .:.
}
virtual at 0
FMUSIC_MODULE FMUSIC_MODULE
FMUSIC_MODULE_size = $-FMUSIC_MODULE
end virtual
OFFSET equ
PTR equ
endif equ end if
include 'ufmod.asm'
include 'core.asm'
if NOLINKER
uFMOD_IMG_END: ; End of uFMOD's code. BSS follows.
align 16
else
section '.bss' readable writeable align 16
end if
; Don't change order!
_mod rb FMUSIC_MODULE_size ; currently playing track
mmt rd 3
ufmod_heap dd ?
dd ? ; unused
if AC97SND_ON
extrn hSound
dd ?
else
hSound dd ?
endif
hBuff dd ?
SW_Exit dd ?
; mix buffer memory block (align 16!)
MixBuf rb FSOUND_BlockSize*8
ufmod_noloop db ?
ufmod_pause_ db ?
mix_endflag rb 2
mmf rd 4
ufmod_vol dd ? ; global volume scale
; * LPCALLBACKS *
uFMOD_fopen dd ?
uFMOD_fread dd ?
file_struct rd 7
cache_offset dd ?
if INFO_API_ON
time_ms dd ?
L_vol dw ? ; L channel RMS volume
R_vol dw ? ; R channel RMS volume
s_row dw ?
s_order dw ?
szTtl rb 24
end if
DummySamp rb FSOUND_SAMPLE_size

View File

@ -0,0 +1,68 @@
@echo off
rem Make the uFMOD libraries in COFF object format
rem Target OS: KolibriOS
rem *** CONFIG START
rem *** Check the Readme docs for a complete reference
rem *** on configuring the following options
rem Pathes:
SET UF_MASM=\masm32\bin
SET UF_NASM=\nasm
SET UF_FASM=\fasm
rem Select compiler: MASM, NASM or FASM
SET UF_ASM=FASM
rem Select mixing rate: 22050, 44100 or 48000 (22.05 KHz, 44.1 KHz or 48 KHz)
SET UF_FREQ=48000
rem Set volume ramping mode (interpolation): NONE, WEAK or STRONG
SET UF_RAMP=STRONG
rem Set build mode: NORMAL, UNSAFE or AC97SND
SET UF_MODE=NORMAL
rem *** CONFIG END
if %UF_ASM%==MASM goto MASM
if %UF_ASM%==NASM goto NASM
if %UF_ASM%==FASM goto FASM
echo %UF_ASM% not supported
goto TheEnd
:MASM
if not exist "%UF_MASM%\ml.exe" goto Err1
"%UF_MASM%\ml" /c /coff /nologo /Df%UF_FREQ% /D%UF_RAMP% /D%UF_MODE% /Fo ufmod.obj src\masm.asm
goto TheEnd
:NASM
if not exist "%UF_NASM%\nasmw.exe" goto Err2
"%UF_NASM%\nasmw" -O4 -t -fwin32 -dNODEBUG -df%UF_FREQ% -d%UF_RAMP% -d%UF_MODE% -isrc\ -oufmod.obj src\nasm.asm
goto TheEnd
:FASM
if not exist "%UF_FASM%\fasm.exe" goto Err3
echo UF_FREQ equ %UF_FREQ% >tmp.asm
echo UF_RAMP equ %UF_RAMP% >>tmp.asm
echo UF_MODE equ %UF_MODE% >>tmp.asm
echo DEBUG equ 0 >>tmp.asm
echo NOLINKER equ 0 >>tmp.asm
echo include 'src\eff.inc' >>tmp.asm
echo include 'src\fasm.asm' >>tmp.asm
"%UF_FASM%\fasm" tmp.asm ufmod.obj
del tmp.asm
goto TheEnd
:Err1
echo Couldn't find ml.exe in %UF_MASM%\
goto TheEnd
:Err2
echo Couldn't find nasmw.exe in %UF_NASM%\
goto TheEnd
:Err3
echo Couldn't find fasm.exe in %UF_FASM%\
:TheEnd
pause
@echo on
cls

View File

@ -0,0 +1,270 @@
; MASM.ASM
; --------
; uFMOD public source code release. Provided as-is.
; *** This stub allows compiling uFMOD sources using MASM32.
.386
.model flat
ifdef f44100
FSOUND_MixRate = 44100
FREQ_40HZ_p = 1DB8Bh
FREQ_40HZ_f = 3B7160h
PCM_format = 3
else
ifdef f22050
FSOUND_MixRate = 22050
FREQ_40HZ_p = 3B716h
FREQ_40HZ_f = 76E2C0h
PCM_format = 9
else
ifndef f48000
echo UF_FREQ not specified (defaulting to 48KHz)
endif
FSOUND_MixRate = 48000
FREQ_40HZ_p = 1B4E8h
FREQ_40HZ_f = 369D00h
PCM_format = 1
endif
endif
RAMP_NONE = 0
RAMP_WEAK = 0
RAMP_STRONG = 0
ifdef NONE
RAMP_NONE = 1
else
ifdef WEAK
RAMP_WEAK = 1
else
ifndef STRONG
echo UF_RAMP not specified (defaulting to STRONG)
endif
RAMP_STRONG = 1
endif
endif
UCODE = 0
DEBUG = 0
CHK4VALIDITY = 1
ifdef UNSAFE
echo WARNING! Unsafe mod is ON. Library may crash while loading damaged XM tracks!
CHK4VALIDITY = 0
endif
AC97SND_ON = 0
ifdef AC97SND
AC97SND_ON = 1
endif
include eff.inc
FSOUND_SAMPLE STRUC
_length dd ?
loopstart dd ?
looplen dd ?
defvol db ?
finetune db ?
bytes db ?
defpan db ?
relative db ?
Resved db ?
loopmode db ?
_align db ?
buff db ?,?
FSOUND_SAMPLE ENDS
FSOUND_CHANNEL STRUC
actualvolume dd ?
actualpan dd ?
fsampleoffset dd ?
leftvolume dd ?
rightvolume dd ?
mixpos dd ?
speedlo dd ?
speedhi dd ?
ramp_lefttarget dw ?
ramp_righttarget dw ?
ramp_leftspeed dd ?
ramp_rightspeed dd ?
fsptr dd ?
mixposlo dd ?
ramp_leftvolume dd ?
ramp_rightvolume dd ?
ramp_count dw ?
speeddir db ?,?
FSOUND_CHANNEL ENDS
FMUSIC_NOTE STRUC
unote db ?
number db ?
uvolume db ?
effect db ?
eparam db ?
FMUSIC_NOTE ENDS
FMUSIC_PATTERN STRUC
rows dw ?
patternsize dw ?
data dd ?
FMUSIC_PATTERN ENDS
FMUSIC_INSTRUMENT STRUC
sample dd 16 dup (?)
keymap db 96 dup (?)
VOLPoints dw 24 dup (?)
PANPoints dw 24 dup (?)
VOLnumpoints db ?
PANnumpoints db ?
VOLsustain db ?
VOLLoopStart db ?
VOLLoopEnd db ?
PANsustain db ?
PANLoopStart db ?
PANLoopEnd db ?
VOLtype db ?
PANtype db ?
VIBtype db ?
VIBsweep db ?
iVIBdepth db ?
VIBrate db ?
VOLfade dw ?
FMUSIC_INSTRUMENT ENDS
FMUSIC_CHANNEL STRUC
note db ?
samp db ?
notectrl db ?
inst db ?
cptr dd ?
freq dd ?
volume dd ?
voldelta dd ?
freqdelta dd ?
pan dd ?
envvoltick dd ?
envvolpos dd ?
envvoldelta dd ?
envpantick dd ?
envpanpos dd ?
envpandelta dd ?
ivibsweeppos dd ?
ivibpos dd ?
keyoff db ?,?
envvolstopped db ?
envpanstopped db ?
envvolfrac dd ?
envvol dd ?
fadeoutvol dd ?
envpanfrac dd ?
envpan dd ?
period dd ?
sampleoffset dd ?
portatarget dd ?
patloopno db ?,?,?,?
patlooprow dd ?
realnote db ?
recenteffect db ?
portaupdown db ?
db ?
xtraportadown db ?
xtraportaup db ?
volslide db ?
panslide db ?
retrigx db ?
retrigy db ?
portaspeed db ?
vibpos db ?
vibspeed db ?
vibdepth db ?
tremolopos db ?
tremolospeed db ?
tremolodepth db ?
tremorpos db ?
tremoron db ?
tremoroff db ?
wavecontrol db ?
finevslup db ?
fineportaup db ?
fineportadown db ?
FMUSIC_CHANNEL ENDS
FMUSIC_MODULE STRUC
pattern dd ?
instrument dd ?
mixer_samplesleft dd ?
globalvolume dd ?
tick dd ?
speed dd ?
order dd ?
row dd ?
patterndelay dd ?
nextorder dd ?
nextrow dd ?
unused1 dd ?
numchannels dd ?
Channels dd ?
uFMOD_Ch dd ?
mixer_samplespertick dd ?
numorders dw ?
restart dw ?
numchannels_xm db ?
globalvsl db ?
numpatternsmem dw ?
numinsts dw ?
flags dw ?
defaultspeed dw ?
defaultbpm dw ?
orderlist db 256 dup (?)
FMUSIC_MODULE ENDS
FMUSIC_MODULE_size = SIZE FMUSIC_MODULE
FSOUND_CHANNEL_size = SIZE FSOUND_CHANNEL
FMUSIC_CHANNEL_size = SIZE FMUSIC_CHANNEL
FMUSIC_INSTRUMENT_size = SIZE FMUSIC_INSTRUMENT
FMUSIC_PATTERN_size = SIZE FMUSIC_PATTERN
FMUSIC_NOTE_size = SIZE FMUSIC_NOTE
; FPU register stack
st0 TEXTEQU <st(0)>
st1 TEXTEQU <st(1)>
.CODE
include ufmod.asm
include core.asm
.DATA?
_mod = $
FMUSIC_MODULE<>
mmt dd ?,?,?
ufmod_heap dd ?,?
if AC97SND_ON
EXTERN hSound:DWORD
dd ?
else
hSound dd ?
endif
hBuff dd ?
SW_Exit dd ?
MixBuf db FSOUND_BlockSize*8 dup (?)
ufmod_noloop db ?
ufmod_pause_ db ?
mix_endflag db ?,?
mmf dd ?,?,?,?
ufmod_vol dd ?
uFMOD_fopen dd ?
uFMOD_fread dd ?
file_struct dd 7 dup (?)
cache_offset dd ?
if INFO_API_ON
time_ms dd ?
L_vol dw ?
R_vol dw ?
s_row dw ?
s_order dw ?
szTtl db 24 dup (?)
endif
DummySamp FSOUND_SAMPLE<>
end

Binary file not shown.

View File

@ -0,0 +1,60 @@
; XM-file: BLITZXMK.XM
; uFMOD optional features:
INFO_API_ON equ 0 ; disable InfoAPI
NOLOOP_ON equ 0 ; disable XM_NOLOOP
PAUSE_RESUME_ON equ 1 ; enable pause/resume and XM_SUSPENDED
VOL_CONTROL_ON equ 0 ; disable volume control
JUMP_TO_PAT_ON equ 1 ; enable Jump2Pattern
XM_FILE_ON equ 0 ; disable file loading
; Special flags:
INSTRUMENTVIBRATO_ON equ 1
VOLUMEENVELOPE_ON equ 1
PANENVELOPE_ON equ 0
VOLUMEBYTE_ON equ 1
ADPCM_ON equ 0
AMIGAPERIODS_ON equ 0
; XM effects:
ARPEGGIO_ON equ 0
PORTAUP_ON equ 0
PORTADOWN_ON equ 0
PORTATO_ON equ 1
VIBRATO_ON equ 1
PORTATOVOLSLIDE_ON equ 0
VIBRATOVOLSLIDE_ON equ 0
TREMOLO_ON equ 0
SETPANPOSITION_ON equ 0
SETSAMPLEOFFSET_ON equ 0
VOLUMESLIDE_ON equ 0
PATTERNJUMP_ON equ 1
SETVOLUME_ON equ 0
PATTERNBREAK_ON equ 0
SETSPEED_ON equ 1
SETGLOBALVOLUME_ON equ 0
GLOBALVOLSLIDE_ON equ 0
KEYOFF_ON equ 0
SETENVELOPEPOS_ON equ 0
PANSLIDE_ON equ 0
MULTIRETRIG_ON equ 0
TREMOR_ON equ 0
EXTRAFINEPORTA_ON equ 0
FINEPORTAUP_ON equ 0
FINEPORTADOWN_ON equ 0
SETVIBRATOWAVE_ON equ 0
SETFINETUNE_ON equ 0
PATTERNLOOP_ON equ 0
SETTREMOLOWAVE_ON equ 0
SETPANPOSITION16_ON equ 0
RETRIG_ON equ 0
NOTECUT_ON equ 1
NOTEDELAY_ON equ 1
PATTERNDELAY_ON equ 0
PORTAUP_OR_DOWN_ON equ 0
VIBRATO_OR_VOLSLIDE equ 1
VIBRATO_OR_TREMOLO equ 1
PORTATO_OR_VOLSLIDE equ 1
VOLUME_OR_PANENVELOPE equ 1
ROWCOMMANDS_ON equ 1
FINEVOLUMESLIDE_ON equ 0

View File

@ -0,0 +1,60 @@
; XM-file: mini.xm
; uFMOD optional features:
INFO_API_ON equ 0 ; disable InfoAPI
NOLOOP_ON equ 0 ; disable XM_NOLOOP
PAUSE_RESUME_ON equ 0 ; disable pause/resume and XM_SUSPENDED
VOL_CONTROL_ON equ 0 ; disable volume control
JUMP_TO_PAT_ON equ 0 ; disable Jump2Pattern
XM_FILE_ON equ 0 ; disable file loading
; Special flags:
INSTRUMENTVIBRATO_ON equ 0
VOLUMEENVELOPE_ON equ 1
PANENVELOPE_ON equ 0
VOLUMEBYTE_ON equ 0
ADPCM_ON equ 0
AMIGAPERIODS_ON equ 0
; XM effects:
ARPEGGIO_ON equ 0
PORTAUP_ON equ 0
PORTADOWN_ON equ 0
PORTATO_ON equ 0
VIBRATO_ON equ 0
PORTATOVOLSLIDE_ON equ 0
VIBRATOVOLSLIDE_ON equ 0
TREMOLO_ON equ 0
SETPANPOSITION_ON equ 0
SETSAMPLEOFFSET_ON equ 0
VOLUMESLIDE_ON equ 1
PATTERNJUMP_ON equ 0
SETVOLUME_ON equ 0
PATTERNBREAK_ON equ 0
SETSPEED_ON equ 0
SETGLOBALVOLUME_ON equ 0
GLOBALVOLSLIDE_ON equ 0
KEYOFF_ON equ 0
SETENVELOPEPOS_ON equ 0
PANSLIDE_ON equ 0
MULTIRETRIG_ON equ 0
TREMOR_ON equ 0
EXTRAFINEPORTA_ON equ 0
FINEPORTAUP_ON equ 0
FINEPORTADOWN_ON equ 0
SETVIBRATOWAVE_ON equ 0
SETFINETUNE_ON equ 0
PATTERNLOOP_ON equ 1
SETTREMOLOWAVE_ON equ 0
SETPANPOSITION16_ON equ 0
RETRIG_ON equ 0
NOTECUT_ON equ 0
NOTEDELAY_ON equ 0
PATTERNDELAY_ON equ 0
PORTAUP_OR_DOWN_ON equ 0
VIBRATO_OR_VOLSLIDE equ 0
VIBRATO_OR_TREMOLO equ 0
PORTATO_OR_VOLSLIDE equ 0
VOLUME_OR_PANENVELOPE equ 1
ROWCOMMANDS_ON equ 1
FINEVOLUMESLIDE_ON equ 0

Binary file not shown.

View File

@ -0,0 +1,278 @@
; NASM.ASM
; --------
; uFMOD public source code release. Provided as-is.
; *** This stub allows compiling uFMOD sources using NASM.
; Everything documented in fasm stub!
; %error directive in NASM causes multiple prompts to appear due to
; multiple passes :( So, we'd better avoid using %error.
ifdef f44100
FSOUND_MixRate equ 44100
FREQ_40HZ_p equ 1DB8Bh
FREQ_40HZ_f equ 3B7160h
PCM_format equ 3
else
ifdef f22050
FSOUND_MixRate equ 22050
FREQ_40HZ_p equ 3B716h
FREQ_40HZ_f equ 76E2C0h
PCM_format equ 9
else
FSOUND_MixRate equ 48000
FREQ_40HZ_p equ 1B4E8h
FREQ_40HZ_f equ 369D00h
PCM_format equ 1
endif
endif
ifdef NONE
RAMP_NONE equ 1
RAMP_WEAK equ 0
RAMP_STRONG equ 0
else
ifdef WEAK
RAMP_NONE equ 0
RAMP_WEAK equ 1
RAMP_STRONG equ 0
else
RAMP_NONE equ 0
RAMP_WEAK equ 0
RAMP_STRONG equ 1
endif
endif
UCODE equ 0
ifdef NODEBUG
DEBUG equ 0
else
DEBUG equ 1
endif
ifdef UNSAFE
CHK4VALIDITY equ 0
AC97SND_ON equ 0
else
CHK4VALIDITY equ 1
ifdef AC97SND
AC97SND_ON equ 1
else
AC97SND_ON equ 0
endif
endif
ifndef NOLINKER
%include "eff.inc"
[segment .text align=4]
endif
STRUC FSOUND_SAMPLE
FSOUND_SAMPLE._length resd 1
FSOUND_SAMPLE.loopstart resd 1
FSOUND_SAMPLE.looplen resd 1
FSOUND_SAMPLE.defvol resb 1
FSOUND_SAMPLE.finetune resb 1
FSOUND_SAMPLE.bytes resb 1
FSOUND_SAMPLE.defpan resb 1
FSOUND_SAMPLE.relative resb 1
FSOUND_SAMPLE.Resved resb 1
FSOUND_SAMPLE.loopmode resb 1
FSOUND_SAMPLE._align resb 1
FSOUND_SAMPLE.buff resb 2
ENDSTRUC
STRUC FSOUND_CHANNEL
FSOUND_CHANNEL.actualvolume resd 1
FSOUND_CHANNEL.actualpan resd 1
FSOUND_CHANNEL.fsampleoffset resd 1
FSOUND_CHANNEL.leftvolume resd 1
FSOUND_CHANNEL.rightvolume resd 1
FSOUND_CHANNEL.mixpos resd 1
FSOUND_CHANNEL.speedlo resd 1
FSOUND_CHANNEL.speedhi resd 1
FSOUND_CHANNEL.ramp_lefttarget resw 1
FSOUND_CHANNEL.ramp_righttarget resw 1
FSOUND_CHANNEL.ramp_leftspeed resd 1
FSOUND_CHANNEL.ramp_rightspeed resd 1
FSOUND_CHANNEL.fsptr resd 1
FSOUND_CHANNEL.mixposlo resd 1
FSOUND_CHANNEL.ramp_leftvolume resd 1
FSOUND_CHANNEL.ramp_rightvolume resd 1
FSOUND_CHANNEL.ramp_count resw 1
FSOUND_CHANNEL.speeddir resb 2
ENDSTRUC
STRUC FMUSIC_NOTE
FMUSIC_NOTE.unote resb 1
FMUSIC_NOTE.number resb 1
FMUSIC_NOTE.uvolume resb 1
FMUSIC_NOTE.effect resb 1
FMUSIC_NOTE.eparam resb 1
ENDSTRUC
STRUC FMUSIC_PATTERN
FMUSIC_PATTERN.rows resw 1
FMUSIC_PATTERN.patternsize resw 1
FMUSIC_PATTERN.data resd 1
ENDSTRUC
STRUC FMUSIC_INSTRUMENT
FMUSIC_INSTRUMENT.sample resd 16
FMUSIC_INSTRUMENT.keymap resb 96
FMUSIC_INSTRUMENT.VOLPoints resw 24
FMUSIC_INSTRUMENT.PANPoints resw 24
FMUSIC_INSTRUMENT.VOLnumpoints resb 1
FMUSIC_INSTRUMENT.PANnumpoints resb 1
FMUSIC_INSTRUMENT.VOLsustain resb 1
FMUSIC_INSTRUMENT.VOLLoopStart resb 1
FMUSIC_INSTRUMENT.VOLLoopEnd resb 1
FMUSIC_INSTRUMENT.PANsustain resb 1
FMUSIC_INSTRUMENT.PANLoopStart resb 1
FMUSIC_INSTRUMENT.PANLoopEnd resb 1
FMUSIC_INSTRUMENT.VOLtype resb 1
FMUSIC_INSTRUMENT.PANtype resb 1
FMUSIC_INSTRUMENT.VIBtype resb 1
FMUSIC_INSTRUMENT.VIBsweep resb 1
FMUSIC_INSTRUMENT.iVIBdepth resb 1
FMUSIC_INSTRUMENT.VIBrate resb 1
FMUSIC_INSTRUMENT.VOLfade resw 1
ENDSTRUC
STRUC FMUSIC_CHANNEL
FMUSIC_CHANNEL.note resb 1
FMUSIC_CHANNEL.samp resb 1
FMUSIC_CHANNEL.notectrl resb 1
FMUSIC_CHANNEL.inst resb 1
FMUSIC_CHANNEL.cptr resd 1
FMUSIC_CHANNEL.freq resd 1
FMUSIC_CHANNEL.volume resd 1
FMUSIC_CHANNEL.voldelta resd 1
FMUSIC_CHANNEL.freqdelta resd 1
FMUSIC_CHANNEL.pan resd 1
FMUSIC_CHANNEL.envvoltick resd 1
FMUSIC_CHANNEL.envvolpos resd 1
FMUSIC_CHANNEL.envvoldelta resd 1
FMUSIC_CHANNEL.envpantick resd 1
FMUSIC_CHANNEL.envpanpos resd 1
FMUSIC_CHANNEL.envpandelta resd 1
FMUSIC_CHANNEL.ivibsweeppos resd 1
FMUSIC_CHANNEL.ivibpos resd 1
FMUSIC_CHANNEL.keyoff resb 2
FMUSIC_CHANNEL.envvolstopped resb 1
FMUSIC_CHANNEL.envpanstopped resb 1
FMUSIC_CHANNEL.envvolfrac resd 1
FMUSIC_CHANNEL.envvol resd 1
FMUSIC_CHANNEL.fadeoutvol resd 1
FMUSIC_CHANNEL.envpanfrac resd 1
FMUSIC_CHANNEL.envpan resd 1
FMUSIC_CHANNEL.period resd 1
FMUSIC_CHANNEL.sampleoffset resd 1
FMUSIC_CHANNEL.portatarget resd 1
FMUSIC_CHANNEL.patloopno resb 4
FMUSIC_CHANNEL.patlooprow resd 1
FMUSIC_CHANNEL.realnote resb 1
FMUSIC_CHANNEL.recenteffect resb 1
FMUSIC_CHANNEL.portaupdown resb 2
FMUSIC_CHANNEL.xtraportadown resb 1
FMUSIC_CHANNEL.xtraportaup resb 1
FMUSIC_CHANNEL.volslide resb 1
FMUSIC_CHANNEL.panslide resb 1
FMUSIC_CHANNEL.retrigx resb 1
FMUSIC_CHANNEL.retrigy resb 1
FMUSIC_CHANNEL.portaspeed resb 1
FMUSIC_CHANNEL.vibpos resb 1
FMUSIC_CHANNEL.vibspeed resb 1
FMUSIC_CHANNEL.vibdepth resb 1
FMUSIC_CHANNEL.tremolopos resb 1
FMUSIC_CHANNEL.tremolospeed resb 1
FMUSIC_CHANNEL.tremolodepth resb 1
FMUSIC_CHANNEL.tremorpos resb 1
FMUSIC_CHANNEL.tremoron resb 1
FMUSIC_CHANNEL.tremoroff resb 1
FMUSIC_CHANNEL.wavecontrol resb 1
FMUSIC_CHANNEL.finevslup resb 1
FMUSIC_CHANNEL.fineportaup resb 1
FMUSIC_CHANNEL.fineportadown resb 1
ENDSTRUC
STRUC FMUSIC_MODULE
FMUSIC_MODULE.pattern resd 1
FMUSIC_MODULE.instrument resd 1
FMUSIC_MODULE.mixer_samplesleft resd 1
FMUSIC_MODULE.globalvolume resd 1
FMUSIC_MODULE.tick resd 1
FMUSIC_MODULE.speed resd 1
FMUSIC_MODULE.order resd 1
FMUSIC_MODULE.row resd 1
FMUSIC_MODULE.patterndelay resd 1
FMUSIC_MODULE.nextorder resd 1
FMUSIC_MODULE.nextrow resd 1
FMUSIC_MODULE.unused1 resd 1
FMUSIC_MODULE.numchannels resd 1
FMUSIC_MODULE.Channels resd 1
FMUSIC_MODULE.uFMOD_Ch resd 1
FMUSIC_MODULE.mixer_samplespertick resd 1
FMUSIC_MODULE.numorders resw 1
FMUSIC_MODULE.restart resw 1
FMUSIC_MODULE.numchannels_xm resb 1
FMUSIC_MODULE.globalvsl resb 1
FMUSIC_MODULE.numpatternsmem resw 1
FMUSIC_MODULE.numinsts resw 1
FMUSIC_MODULE.flags resw 1
FMUSIC_MODULE.defaultspeed resw 1
FMUSIC_MODULE.defaultbpm resw 1
FMUSIC_MODULE.orderlist resb 256
ENDSTRUC
%macro PUBLIC 1
ifndef NOLINKER
GLOBAL %1
endif
%endmacro
%define OFFSET
%define PTR
include "ufmod.asm"
include "core.asm"
ifdef NOLINKER
uFMOD_IMG_END: ; End of uFMOD's code. BSS follows.
align 16
[segment .bss]
else
[segment .bss align=16]
endif
_mod resb FMUSIC_MODULE_size
mmt resd 3
ufmod_heap resd 2
if AC97SND_ON
extern hSound
resd 1
else
hSound resd 1
endif
hBuff resd 1
SW_Exit resd 1
MixBuf resb FSOUND_BlockSize*8
ufmod_noloop resb 1
ufmod_pause_ resb 1
mix_endflag resb 2
mmf resd 4
ufmod_vol resd 1
uFMOD_fopen resd 1
uFMOD_fread resd 1
file_struct resd 7
cache_offset resd 1
if INFO_API_ON
time_ms resd 1
L_vol resw 1
R_vol resw 1
s_row resw 1
s_order resw 1
szTtl resb 24
endif
DummySamp resb FSOUND_SAMPLE_size

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,89 @@
/*
uFMOD API reference (AC97SND mode)
=========================================================
NOTE: ufmod.obj should be rebuilt setting UF_MODE=AC97SND
in order to make it usable in AC97SND player.
The Infinity Sound driver handle should be available as
a public symbol named hSound. It is so when using Serge's
sound.lib.
*/
#ifdef __cplusplus
extern "C" {
#endif
/* HANDLE uFMOD_LoadSong(char *lpXM);
---
Description:
---
Loads the given XM song and starts playing it as soon as you
call uFMOD_WaveOut for the first time. It will stop any
currently playing song before loading the new one. Heap should
be initialized before calling this function!
---
Parameters:
---
lpXM
Specifies the filename of the song to load.
---
Return Values:
---
On success, returns a non zero value. Returns 0 on failure.
*/
int __cdecl uFMOD_LoadSong(char*);
/* int uFMOD_WaveOut(SNDBUF hBuff)
---
Description:
---
Updates the internal playback buffer.
---
Parameters:
---
hBuff
The Infinity Sound buffer to update.
---
Remarks:
---
Playback doesn't actually begin when calling uFMOD_LoadSong,
but when calling uFMOD_WaveOut after a successful uFMOD_LoadSong
call. Afterwards, you should call uFMOD_WaveOut repeatedly at
least once every 250 ms to prevent "buffer underruns".
uFMOD_WaveOut is a non-blocking function.
---
Return Values:
---
Returns non zero on error.
*/
int __cdecl uFMOD_WaveOut(unsigned int);
/* void uFMOD_StopSong(void)
---
Description:
---
Stops the currently playing song, freeing the associated
resources.
---
Remarks:
---
Does nothing if no song is playing at the time the call is made.
*/
void __cdecl uFMOD_StopSong();
/* unsigned char* _uFMOD_GetTitle(void)
---
Description:
---
Returns the current song's title.
---
Remarks:
---
Not every song has a title, so be prepared to get an empty string.
*/
unsigned char* __cdecl uFMOD_GetTitle();
#ifdef __cplusplus
}
#endif

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,253 @@
; uFMOD API reference (NORMAL/UNSAFE mode)
; ====================================================================
; NOTE: All functions follow the cdecl calling convention!
; _uFMOD_LoadSong
; _uFMOD_WaveOut
; _uFMOD_StopSong
; _uFMOD_Jump2Pattern
; _uFMOD_Pause
; _uFMOD_Resume
; _uFMOD_GetStats
; _uFMOD_GetRowOrder
; _uFMOD_GetTime
; _uFMOD_GetTitle
; _uFMOD_SetVolume
; ====================================================================
; HANDLE _uFMOD_LoadSong(
; void *lpXM,
; void *param,
; int fdwSong
; )
; ---
; Description:
; ---
; Loads the given XM song and starts playing it as soon as you
; call _uFMOD_WaveOut for the first time. Playback won't begin
; if XM_SUSPENDED flag is specified. It will stop any currently
; playing song before loading the new one.
; ---
; Parameters:
; ---
; lpXM
; Specifies the song to load. If this parameter is 0, any
; currently playing song is stopped. In such a case, function
; does not return a meaningful value. fdwSong parameter
; determines whether this value is interpreted as a filename
; or as a pointer to an image of the song in memory.
; param
; If XM_MEMORY is specified, this parameter should be the size
; of the image of the song in memory.
; If XM_FILE is specified, this parameter is ignored.
; fdwSong
; Flags for playing the song. The following values are defined:
; XM_FILE lpXM points to filename. param is ignored.
; XM_MEMORY lpXM points to an image of a song in memory.
; param is the image size. Once, _uFMOD_LoadSong
; returns, it's safe to free/discard the memory
; buffer.
; XM_NOLOOP An XM track plays repeatedly by default. Specify
; this flag to play it only once.
; XM_SUSPENDED The XM track is loaded in a suspended state,
; and will not play until the _uFMOD_Resume function
; is called. This is useful for preloading a song
; or testing an XM track for validity.
; ---
; Return Values:
; ---
; On success, returns the handle of the Infinity Sound driver.
; Returns 0 on failure.
; ====================================================================
; int _uFMOD_WaveOut(void)
; ---
; Description:
; ---
; Updates the internal playback buffer.
; ---
; Remarks:
; ---
; This function should be called from the same thread
; _uFMOD_LoadSong was previously called. Playback doesn't actually
; begin when calling _uFMOD_LoadSong, but when calling _uFMOD_WaveOut
; after a successful _uFMOD_LoadSong call. Afterwards, you should
; call _uFMOD_WaveOut repeatedly at least once every 250 ms to
; prevent "buffer underruns".
; _uFMOD_WaveOut is a non-blocking function. The accuracy of the
; InfoAPI functions (_uFMOD_GetStats, _uFMOD_GetRowOrder and
; _uFMOD_GetTime) depends on the periodicity of this function being
; invoked.
; ---
; Return Values:
; ---
; Returns non zero on error.
; ====================================================================
; void _uFMOD_StopSong(void)
; ---
; Description:
; ---
; Stops the currently playing song, freeing the associated
; resources.
; ---
; Remarks:
; ---
; Does nothing if no song is playing at the time the call is made.
; ====================================================================
; void _uFMOD_Jump2Pattern(
; unsigned int pat
; )
; ---
; Description:
; ---
; Jumps to the specified pattern index.
; ---
; Parameters:
; ---
; pat
; Next zero based pattern index.
; ---
; Remarks:
; ---
; uFMOD doesn't automatically perform Note Off effects before jumping
; to the target pattern. In other words, the original pattern will
; remain in the mixer until it fades out. You can use this feature to
; your advantage. If you don't like it, just insert leading Note Off
; commands in all patterns intended to be used as _uFMOD_Jump2Pattern
; targets.
; if the pattern index lays outside of the bounds of the pattern order
; table, calling this function jumps to pattern 0, effectively
; rewinding playback.
; ====================================================================
; void _uFMOD_Pause(void)
; ---
; Description:
; ---
; Pauses the currently playing song, if any.
; ---
; Remarks:
; ---
; While paused you can still control the volume (_uFMOD_SetVolume) and
; the pattern order (_uFMOD_Jump2Pattern). The RMS volume coefficients
; (_uFMOD_GetStats) will go down to 0 and the progress tracker
; (_uFMOD_GetTime) will "freeze" while the song is paused.
; _uFMOD_Pause doesn't perform the request immediately. Instead, it
; signals to pause when playback reaches next chunk of data.
; This way, _uFMOD_Pause performs asynchronously and returns very fast.
; It is not cumulative. So, calling _uFMOD_Pause many times in a row
; has the same effect as calling it once.
; You shouldn't stop calling _uFMOD_WaveOut while the song is paused!
; ====================================================================
; void _uFMOD_Resume(void)
; ---
; Description:
; ---
; Resumes the currently paused song, if any.
; ---
; Remarks:
; ---
; _uFMOD_Resume doesn't perform the request immediately. Instead, it
; signals to resume when _uFMOD_WaveOut is called again. _uFMOD_Resume
; is not cumulative. So, calling it many times in a row has the same
; effect as calling it once.
; ====================================================================
; unsigned int _uFMOD_GetStats(void)
; ---
; Description:
; ---
; Returns the current RMS volume coefficients in (L)eft and (R)ight
; channels.
; low-order word: RMS volume in R channel
; hi-order word: RMS volume in L channel
; Range from 0 (silence) to $7FFF (maximum) on each channel.
; ---
; Remarks:
; ---
; This function is useful for updating a VU meter. It's recommended
; to rescale the output to log10 (decibels or dB for short), because
; human ears track volume changes in a dB scale. You may call
; _uFMOD_GetStats() as often as you like, but take in mind that uFMOD
; updates both channel RMS volumes at the same rate _uFMOD_WaveOut
; function is called. In other words, you should call _uFMOD_WaveOut
; more often to increase the accuracy of _uFMOD_GetStats.
; ====================================================================
; unsigned int _uFMOD_GetRowOrder(void)
; ---
; Description:
; ---
; Returns the currently playing row and order.
; low-order word: row
; hi-order word: order
; ---
; Remarks:
; ---
; This function is useful for synchronization. uFMOD updates both
; row and order values at the same rate _uFMOD_WaveOut function is
; called. In other words, you should call _uFMOD_WaveOut more often
; to increase the accuracy of _uFMOD_GetRowOrder.
; ====================================================================
; unsigned int _uFMOD_GetTime(void)
; ---
; Description:
; ---
; Returns the time in milliseconds since the song was started.
; ---
; Remarks:
; ---
; This function is useful for synchronizing purposes. Multimedia
; applications can use _uFMOD_GetTime to synchronize GFX to sound,
; for example. An XM player can use this function to update a progress
; meter.
; ====================================================================
; unsigned char* _uFMOD_GetTitle(void)
; ---
; Description:
; ---
; Returns the current song's title.
; ---
; Remarks:
; ---
; Not every song has a title, so be prepared to get an empty string.
; ====================================================================
; void _uFMOD_SetVolume(
; unsigned int vol
; )
; ---
; Description:
; ---
; Sets the global volume. The volume scale is linear.
; ---
; Parameters:
; ---
; vol
; New volume. Range: from uFMOD_MIN_VOL (muting) to uFMOD_MAX_VOL
; (maximum volume). Any value above uFMOD_MAX_VOL maps to maximum
; volume.
; ---
; Remarks:
; ---
; uFMOD internally converts the given values to a logarithmic scale (dB).
; Maximum volume is set by default. The volume value is preserved across
; _uFMOD_LoadSong calls. You can set the desired volume level before
; actually starting to play a song.
; You can use Infinity Sound API to control the L and R channels volumes
; separately. It also has a wider range than _uFMOD_SetVolume, sometimes
; allowing to amplify the sound volume as well, as opposed to
; _uFMOD_SetVolume only being able to attenuate it.
XM_MEMORY equ 1
XM_FILE equ 2
XM_NOLOOP equ 8
XM_SUSPENDED equ 16
uFMOD_MIN_VOL equ 0
uFMOD_MAX_VOL equ 25
uFMOD_DEFAULT_VOL equ 25