Page 1 of 1
XGM driver hangs during fades
Posted: Wed Apr 20, 2016 1:49 pm
by cero
Whenever there's a fade, or just a loop of "for (i = 0; i < 180; i++) VDP_waitVSync();", the XGM driver just plays one note, as if it's stuck. Known issue? Any workarounds?
Re: XGM driver hangs during fades
Posted: Wed Apr 20, 2016 9:42 pm
by Stef
Weird issue, the only reason the XGM driver could hangs is that Z80 is interrupted for some reason.
Do you have a simple example as i already used fade and waitVsync() without problems.
Re: XGM driver hangs during fades
Posted: Thu Apr 21, 2016 7:50 am
by cero
Taking a closer look, it's not waitVsync(), but just the fade. It happens in multiple emulators.
Code: Select all
SND_startPlay_XGM(sample);
for (i = 0; i < 180; i++) VDP_waitVSync(); // the first time, this short song plays properly
VDP_fadeIn(1, 15, intropal, 30, 0); // during the fade, the first note hangs. After the fade it continues normally
This code is enough to show the issue. I'll try to make a distributable sample if you can't reproduce.
When I comment out the fades, the second time also plays properly.
Re: XGM driver hangs during fades
Posted: Thu Apr 21, 2016 7:56 am
by cero
Is it perhaps because the fade disables interrupts, and XGM does some processing in vint?
Code: Select all
// process asynchrone fading
if (async) VIntProcess |= PROCESS_PALETTE_FADING;
// process fading immediatly
else
{
// disable interrupts to avoid VDP accesses conflict
SYS_disableInts();
while (VDP_doStepFading(TRUE));
SYS_enableInts();
}
Re: XGM driver hangs during fades
Posted: Thu Apr 21, 2016 8:46 am
by Stef
Yeah it could be a problem as indeed VInt is used to define the XGM tempo... but normally as soon you re-enabled interrupt the VInt should happen immediately, also interrupts are never disabled for more than 1 frame so you shouldn't miss them. I will try to reproduce the issue and fix it.
In the meantime, just try to change your code that way :
Code: Select all
VDP_fadeIn(1, 15, intropal, 30, TRUE);
VDP_waitFadeCompletion();
That should be enough to fix your issue.
Edit: You're right, the problem occurs... i'm surprised that i never noticed it before !
Re: XGM driver hangs during fades
Posted: Tue May 03, 2016 8:40 am
by cero
Do you plan to fix this on the xgm side, by allowing interrupts during fades, or by allowing interrupts + clearing the pointers during the fade?
Re: XGM driver hangs during fades
Posted: Tue May 03, 2016 2:13 pm
by Stef
The problem is not on XGM side and i fixed it, will work fine in next version.
The problem was that i was disabling Interrupt during all the fading process which is something i shouldn't do ! Now interrupts are disabled only when i'm writing to the VDP

Re: XGM driver hangs during fades
Posted: Tue May 03, 2016 4:40 pm
by cero
I don't see it on github?
It's perfectly fine for master to be broken, or you could use a different branch if it's invasive. There are many people waiting for this new version, even if it's broken right now, please share the code.
Re: XGM driver hangs during fades
Posted: Tue May 10, 2016 2:51 pm
by cero
Stef, can you post the patch somewhere? I'd like to keep my sgdk in sync with the official fix, and I'd need this to work.
Re: XGM driver hangs during fades
Posted: Tue May 10, 2016 3:25 pm
by Stef
Oh sorry cero, i missed your last message. I will try to push on github when i will get back to home (in few hours). Sprite Engine is currently broken in my wip version so you may take only the fix you need (as vdp_pal.c for the fading part and XGM driver related stuff).
Re: XGM driver hangs during fades
Posted: Tue May 10, 2016 9:16 pm
by Stef
I updated vdp_pal.c and vdp_pal.h on github, i can't really update others parts, too much broken stuff :p
Re: XGM driver hangs during fades
Posted: Wed May 11, 2016 7:56 am
by cero
Thanks. master doesn't build due to multiple issues with vram.c, but I could just pull the relevant commits. I confirm the XGM issue is fixed.
Re: XGM driver hangs during fades
Posted: Wed May 11, 2016 11:46 am
by Stef
Yeah i need to add new commits but then i believe others issues will appears. Anyway it would be better as many people reported me issues which has been already fixed
