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.
KostaSaizo7 says:
Jul 23rd 2020
I am so glad you haven't given up!
WaluigiWare64 says:
Jul 23rd 2020
Nice!
Amnesia says:
Jul 23rd 2020
Great!
Ajinomotor says:
Jul 23rd 2020
So when's the release?
phantop says:
Jul 23rd 2020
Just wanna pop in and say grats on getting there with your gender marker! I’m kinda jelly, COVID is delaying my own transition by months.
screeeee says:
Jul 24th 2020
Hi, I downloaded the latest build under the Action tab on Github. It's really nice but the touchscreen coordinates are off. The clickable portion of the touchscreen is actually a bit further down than it appeared on screen. To illustrate it with numpad: if I press 7 on the numpad, nothing will appear; if I press 1 on the numpad, 4 will appear instead.

I'm on Win 10 1909 and have every 32 & 64bit Visual C++ redists installed. What am I missing?
Arisotura says:
Jul 24th 2020
you need to recalibrate the touchscreen
screeeee says:
Jul 24th 2020
@Arisotura Many thanks for the reply! Unfortunately that didn't work. I kept bashing my head against the wall when suddenly specifying the DSi files (BIOSes, Firmware, NAND) seemed to solve the problem. So, I guess you now need DSi files even if you're strictly using DS mode.
Arisotura says:
Jul 24th 2020
that's weird, because it's set to use the DS files if you're running in DS mode. I'll look into it.
screeeee says:
Jul 25th 2020
Ah, another thing which might be worth mentioning: after getting the touchscreen fixed, I no longer need the DSi files for the subsequent launch of melonDS. I could delete the DSi files and the touchscreen will still work properly.

I'd never used the Qt version before yesterday, so maybe something in the code force it to default to DSi mode when melonDS is launched for the first time?
straif says:
Jul 25th 2020
thanks for the write up! just wanted to let you know that the fast forward toggle hotkey doesnt seem to be working, but holding it seems doing just fine. (testing with pokemon platinum US version)

thank you so much for your dedication!
marvelball says:
Jul 26th 2020
your doing something that was up to this point unthinkable, please do go on, I wish you the best of luck with developing this emulator and also with your transition.
Sigma says:
Jul 26th 2020
Have you heard about ensata already? It's a Nintendo-made DS emulator that was even used to run commercial games which got leaked a few hours ago. I think it's worth checking out.
WaluigiWare64 says:
Jul 26th 2020
Ensata was leaked a long time ago.
https://emulation.gametechwiki.com/index.php/Ensata
Obluda says:
Jul 26th 2020
Nice !
Post a comment
Name:
DO NOT TOUCH