Volume envelope bug emulation

Discussion of programming and development for the original Game Boy and Game Boy Color.
Post Reply
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Volume envelope bug emulation

Post by mic_ »

Are there any GB emulators out there (preferably in form of a winamp input plugin) that emulates the hardware bug that lets you change the volume without restarting the channel by making bogus writes to the volume envelope generator registers?
I'm asking if someone knows, before I start trying out all of them to find out for myself.
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

VBA-M emulates it.

But this bug does not appear to exist on GBA hardware. On the GBA, you must use timers to know a good time to reset the sound channel.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Post by mic_ »

I'm only targeting DMG/CGB atm, so that's not an issue.
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Post by mic_ »

Actually it doesn't appear to be working at all in VBA-M 296. It's working the way I expect it to in no$gmb though. I'll have to test my code on my Gameboy when I get home..
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Post by mic_ »

But this bug does not appear to exist on GBA hardware.
It works on my GBA SP. I haven't tested it on my classic model GBA though.

As far as emulators are concerned, nezplug++ also emulates this "feature" (besides VBA-M).
User avatar
Dwedit
Posts: 4924
Joined: Fri Nov 19, 2004 7:35 pm
Contact:

Post by Dwedit »

Maybe the phantom volume envelope change bug is absent in GBA Mode? I don't have any GB games which trigger the bug, but I couldn't reproduce any GBA code to trigger the phantom volume envelope change bug. I tried a DS and DS Lite in GBA mode, an original Milky Blue Japanese GBA, and a US GBA SP.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Post by tepples »

Dwedit wrote:Maybe the phantom volume envelope change bug is absent in GBA Mode? I don't have any GB games which trigger the bug
Are GBC flash carts still available anywhere?
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Post by Bregalad »

Well where can I find information about what is the bug ?
As I understand it, the $F012/17/21 registers seems to allow writing an initial value, it can either stay as it, incrase or decrease at different speed depending on the low 4 bits.
What happens when a write is done to this register ? Does a click or something happen ? I admit I'm consused.
Useless, lumbering half-wits don't scare us.
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Post by mic_ »

http://gbdev.gg8.se/wiki/articles/Gameb ... e_Behavior
I've been using it in XPMCK for a couple of months (look for XPMP_ALT_GB_VOLCTRL in the GBC playback lib).
User avatar
Bregalad
Posts: 8056
Joined: Fri Nov 12, 2004 2:49 pm
Location: Divonne-les-bains, France

Post by Bregalad »

Oww this is overly complicated :(
Useless, lumbering half-wits don't scare us.
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Post by mic_ »

It's not that complicated. The idea is to avoid the distortions you get when you change the volume in the normal way, which requires restarting the channel.

In pseudo-code it works like this:

Code: Select all

#define ENVE_DIR_INC (0x08)

for (i = 0; i < ((newVolume - oldVolume) + 16) % 16; i++)
{
    NRx2 = ENVE_DIR_INC;
}
Lord Nightmare
Posts: 131
Joined: Wed Apr 05, 2006 10:12 am
Location: PA, USA
Contact:

Post by Lord Nightmare »

I know the non-reinit 'zombie' volume change stuff is supported by blargg's newest gb sound emu library, and is supported by my hacked up version of gnuboy's sound core (from 2003ish, way obsolete compared to blargg's core).

MESS does not support it (it is using a sound core based loosely on a 1998 or 1999 gnuboy core and sounds awful), but MESS doesn't play .gbs files, neither does gnuboy for that matter.

The older emulators (rew, smygbe, gbcemu) do not support it, and frankly I'm a bit surprised that no$gmb does.
kigb MIGHT support it.

gambatte (cgb emu) probably does support it, as sinamas, the author, worked closely with blargg on gambatte's sound core implementation.

LN
"When life gives you zombies... *CHA-CHIK!* ...you make zombie-ade!"
mic_
Posts: 922
Joined: Thu Oct 05, 2006 6:29 am

Post by mic_ »

and frankly I'm a bit surprised that no$gmb does
Actually, no$gmb does not emulate it iirc. When I wrote that it did I was testing incorrect code.
Post Reply