dsdoom source

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: dsdoom source

Post by elhobbs » Mon May 23, 2011 1:29 pm

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.

happy_bunny
Posts: 28
Joined: Mon May 02, 2011 10:13 pm

Re: dsdoom source

Post by happy_bunny » Tue May 24, 2011 6:20 am

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?

happy_bunny
Posts: 28
Joined: Mon May 02, 2011 10:13 pm

Re: dsdoom source

Post by happy_bunny » Tue May 24, 2011 8:40 am

google is god ;-) found the source to adlib

http://dsx86.patrickaalto.com/DSdown.html

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

http://sourceforge.net/projects/chocolate-doom/

under src directory their are two files

mus2mid.c
midifile.c

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

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: dsdoom source

Post by zeromus » Tue May 24, 2011 8:45 am

this is not completely on topic, but somebody really ought to remake the doom music as mods using samples derived from the adlib patches.

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: dsdoom source

Post by elhobbs » Tue May 24, 2011 1:35 pm

here is the code for playing mus files musplay.c. This is from multiple open source projects mostly MUS File Player Library V1.75.

happy_bunny
Posts: 28
Joined: Mon May 02, 2011 10:13 pm

Re: dsdoom source

Post by happy_bunny » Thu May 26, 2011 4:05 pm

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 ?

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: dsdoom source

Post by elhobbs » Thu May 26, 2011 5:40 pm

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.

happy_bunny
Posts: 28
Joined: Mon May 02, 2011 10:13 pm

Re: dsdoom source

Post by happy_bunny » Fri May 27, 2011 9:28 am

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

mus_play{

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 !

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: dsdoom source

Post by elhobbs » Fri May 27, 2011 1:53 pm

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.

WinterMute
Site Admin
Posts: 1845
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: dsdoom source

Post by WinterMute » Sat May 28, 2011 5:06 pm

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 AdLibSrc.zip from http://dsx86.patrickaalto.com/DSdown.html

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.
Help keep devkitPro toolchains free, Donate today

Personal Blog

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 11 guests