Page 1 of 1

Issue with scrolling that I just can't fix

Posted: Sat Feb 13, 2016 2:27 am
by POLYGAMe
So I've checked EVERYTHING and I can't see what's wrong. When I bend my road and leave the sky still, it works properly. My road bends to make a corner and the sky stays still.
Sky not scrolling - road bent.png
Sky not scrolling - road bent.png (16.81 KiB) Viewed 3438 times
When I scroll the sky but don't bend the road, that also works, I get a straight road and a scrolling sky.
Sky scrolling - road straight.png
Sky scrolling - road straight.png (19.4 KiB) Viewed 3438 times
The problem is, when I do both, for no reason the road portion is shifted quite a few tiles to the right and if I look really closely I can see random lines being scrolled every so slightly.
Sky scrolling - road bent.png
Sky scrolling - road bent.png (14.8 KiB) Viewed 3438 times
It makes no sense. All of the function parameters are correct.

Here is the code for the bend road function:

Code: Select all

void BendRoad(u16 ScrollValuesLength, fix32* ScrollValuesFloats, s16* ScrollValues, u16 iVertLine, u16 iLinesToScroll)
{
    u16 uOffset = 0;
    u16 i = 0;

    // ADJUST EACH LINE'S OFFSET (BEND ROAD)
    for (i = ScrollValuesLength - 1; i > 0; i--)
    {
        uOffset += 15;

        ScrollValuesFloats[i] = ScrollValuesFloats[i + 1] + uOffset;
        ScrollValues[i] = fix32ToInt(ScrollValuesFloats[i]);
    }

    // PERFORM LINE SCROLLING FOR ROAD
    VDP_setHorizontalScrollLine(PLAN_B, iVertLine, ScrollValues, iLinesToScroll, FALSE);
}
And here is the code for the scroll sky function:

Code: Select all

void ScrollSky(u16 skyScrollValuesLength, s16* skyScrollValues, u16 iSkyVertLine, u16 iSkyLinesToScroll)
{
    u16 i = 0;

    // SCROLL SKY
    for (i = 0; i < skyScrollValuesLength; i++)
    {
        skyScrollValues[i] -= 1; // TODO - CHANGE TO MATCH SPEED
    }

    // PERFORM LINE SCROLLING FOR SKY
    VDP_setHorizontalScrollLine(PLAN_A, iSkyVertLine, skyScrollValues, iSkyLinesToScroll, FALSE);
}

What could be causing this? Any help would be greatly appreciated as I'm really stuck!

Re: Issue with scrolling that I just can't fix

Posted: Sat Feb 13, 2016 7:59 pm
by r57shell
write equations, how much should be scroll on top of road.
and you'll see your bug.
reason is because you're calculating from bottom.

Re: Issue with scrolling that I just can't fix

Posted: Sun Feb 14, 2016 3:26 am
by POLYGAMe
r57shell wrote:write equations, how much should be scroll on top of road.
and you'll see your bug.
reason is because you're calculating from bottom.
Each plane is counting in different directions and meeting in the middle. The numbers are correct and even if they weren't I'm controlling the scrolling of the planes in separate functions so don't know why this should happen. They work fine when used on their own. I'll try something else to see if that's the case though... Cheers.

Re: Issue with scrolling that I just can't fix

Posted: Sun Feb 14, 2016 5:14 am
by POLYGAMe
r57shell wrote:write equations, how much should be scroll on top of road.
and you'll see your bug.
reason is because you're calculating from bottom.
Looks like you were right. I combined the two into one function and made it less messy and counted through all 224 lines in sequence and it works. Cheers!