Theorical question about the planes

SGDK only sub forum

Moderator: Stef

Post Reply
alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Theorical question about the planes

Post by alko » Fri Dec 18, 2015 12:13 pm

how to fast draw compressed images ("-1" in gfx.res) on the planes for real-time animation consisting of 2 or 3 frames ?
Image

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

Re: Theorical question about the planes

Post by Stef » Fri Dec 18, 2015 1:05 pm

There is no way of doing real time fast compressed video.
Even without compression the bandwidth alone is not fast enough to allow fullscreen animation at 20 FPS.
You need to enlarge blank period if you want fast and large animation and so reduce the vertical resolution or you need to reduce the animation resolution (something as 160x128) to get 20 FPS without touching blanking.

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Theorical question about the planes

Post by alko » Fri Dec 18, 2015 4:30 pm

I do not need a very fast frame rates.
at least to update image does not slow down the gameplay, and that is not visible process of updating pictures.

Code: Select all

main()
{
....
while(1)
{
update_game();
fon_anim();
}
}


static void fon_anim()
{
fon_anim_count++;
if(fon_anim_count==5)
{ 
VDP_drawImageEx(BPLAN, &image1, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE);
//ind += fon1.tileset->numTile;
}
if(fon_anim_count==10){ 
VDP_drawImageEx(BPLAN, &image2, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, ind), 0, 0, FALSE, TRUE);
//ind += fon1.tileset->numTile;
}
if(fon_anim_count>=15)fon_anim_count=0;
}
Image

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

Re: Theorical question about the planes

Post by cero » Fri Dec 18, 2015 4:34 pm

To do it slow, and not have partial updates show, you need to double buffer. Which means: both planes will be used for your animation, nothing left for your game but sprites.

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Theorical question about the planes

Post by alko » Fri Dec 18, 2015 7:46 pm

if do not use compression then picture is updated faster, but the lag is still there.
Image

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Theorical question about the planes

Post by alko » Sat Dec 26, 2015 4:28 pm

however, mirroring planes useful in the development of top-down games for generate terrain.

for example:
Image
Image

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

Re: Theorical question about the planes

Post by Stef » Sat Dec 26, 2015 6:03 pm

Of course it is :-) It's why tilemap are always optimized to handle flipped tiles whatever is the compression parameter.

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Theorical question about the planes

Post by alko » Mon Dec 28, 2015 12:33 pm

how to fast fill a PLANE of the array identical pictures (for example 32*32 or 64*64 each picture) directly from VDP-RAM :?:
Image

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

Re: Theorical question about the planes

Post by Stef » Mon Dec 28, 2015 2:36 pm

Not sure to understand what you mean, fast fill tilemap ? Or fast fill tile data ?

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Theorical question about the planes

Post by alko » Tue Dec 29, 2015 8:20 am

let us suppose have a picture img1 (size 32*32)
if to do

Code: Select all

int i;
int j;
for(i=0;i<10;i++)
{
for(j=0;j<8;j++)
{
VDP_drawImageEx(BPLAN, &img1, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, ind), i*4, j*4, FALSE, TRUE);
}
}
then it turns out that every time the image is decompressed from the ROM in the VDP-RAM.
Image

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

Re: Theorical question about the planes

Post by Stef » Tue Dec 29, 2015 11:29 am

alko wrote:let us suppose have a picture img1 (size 32*32)
if to do

Code: Select all

int i;
int j;
for(i=0;i<10;i++)
{
for(j=0;j<8;j++)
{
VDP_drawImageEx(BPLAN, &img1, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, ind), i*4, j*4, FALSE, TRUE);
}
}
then it turns out that every time the image is decompressed from the ROM in the VDP-RAM.
Indeed. An image is composed from a TileSet (set of tiles) and a Map (tilemap), here what you want to do it just updating the tilemap in the loop so you can just start by uploading the tileset once then updating the tilemap :

Code: Select all

int i, j;
Map map*;

// upload TileSet of image in VRAM (unpack tileset first if needed)
VDP_loadTileSet(img1.tileset, ind, TRUE);
// load the palette
VDP_setPalette(PAL1, img1.palette->data);
// unpack the map once so we don't do it as each setMap(..) call
map = unpackMap(img.map, NULL);

for(i=0;i<10;i++)
{
  for(j=0;j<8;j++)
  {
    // wait for VSync
    VDP_waitVSync();
    VDP_setMap(VDP_PLAN_B, map, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, ind), i*4, j*4);
  }
}
And that is !

alko
Very interested
Posts: 172
Joined: Thu Aug 07, 2014 9:31 am
Location: Russian Federation

Re: Theorical question about the planes

Post by alko » Tue Mar 08, 2016 5:36 am

is possible to set visible or invisible plane ?
Image

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

Re: Theorical question about the planes

Post by Stef » Tue Mar 08, 2016 8:37 pm

Err no... You have to modify the tilemap and set it to transparent tiles only :-/

Post Reply