beta.blog

FASM: Play MOD files

by on Sep.19, 2011, under Programming

Example of how to read and play a mod-file in flat assembler.
This example requires you to download the library bassmod.dll as well as the sample XM-file fff-90kb.daydreams.XM in order to work properly.

Keep in mind this library supports playing multiple audio formats such as mod, xm (xmod) and more.

format PE GUI 4.0
entry start

include 'win32a.inc'

;================== code =====================
section '.code' code readable executable
;=============================================

proc start

        invoke  BASS_Init, -1, 44100, 0, 0, NULL            ; Initialize the BassMOD DLL
        invoke  BASS_Load, 0, filename, 0, 0, 514           ; Load our mod file (*.mod, *.xm, ...)
        invoke  BASS_Play                                   ; Play it

        invoke  MessageBox,0,message,caption,MB_OK          ; Display a MessageBox while the song is playing

        invoke  BASS_Stop                                   ; After the user clicked OK, stop playing the file
        invoke  BASS_Free                                   ; Free the library
        invoke  ExitProcess,0                               ; Exit the application

endp

;=================== data ====================
section '.data' data readable writeable
;=============================================

flags           dd ?
caption         db 'Hello BassMOD | BetaMaster.us',0
message         db 'Click OK to exit the application.',0
filename        db 'fff-90kb.daydreams.XM',0

;=============================================
section '.idata' import data readable
;=============================================

library         kernel32,'KERNEL32.DLL',\
                user32,'USER32.DLL',\
                bassmod,'bassmod.dll'

import          kernel32,\
                ExitProcess,'ExitProcess'

import          user32,\
                MessageBox,'MessageBoxA'

import          bassmod,\
                BASS_Init,'BASSMOD_Init',\
                BASS_Load,'BASSMOD_MusicLoad',\
                BASS_Free,'BASSMOD_Free',\
                BASS_Play,'BASSMOD_MusicPlay',\
                BASS_Stop,'BASSMOD_MusicStop'


1 Comment for this entry

Leave a Reply

*

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!