MOD Player for 32X - the Good Enough release

Ask anything your want about the 32X Mushroom programming.

Moderator: BigEvilCorporation

Pascal
Very interested
Posts: 200
Joined: Wed Nov 29, 2006 11:29 am
Location: Belgium
Contact:

Post by Pascal » Fri Mar 11, 2011 9:06 am

great release again

Image

Bitybity
Interested
Posts: 36
Joined: Wed Dec 07, 2011 2:09 am

Post by Bitybity » Fri Dec 16, 2011 2:06 am

@ChillyWilly: I have a question: Which compiler do you use for it?
Sorry if I sound n00b. I just know asm; nothing of C.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Fri Dec 16, 2011 3:47 am

I use my own home built one.

viewtopic.php?t=889

That shows how to make your own gcc toolchain for the MD and 32X under linux, but it's about the same for mingw/cygwin if you use Windows. You get C, C++, ObjC, and ObjC++ compilers. It comes with simple examples for C and C++ for both the MD and 32X. It can also be used for my MOD player and Yeti3D demos as well.

Bitybity
Interested
Posts: 36
Joined: Wed Dec 07, 2011 2:09 am

Post by Bitybity » Fri Dec 16, 2011 5:57 pm

OK, so I get this compiling very well on windows with the powerofrecall's compilers. But I have 3 last n00b questions:

- Where I could specify which pattern to start with, on a MOD?
- Where I could modify to make some MOD channels to play in mono?
- How I could just copy the Slave SH2 part, to make it to work on a source code like this one?

And again, sorry if I'm n00b, but that's because I just know ASM, and not C.

Chilly Willy
Very interested
Posts: 2984
Joined: Fri Aug 17, 2007 9:33 pm

Post by Chilly Willy » Sat Dec 17, 2011 2:37 am

Bitybity wrote:OK, so I get this compiling very well on windows with the powerofrecall's compilers. But I have 3 last n00b questions:

- Where I could specify which pattern to start with, on a MOD?
In module.c in the InitMOD() function, you'll find this toward the end:

Code: Select all

  Mod_p->Order = 0; /* default order */
  Mod_p->Row = 0;   /* default row */
That is the default start play point for MODs. You could change it if you like and understand how your MODs are done, but this is the default used by all players.

- Where I could modify to make some MOD channels to play in mono?
At the top of module.c, you'll find

Code: Select all

/* define if handle 6 or 8 channel mods */
#define HANDLE_EXTRA_CHANNELS
/* define if handle panning */
//#define HANDLE_PANNING
/* define if want a little cross-talk between sides (only if no panning) */
//#define CROSS_TALK 3
Delete the "//" from the CROSS_TALK define and set it to 0. That will play the MOD as mono... it's still stereo, but with all channels playing equally to both right and left, which is mono. If you wished true mono, you'd need to edit the code more - my sound mixer expects sounds that have a left/right volume balance on stereo output. I suggest leaving everything as regular stereo and change the way PCM is output on Sonic 32X to match my sound mixer instead of the way it's handled now. The sound handling for Sonic 32X is pretty nasty anyway - it's hard-coded, int driven, and designed to pull data through the system communication registers from the 68000 side. Very not cool.
- How I could just copy the Slave SH2 part, to make it to work on a source code like this one?
You need to find where the Slave SH2 vector table directs the slave to run from on start up. Then direct it to my slave() function instead. It might be better to toss ALL the 32X code from Sonic 32X and redo it completely, keeping just the 68000 changes.

And again, sorry if I'm n00b, but that's because I just know ASM, and not C.
No problem. Just keep at it and you'll learn. :)

KillaMaaki
Very interested
Posts: 84
Joined: Sat Feb 28, 2015 9:22 pm

Re: MOD Player for 32X - the Good Enough release

Post by KillaMaaki » Thu Oct 01, 2015 10:14 pm

Pardon the slightly off-topic question, but didn't you have source code for an XM player laying around somewhere as well? I ask because I wanted to take a look at integrating it, and the song I made is currently in XM format (converting it to MOD doesn't seem to be an easy option - many notes go out of range, so part of the song just sounds like complete ass upon conversion).

On a side note, do you think for a large-ish game that storing samples per song is likely to be an issue storage-wise? One thought I had was to modify the format so that instead of storing the sample data directly in the file, I have a separate global sample table and the modified XM file just points to entries in that table instead (if your XM code is anything like your MOD code, it looks like this could be a one-line change, on the line where it assigns the sample pointer), but ofc if this isn't likely to be an issue I'd like to be as lazy as possible and spend my effort on other things XD

EDIT: NVM, I found the XM player. Am now studying the internals of the audio mixing code. I'm not fantastic with assembly, and it's also late at night and my brain is perhaps not functioning at 100%, but I think I'm starting to understand this, at least to some extent. I may ditch the full-blown XM player and just write my own audio engine. I've once written a tracker playback engine in Unity3D in C#. Rather a different beast, but surprisingly(?) I'm seeing a lot of similarities between some of its inner workings and your audio mixing code.

EDIT 2: Oh, wow, the conversion from PCM buffer to PWM was more straightforward than I thought :O
Interesting that you do it "in-place" so to speak - clear the buffer, write samples to it, then convert buffer in-place from PCM to PWM. I also was not expecting it to be entirely in C, I thought it would be implemented in assembly somewhere XD
Man, this is a fantastic resource for someone who just wants to learn how audio works on the 32X. Really a damn shame more games didn't take advantage of the insane flexibility this system has...

Post Reply