maxmod fixes
Sorry for the silence lately -- these times are getting pretty busy. melonDS wise, we're trying to perfect the JIT and the few other things we want for the 0.9 release. Real life wise, on my side, I'm starting the procedure to get my gender marker updated, which is going to be the last big thing for my transition.

Anyway, just yesterday, asie told me that maxmod's interpolated mode was broken in melonDS, which piqued my curiosity.

What's maxmod, you ask? It's a real fancy audio library for the GBA and DS. I don't know much about the GBA side of it, but on the DS, it supports three modes: hardware mode, interpolated mode, and extended mode. Hardware mode is fairly straightforward. Interpolated mode resamples audio on the fly, applying interpolation to make up for the lack of hardware interpolation. Extended mode does its own mixing, adding support for more channels than the hardware can offer.

In our case, interpolated mode was broken, outputting pretty much short high-pitched beeps and nothing else. I was curious to see if maxmod used any of the fancy audio capture/output modes that melonDS doesn't support (because no commercial game uses them, and my policy is to avoid implementing things until I have test cases). melonDS is set to report if any such features are being used, but in this case, it didn't report anything out of the ordinary. So this meant I'd have to dig further.

Quick regression testing showed that interpolated mode worked okay-ish on melonDS versions prior to 0.6. Well, it didn't sound as it should, but it was atleast reasonably close, instead of just being high-pitched beeps.

So apparently it was completely broken when sound FIFOs were implemented. The FIFO logic was fine, but the addition of that feature worsened the consequences of a bug that had always been there.

I logged what was going on during playback, to try and figure out where it failed. It appeared that the data being fed to the audio channels was fine, but, for whatever reason, the channels themselves failed to actually pull the data from memory. More logging revealed some strange things, like how certain things started at zero when they shouldn't. Notably, the channel timers started at zero, when they're supposed to start at the SOUNDxTMR reload value. But also, the FIFO level started at zero, causing it to immediately go negative and break the FIFO filling logic.

For a while, I scratched my head at all that, until it finally clicked.

In interpolated mode, maxmod will first disable the mixer, then sequentially initialize the channel registers, then enable the mixer, letting all channels start in perfect sync.

Thing is, at this point, for each channel, SOUNDxCNT is initialized with the start bit set, and before the other channel registers are set (because SOUNDxCNT comes first). This messed with the way melonDS initialized its channels, because it expected everything to be ready by the time the SOUNDxCNT start bit is set. But, obviously, here, it wasn't the case, and most things being zero fucked everything up.

So I quickly revised melonDS to only perform channel initialization as soon as the channel can actually run. And, hey, that did the trick -- maxmod's interpolated mode sounds fine now.

That being said, I still want to check for any tests that use the unimplemented capture/output modes.
Sigma says:
Jul 26th 2020
@WaluigiWare64 I'm so sorry! I spoke too soon. When I read about it it was pretty vague, I didn't know it was the source code they leaked and not the emulator itself. Still, it's a pretty neat find!
Tuition_Free says:
Jul 26th 2020
So 9 will be a pretty big update!
AsPika2219 says:
Jul 27th 2020
Never give up! 👍 Waiting for next release!
Nixel says:
Jul 27th 2020
Sounds like you're making good progress, both on the emu front and the real life front! I hope everything goes well!
Emulate since 2009 says:
Aug 5th 2020
Is connectivity to Dolphin planned for games like Pokemon Battle Revolution which could connect to a DS game to Wii to use the Pokemon from the DS save in Battle Revolution. Sort of like the game boy Pokemon games connecting to Nintendo 64 for the same reason and unlock a few things which is possible in emulators for Windrows and Android. Haven't seen DS to Wii connectivity yet in any emulator and the more time passes the less hopes I have to finally see this obscure feature emulated.
Emulate since 2009 says:
Aug 5th 2020
Also shame how the Pokewalker never got emulated in any DS emulators
WaluigiWare64 says:
Aug 6th 2020
I think the Pokewalker uses the IR sensor.
Generic aka RSDuck says:
Aug 6th 2020
we know these peripherals exists though we're already occupied with what we're currently doing. Additionally there's no documentation for the IR transceiver nor the Pokewalker, while there are still plenty of peripherals with documentation which are unimplemented. Feel free to do some REing yourself and implementing it. In theory there's nothing standing in the way of Wii <-> DS communication (besides local wireless just being a bit wonky in general), Dolphin only needs to pickup the signal melonDS is already sending.
Emulate since 2009 says:
Aug 6th 2020
So can the dolphin devs collaborate with melonds devs to make a working connection between those two emulators?
poudink says:
Aug 11th 2020
according to what generic just said, there's nothing for the melonDS devs to do, since it's already sending the signal. the dolphin devs are the ones that need to do the remaining work for DS <-> Wii connectivity.
Rian Caio says:
Aug 15th 2020
The 0.9 will have any improvidents to local wifi connection
Rian Caio says:
Aug 15th 2020
Local Multiplayer i say
BigMan says:
Aug 15th 2020
Hey man, when is 0.9 coming out? And where is the better wi-fi build. I though the main dev dude said he made a version what works without libpcap, but then he never did end up posting ig.
BigMan says:
Aug 15th 2020
*it, sorry
WaluigiWare64 says:
Aug 15th 2020
libslirp (the better wi-fi) was merged into master. You can find the latest builds here - https://github.com/Arisotura/melonDS/actions
Post a comment
Name:
DO NOT TOUCH