
12-01-2005, 20:50
|
|
|
XM files in ASM [Mini-tutorial]
If you want to put a XM (Modular Music) in your assembler programs, you can follow these steps:
Quote:
To play music, I use the MiniFMOD 1.60 library.
In the RC (Resource) file:
#define IDM_MUSIC 400
IDM_MUSIC RCDATA "music.xm"
In the .asm file:
You may include the libraries:
include mfmplayer.inc
includelib mfmplayer.lib
Declare the music const:
.const
IDM_MUSIC equ 400
Add the data variables:
nMusicSize DWORD ?
pMusic LPVOID ?
Put the this code on the start of the app:
start:
;chiptune
INVOKE GetModuleHandle, NULL
mov hInstance, eax
; Load the music
push esi
INVOKE FindResource, hInstance, IDM_MUSIC, RT_RCDATA
push eax
INVOKE SizeofResource, hInstance, eax
mov nMusicSize, eax
pop eax
INVOKE LoadResource, hInstance, eax
INVOKE LockResource, eax
mov esi, eax
mov eax, nMusicSize
add eax, SIZEOF nMusicSize
INVOKE GlobalAlloc, GPTR, eax
mov pMusic, eax
mov ecx, nMusicSize
mov dword ptr [eax], ecx
add eax, SIZEOF nMusicSize
mov edi, eax
rep movsb
pop esi
...
...
end start
And the code for execute the music:
invoke mfmPlay, pMusic
To free the memory (music stops):
INVOKE GlobalFree, pMusic
The needed files and this txt is attached.
This is all!
Tested on WinXP SP2. WinAsm 5.1. Compiled with MASM 8.2 (compatible with SP2)
|
Be happy  !
(If you find another good "minituto" like this one, you can put it here.)
this is another not-so-mini tutorial on the same topic: hxxp://www.freewebtown.com/fusionrulez/database/xmmusicasm.zip by fornix
[EDIT:JMI] DO NOT ANSWER YOUR OWN POST. USE THE EDIT BUTTION TO ADDED TO THE ORIGINAL. OTHERWISE IT LOOKS LIKE POST COUNT PADDING AND THAT WILL GET YOU BANNED.
[About the edit:ADX]Hey, sorry JMI, I'm not answered my own post (and I'm editting now), and I found this "thing" on the net, this isn't made by me, and I didn't know about the really author of that. I don't want to "padding" posts, it's only a post for the people who don't knows how to add xm files in assember (like me). In any case, sorry, I'm new.
My regards: ADX
(So, thanks to fornix for that tutorial)
Byez
ADX Note: Because we found the author (fornix) of this tutorial, I removed the attachment.
Last edited by ADX; 12-02-2005 at 22:55.
Reason: Simple Mistake
|