Background scrolling lags

SGDK only sub forum

Moderator: Stef

Post Reply
Arrovs
Interested
Posts: 18
Joined: Wed Sep 11, 2013 3:44 pm

Background scrolling lags

Post by Arrovs » Tue Mar 24, 2015 11:24 pm

Have anyone else experienced 1 pixel lags for part of lines when moving backgrounds - especially can feel when moving whole plane? Although speed is exactly 60 fps. Sprite movements dont lag.
If noone else have this problem possibly im doing something wrong with background setup.

Code: Select all

void Karte_zimet(Karte* p_karte)
{
	SYS_disableInts();
	u16 i, j;
	Laucins* _laucins;
	Image* _bilde;
	u16 _x = 0, _y = 0;
	u8 _vertiba;
	u16 _indeks, _pedejais_indeks = TILE_USERINDEX;
	VDP_setPalette(0, palette_black);
	VDP_setPalette(1, bmp_zale.palette->data);

	for(i = 0; i < p_karte->rindas; i++)
	{
		_x = 0;
		for(j = 0; j < p_karte->kolonnas; j++)
		{
			_vertiba = sisp(p_karte, iegut_saturu, i, j);
			_laucins = Laucini_iegut_laucinu(_vertiba);
			_bilde = _laucins->bilde;
			if(_laucins->ir_VRAM)
			{
				_indeks = _laucins->VRAM_indeks;
			}
			else
			{
				_indeks = _pedejais_indeks;
			}
			VDP_drawImageEx(VDP_PLAN_B, _bilde, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, _indeks), _x, _y, FALSE, TRUE);
			if(_laucins->ir_VRAM == ne)
			{
				_laucins->VRAM_indeks = _indeks;
				_pedejais_indeks += _bilde->tileset->numTile;
				_laucins->ir_VRAM = ja;
			}
			_x += _bilde->map->h;
		}
		_y += _bilde->map->w;
	}
	SYS_enableInts();
}
I use this for drawing map. Basically it gets numbers from map content array and searches global defined tiles/fields after then it finds index for tile(so for all same looking tiles there is only one set in VRAM) and pushes thise tile to VDP and keeps doing same for all map.
Atleast i dont see anything wrong in way i set up background, but i dont think SGDK have bug like this. So please help me.

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

Post by Stef » Fri Mar 27, 2015 2:13 pm

Your method to load the map appears to be very complex and should be really slow (call drawImageEx at each tile O_o ??).

I have explained in both topic here how to deal with the map :
viewtopic.php?t=1753
viewtopic.php?t=1949

Arrovs
Interested
Posts: 18
Joined: Wed Sep 11, 2013 3:44 pm

Post by Arrovs » Fri Mar 27, 2015 5:10 pm

Of course its a bit slower. Its possible to see it loading in like in 3 farmes, but that shouldnt mess things afterwards when all stuff is there in memory.

I kinda dont want to make whole image for map tilemap and also to make content array to actually know what is in this map. I better use one array and just procedurally make all afterwars.

VDP_fillTileMapRect could be alternative here, but is it faster than VDP_drawImageEx?

Arrovs
Interested
Posts: 18
Joined: Wed Sep 11, 2013 3:44 pm

Post by Arrovs » Mon Apr 06, 2015 3:17 pm

Try game and see yourself
Possibly game itself have some flaws for slowdown. Possibly too many sprites and drawing stuff, but that scrolling information screen have nothing more in cycle than scrolling. And as you see it scrolls fluent some seconds and than lags for some secs and it keeps cycling like this. If you run around in map doing nothing can see same effect. What is this thing?
Also gens mod already shows spy errors only from launching game. Does SGDK does something wrong in registers?

Post Reply