Subversion Repositories Kolibri OS

Rev

Rev 1845 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ; MINI.ASM
  2. ; --------
  3. ; Minimalistic uFMOD usage example.
  4.  
  5. ; Shows how to play an XM track in memory,
  6. ; including proper error handling.
  7.  
  8. ; A precompiled version (not packed or whatever) is
  9. ; available in bin\
  10.  
  11. use32
  12. org 0
  13. db 'MENUET01'
  14. dd 1
  15. dd START         ; Entry point
  16. dd uFMOD_IMG_END ; End of code and initialized data
  17. dd MEMORY_END    ; End of uninitialized (BSS) data
  18. dd STACK_B       ; Bottom of the stack
  19. dd 0             ; Args
  20. dd 0             ; Reserved
  21.  
  22. ; uFMOD setup:
  23. UF_FREQ  equ 48000  ; Set sampling rate to 48KHz  (22050, 44100, 48000)
  24. UF_RAMP  equ STRONG ; Select STRONG interpolation (NONE, WEAK, STRONG)
  25. UD_MODE  equ UNSAFE ; Select UNSAFE mode          (NORMAL, UNSAFE)
  26. DEBUG    equ 0      ; Skip debug-board messages
  27. NOLINKER equ 1      ; Select "no linker" mode
  28.  
  29. ; uFMOD constants:
  30. XM_MEMORY         = 1
  31. XM_FILE           = 2
  32. XM_NOLOOP         = 8
  33. XM_SUSPENDED      = 16
  34. uFMOD_MIN_VOL     = 0
  35. uFMOD_MAX_VOL     = 25
  36. uFMOD_DEFAULT_VOL = 25
  37.  
  38. ; The XM track.
  39. xm        file '..\media\mini.xm'
  40. xm_length = $ - xm
  41.  
  42. ; Optimization:
  43. ; This header file is suitable for mini.xm track only!
  44. ; If you change the track, update the optimization header.
  45. ; (Use the standart eff.inc file for a general purpose player app.)
  46. include '..\media\mini.eff.inc'
  47.  
  48. ; Include the GUI framework.
  49. FRMWRK_CALLBACK_ON equ 1 ; Enable callback
  50. include 'frmwrk.asm'
  51.  
  52. ; UI text messages.
  53. msg_txt   db "uFMOD ruleZ!"
  54. msg_txt_l = $ - msg_txt
  55. msg_cap   db "FASM",0
  56. err_txt   db "Error"
  57. err_txt_l = $ - err_txt
  58. err_cap   db ":-(",0
  59.  
  60. START:
  61.         ; Start playback.
  62.         push XM_MEMORY
  63.         push xm_length
  64.         push xm
  65.         call _uFMOD_LoadSong
  66.  
  67.         ; Stack fixing is required here, but in this simple
  68.         ; example leaving ESP as it is won't harm. In a real
  69.         ; application you should uncomment the following line:
  70.         ; add esp,12
  71.  
  72.         test eax,eax
  73.         jz error
  74.  
  75.         ; Wait for user input.
  76.         push _uFMOD_WaveOut ; cbProc <- continue fetching data!
  77.         push msg_txt_l      ; cbString
  78.         push msg_txt        ; lpString
  79.         push msg_cap        ; szCap
  80.         call _MessageBoxCB
  81.         ; add esp,16
  82.  
  83.         ; Stop playback.
  84.         call _uFMOD_StopSong
  85.  
  86. r:      ; Exit.
  87.         xor eax,eax
  88.         dec eax
  89.         int 40h
  90.  
  91. error:
  92.         push 0              ; cbProc <- no callback
  93.         push err_txt_l      ; cbString
  94.         push err_txt        ; lpString
  95.         push err_cap        ; szCap
  96.         call _MessageBoxCB
  97.         ; add esp,16
  98.         jmp r
  99.  
  100.         ; Include the whole uFMOD sources here. (Right after
  101.         ; your main code to avoid naming conflicts, but still
  102.         ; inside your code section.)
  103.         macro PUBLIC symbol {} ; hide all publics
  104.         include '..\fasm.asm'
  105.  
  106. align 4
  107.         rb 1020
  108. STACK_B dd ? ; Stack bottom
  109. MEMORY_END:  ; End of uninitialized (BSS) data
  110.