Is it possible to scroll two planes horizontally by line AND plane?

SGDK only sub forum

Moderator: Stef

Post Reply
POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Is it possible to scroll two planes horizontally by line AND plane?

Post by POLYGAMe » Fri Jan 29, 2016 9:42 pm

Okay, so I'm using line scrolling for my road. Works great thanks to a lot of help from Stef. The problem is, since I've set the horizontal scroll to 'line' I can't scroll my background as one image. Is it possible to somehow scroll the top half by plane and the bottom by line or even control the horizontal mode separately for each plane? Could this be achieved with interrupts? I'm not entirely sure how interrupts work.. but think I have an idea.

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

Re: Is it possible to scroll two planes horizontally by line AND plane?

Post by Stef » Sat Jan 30, 2016 12:45 pm

You cannot have different scrolling mode for each plane and so when line scrolling is enable you have to set it for every line.
You can does what you want with interrupt, mean you use the whole plan scrolling mode, but you modify it during H-Interrupt where you want to have finer control. That might be more trickier than just setting scroll value for each line though.

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Is it possible to scroll two planes horizontally by line AND plane?

Post by POLYGAMe » Sat Jan 30, 2016 7:21 pm

OK. I'll try setting it each line. Just hope it's fast enough and I don't see the sky warping/tearing.

r57shell
Very interested
Posts: 478
Joined: Sun Dec 23, 2012 1:30 pm
Location: Russia
Contact:

Re: Is it possible to scroll two planes horizontally by line AND plane?

Post by r57shell » Sun Jan 31, 2016 1:11 pm

POLYGAMe wrote:The problem is, since I've set the horizontal scroll to 'line' I can't scroll my background as one image.
wut :shock:
just put same value for each line.
Image

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Is it possible to scroll two planes horizontally by line AND plane?

Post by POLYGAMe » Sun Jan 31, 2016 6:20 pm

I haven't tried it but I just imagined that since you have to count through each line and set it separately that there would be noticeable warping as you can't move them all at exactly the same time. I guess if I'm waiting for v-sync between calls it could work. I'm new to this :) I'll give it a go today.

POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Re: Is it possible to scroll two planes horizontally by line AND plane?

Post by POLYGAMe » Mon Feb 01, 2016 1:56 am

Okay, so it works fine scrolling the sky too. The problem is, I have a weird issue when I activate it. Here's the function I have been using to test:

Code: Select all

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

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

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

    u16 j = 0;

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


    // PERFORM LINE SCROLLING FOR ROAD
    VDP_setHorizontalScrollLine(PLAN_B, iVertLine, ScrollValues, iLinesToScroll, FALSE); 
    // PERFORM LINE SCROLLING FOR SKY
    VDP_setHorizontalScrollLine(PLAN_A, iSkyVertLine, skyScrollValues, iSkyLinesToScroll, FALSE);
}


When I get rid of the second for loop it works fine (but the sky obviously doesn't scroll) but when I scroll the sky, the road shifts to the right a bit and I get some garbled graphics. Any ideas? I have checked all my pointers and variables and everything is correct... not sure why this would happen as that loop should ONLY affect the sky.

And yes I know the graphics are a bit messy, I haven't arranged the palette indexes properly yet and the images aren't tileable just now.

Oh, I should add that the sky and road are on different planes too.

EDIT: It seems to be this line:

Code: Select all

skyScrollValues[j] -= 1; // TODO - CHANGE TO MATCH SPEED
When I REM it out, it's fine. This makes no sense...
Attachments
frame_02.png
frame_02.png (9.98 KiB) Viewed 4287 times
farme_01.png
farme_01.png (10.38 KiB) Viewed 4287 times

Post Reply