Horizontal Scroll not showing all background image

SGDK only sub forum

Moderator: Stef

danibus
Very interested
Posts: 78
Joined: Sat Feb 03, 2018 12:41 pm

Re: Horizontal Scroll not showing all background image

Post by danibus » Wed Jan 15, 2020 3:23 pm

Thanks Chilly Willy, changed with

Code: Select all

offsetTILES = (offset>>3) % 128;
//offset=0..1023 then offsetTILES=0..127

Anyway, I can see 1st tile-column (left part of visible tiles) updating.

I think I have to update in another place but not sure why, as 1st column dissapearing at left part (tile column 0 i.e.) would be the first tile to appear in the right part (non-visible part to scrolling)

Chilly Willy
Very interested
Posts: 2809
Joined: Fri Aug 17, 2007 9:33 pm

Re: Horizontal Scroll not showing all background image

Post by Chilly Willy » Wed Jan 15, 2020 10:43 pm

Oh, one other issue - you set the horz scroll, THEN you check if the value is > 1023 and wrap around. You should be checking for the wrap before setting the scroll offset. The way you have it now, for one frame, the hscroll regs will be -1024 while the tiles will be set to 0.

danibus
Very interested
Posts: 78
Joined: Sat Feb 03, 2018 12:41 pm

Re: Horizontal Scroll not showing all background image

Post by danibus » Wed Jan 15, 2020 10:51 pm

Thanks again Chilly Willy

Now it's like this

Code: Select all

[...]
    VDP_drawImageEx(PLAN_B, &bgd_image, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE);
    ind += bgd_image.tileset->numTile;
    VDP_setScrollingMode(HSCROLL_PLANE  ,VSCROLL_PLANE);

    s16 offset=512;           //PIXELS from 0 to 1023px
    s16 offsetTILES = 0;    //TILES, from 0 to 63 tiles

    while(TRUE) //main Loop
    {
	//here some sprite and control stuff
	[...]

	//now scrolling part 
        offsetTILES = (offset>>3) % 128;
        if(offset>1023){ offset = 0; offsetTILES = 0;}

        VDP_setHorizontalScroll(PLAN_B, -offset);
        VDP_setMapEx(PLAN_B, bgd_image.map, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, TILE_USERINDEX),offsetTILES, 0, offsetTILES, 0, 1, 28);
        offset++;
        
        VDP_waitVSync();
    }
[...]    
Anyway problem remains :|

I think I must update another tile-column, I tried different ways but not working properly.
My way is to update every tile-column when wraps using VDP_setMapEx() but it's done 1 or 2 pixels before moving out TV.

Here small gif to understand
(edit: slow motion video added)
https://prnt.sc/qoa1jh

Grind
Very interested
Posts: 65
Joined: Fri Jun 13, 2014 1:26 pm
Location: US
Contact:

Re: Horizontal Scroll not showing all background image

Post by Grind » Thu Jan 16, 2020 1:23 am

Offset 0 is always going to be the leftmost pixel/tile of the screen. Have to move it back and wrap it.

VDP_setMapEx(PLAN_B, bgd_image.map, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, TILE_USERINDEX),offsetTILES, 0, (offsetTILES-1) % 128, 0, 1, 28);

Try that? That -1 could be anything else depending on where you want to move the draw column.

danibus
Very interested
Posts: 78
Joined: Sat Feb 03, 2018 12:41 pm

Re: Horizontal Scroll not showing all background image

Post by danibus » Fri Jan 17, 2020 9:18 am

This is working but not for column-tile 127, not sure why but tile 127 are being painted with column-tile 63.
Just wait for moving 8 pixels to update tile, so it's painted out of "TV zone"


Code: Select all

[...]
s16 offset=512;
s16 offsetTILES = 0;
s16 offset_old = offset;

    while(TRUE)
    {
        offsetTILES = (offset>>3) & 127;

        VDP_setHorizontalScroll(PLAN_B, -offset);

        if((offset-offset_old)==8)
        {
                    VDP_setMapEx(PLAN_B, bgd_image.map, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, TILE_USERINDEX),
                                (offsetTILES-1) % 128, 0, (offsetTILES-1) % 128, 0, 1, 28);
                    offset_old = offset;
        }

        offset++;
        if(offset>1023){ offset = 0; offsetTILES = 0; offset_old = 0; }

        VDP_waitVSync();
    }

Post Reply