XGM driver hangs during fades

SGDK only sub forum

Moderator: Stef

Post Reply
cero
Very interested
Posts: 259
Joined: Mon Nov 30, 2015 1:55 pm

XGM driver hangs during fades

Post by cero » Wed Apr 20, 2016 1:49 pm

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?

Stef
Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: XGM driver hangs during fades

Post by Stef » Wed Apr 20, 2016 9:42 pm

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.

cero
Very interested
Posts: 259
Joined: Mon Nov 30, 2015 1:55 pm

Re: XGM driver hangs during fades

Post by cero » Thu Apr 21, 2016 7:50 am

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.

cero
Very interested
Posts: 259
Joined: Mon Nov 30, 2015 1:55 pm

Re: XGM driver hangs during fades

Post by cero » Thu Apr 21, 2016 7:56 am

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();
    }

Stef
Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: XGM driver hangs during fades

Post by Stef » Thu Apr 21, 2016 8:46 am

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 !

cero
Very interested
Posts: 259
Joined: Mon Nov 30, 2015 1:55 pm

Re: XGM driver hangs during fades

Post by cero » Tue May 03, 2016 8:40 am

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?

Stef
Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: XGM driver hangs during fades

Post by Stef » Tue May 03, 2016 2:13 pm

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 :)

cero
Very interested
Posts: 259
Joined: Mon Nov 30, 2015 1:55 pm

Re: XGM driver hangs during fades

Post by cero » Tue May 03, 2016 4:40 pm

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.

cero
Very interested
Posts: 259
Joined: Mon Nov 30, 2015 1:55 pm

Re: XGM driver hangs during fades

Post by cero » Tue May 10, 2016 2:51 pm

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.

Stef
Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: XGM driver hangs during fades

Post by Stef » Tue May 10, 2016 3:25 pm

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).

Stef
Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: XGM driver hangs during fades

Post by Stef » Tue May 10, 2016 9:16 pm

I updated vdp_pal.c and vdp_pal.h on github, i can't really update others parts, too much broken stuff :p

cero
Very interested
Posts: 259
Joined: Mon Nov 30, 2015 1:55 pm

Re: XGM driver hangs during fades

Post by cero » Wed May 11, 2016 7:56 am

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.

Stef
Very interested
Posts: 2976
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: XGM driver hangs during fades

Post by Stef » Wed May 11, 2016 11:46 am

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 ;)

Post Reply