Page 3 of 6

Re: dsdoom source

Posted: Mon May 23, 2011 1:29 pm
by elhobbs
I have been working on a heretic port. I have added in Pate's adlib emulator and have cobbled together something to get MUS files playing. you are welcome to it if you are interested. the drawbacks to this route are that the adlib emulator takes up 9 of the ds sound channels. I am using software mixing for the sound effects so it is not a big deal for me, as I only need two channels for that.

Re: dsdoom source

Posted: Tue May 24, 2011 6:20 am
by happy_bunny
it would be nice not to have external *.raw files, is there a stand alone version of adlib emulator for the nds ? if so where can i get it from ?

currently i am using soundPlaySample to play sfx in doom, how are you doing the software mixing for the sound effects in heretic?

Re: dsdoom source

Posted: Tue May 24, 2011 8:40 am
by happy_bunny
google is god ;-) found the source to adlib

so it uses channels 2-10 for sound, soundPlaySample uses the first free channel it finds so if I limit the calls to soundPlaySample to a maximum of 7 I should have enough channels to play 7 sfx + music simultaneously ;-)

so my next question is how do I use adlib to play mus / midi files ? can I have a look at your "cobbled together" code please.

not sure if this will help but if you look at the source code for chocolate doom

under src directory their are two files


these may help convert play midi files using adlib (I need to spend so time looking over the files)

Re: dsdoom source

Posted: Tue May 24, 2011 8:45 am
by zeromus
this is not completely on topic, but somebody really ought to remake the doom music as mods using samples derived from the adlib patches.

Re: dsdoom source

Posted: Tue May 24, 2011 1:35 pm
by elhobbs
here is the code for playing mus files musplay.c. This is from multiple open source projects mostly MUS File Player Library V1.75.

Re: dsdoom source

Posted: Thu May 26, 2011 4:05 pm
by happy_bunny
you sir are a star thanks for the code :D

is it possiable to have a variable call back function to handle track timings ? ie do something like this

void OPL_SetCallback(unsigned int ms, VoidFn callback)
timerStart( 2, ClockDivider_1024, TIMER_FREQ_1024( 1000 / ms ), callback );

and then just call OPL_SetCallback with different values of ms, would this work ? or would I need to stop the timer in the call back function before each call to OPL_SetCallback ?

Re: dsdoom source

Posted: Thu May 26, 2011 5:40 pm
by elhobbs
yes, that will work it will just stomp the old timer callback. curious, what are you timing?

EDIT: not sure if that is the latest code. I will check the svn when I get home and let you know if there were updates.

Re: dsdoom source

Posted: Fri May 27, 2011 9:28 am
by happy_bunny
musplay.c calls a routine (mus_play_timer) every 1/140 seconds this routine in turns call a second function (mus_delay_ticks) which sets up a variable called MUSticks.

no music is played until this variable gets decremented to zero, it this point mus_play_tick is called. So for every call to mus_play_tick, mus_play_timer gets called

mus_play_timer * MUSticks

this is a waste of cpu time it would be better to do something like this


MUSticks = mus_delay_ticks();
OPL_SetCallback(MUSticks, mus_play_tick)

that way the routine only runs when its needed, well thats the plan I havnt got anything running yet :( will post something when I get the time to get something working !

Re: dsdoom source

Posted: Fri May 27, 2011 1:53 pm
by elhobbs
what is that saying about premature optimization?

minimal code to get it working:
add " mus_init_music();" to S_Init
add "mus_play_music(S_music[song].name);" to S_StartSong

not 100% sure about the second one - "S_music[song].name" needs to be the name of the MUS file. this is from heretic, but it uses the doom engine so it should be similiar if not the same.

Re: dsdoom source

Posted: Sat May 28, 2011 5:06 pm
by WinterMute
You're wasting your time with that and I don't think converting MUS to mod will work well either. The DS arm7 isn't powerful enough for OPL emulation in C.

Your best bet for music is from

Also, the diff you made is a bit wrong, what you need to do is use svn diff directly against the code on the google code project. I'm not 100% sure offhand but I believe you can use svn add and svn remove without checkin privileges. If you deleted any files then use svn remove, for any files you added then use svn add.

The diff you attached has all sorts of stuff from the svn control files.