Page 8 of 10

Posted: Mon Mar 03, 2014 11:54 am
by matteus
Stef wrote:It's me, again a missed message.. i don't understand ^^
Well the compression information is given in the .res file, just look in the SPRITE definition of the rescomp.txt file, you will see that is pretty easy =)
Oh that's where the compression is defined! .RES file controls compression, etc Silly me! that's what the "-1" means!

Thanks Stef really appreciate the response :)

Posted: Mon Mar 03, 2014 1:24 pm
by Stef
matteus wrote: Oh that's where the compression is defined! .RES file controls compression, etc Silly me! that's what the "-1" means!

Thanks Stef really appreciate the response :)
Yeah exactly, the -1 parameter just mean "auto compression" so it will use the best compression scheme depending your image.
You can set it to 0 (no compression) or fixed value (1, 2...) to use a specific compression scheme.

Posted: Tue Mar 04, 2014 12:39 am
by matteus
Stef wrote:
matteus wrote: Oh that's where the compression is defined! .RES file controls compression, etc Silly me! that's what the "-1" means!

Thanks Stef really appreciate the response :)
Yeah exactly, the -1 parameter just mean "auto compression" so it will use the best compression scheme depending your image.
You can set it to 0 (no compression) or fixed value (1, 2...) to use a specific compression scheme.
Removed compress and now working at full speed (so much so I'm having to put a waittick in!

I'm presently optimising the palette in the next 10 seconds of animation to allow dithering to soften the low res of the animation, while maximising the colour.

Posted: Tue Mar 04, 2014 9:37 am
by matteus
Update video time: https://www.youtube.com/watch?v=a0YJu9p ... ata_player

Probably the last one for a while until I make decent progress animation wise :)

Posted: Tue Mar 04, 2014 6:28 pm
by Chilly Willy
Looks really good. :D

Posted: Tue Mar 04, 2014 10:55 pm
by Stef
Looks nice and smooth !
Test at least on Fusion as older emulators (as Gens) does not emulate VRAM access time so it will be a lot faster than Real Hardware in active period.

Posted: Wed Mar 05, 2014 12:35 am
by matteus
Update video:

http://youtu.be/3n5rci_SC2o

Managed to implement a masked frame on Pane A but seem to have lost the initial fade transition on the animation :(

I used

Code: Select all

VDP_setBackgroundColor(32);
Which I believe should have set the transparency to colour 0 of palette 3? I could be wrong :/

Update: Oh wait! Is it is because pane B uses a colour specific to it's palette own palette position 0. Which in most cases will be the only colour in a 1bpp image (doh) on the initial fade in???

Posted: Tue Mar 11, 2014 12:13 am
by matteus
I figured it has been a few days so it was time for an update :)

http://youtu.be/7yHF3VzqH9w

I'm not entirely sure whats happening with the tiles in some of the frames :/ I'm going to need to do some serious optimizing to keep the palettes displaying correctly!

Posted: Tue Mar 11, 2014 9:22 am
by matteus
Stef have you any idea what would cause the weird corruption in some frames? I can only guess it is something to do with the way I batch process the images or the way in which the SGDK converts the images to tiles...

What confused me is that the frames before and after the on screen corruption are not that different to one another.

Posted: Tue Mar 11, 2014 12:38 pm
by Stef
A good practice is to use sort of double buffering as i already explained, do you use it ? so while you are uploading an image the previous one remains visible and when the new one is ready you switch to it.
If you don't do that you may see corruption sometime as you may display an image partially changed. Another problem you may experience if the way you are dealing with VRAM, from what i remember you use a simple index position test, you should be sure that position test is safe enough...

Posted: Tue Mar 11, 2014 5:54 pm
by matteus
Stef wrote:A good practice is to use sort of double buffering as i already explained, do you use it ? so while you are uploading an image the previous one remains visible and when the new one is ready you switch to it.
If you don't do that you may see corruption sometime as you may display an image partially changed. Another problem you may experience if the way you are dealing with VRAM, from what i remember you use a simple index position test, you should be sure that position test is safe enough...
I get the impression it maybe because i'm still not entirely sure what the ind value is used for?

Code: Select all

    u16 ind = TILE_USERINDEX;
    u16 i = 0;
    u16 pal = PAL0;
    u16 ypos = 0;
    u16 vpos = 0;

    VDP_drawImageEx(APLAN, &border, TILE_ATTR_FULL(PAL3, FALSE, FALSE, FALSE, ind), 0, 0, TRUE, TRUE);
    VDP_setBackgroundColor(32);

    u16 newInd = TILE_USERINDEX + border.tileset->numTile;

        for(i = 0; i < 214; i++)
        {
            if(i == 37) {
               //music
                SND_startPlay_PCM(thundercats_music, sizeof(thundercats_music), SOUND_RATE_8000, SOUND_PAN_CENTER, FALSE);
            }
            u16 nextypos =  ypos ^ 0x20;
            VDP_setVerticalScroll(BPLAN, vpos);
            VDP_drawImageEx(BPLAN, images[i], TILE_ATTR_FULL(pal, FALSE, FALSE, FALSE, ind), 7, vpos + 4, TRUE, TRUE);
            if (ind == (newInd + 540)) {
                ind = newInd;
            } else {
                ind = newInd + 540;
            }
            pal ^= 1;
            waitTick(10);
            ypos = nextypos;
        }

    while(1)
    {
            VDP_waitVSync();
    }
    return 0;

Posted: Wed Mar 12, 2014 9:58 am
by matteus
I've modified the code (which I will post tonight).

I have been debugging the VRAM, while also displaying a count of the number of tiles in use on the A Plan.

The code makes sure that the tile count is big enough for 2 screen at 216x160 plus the A Plan border tiles.

I have notice some corruption towards the bottom of the VRAM not far beyond the allocated VRAM space for the Font tiles but I don't understand how that is becoming corrupted :/

Posted: Wed Mar 12, 2014 8:10 pm
by Stef
It would be nice if you can post the complete code as it seems some parts are missing in the one you posted !

Posted: Thu Mar 13, 2014 6:41 pm
by matteus

Code: Select all

#include <genesis.h>

#include "gfx.h"
#include "music.h"

int main()
{

   // initialization
    VDP_setScreenWidth320();

    const Image *images[214] = {
      &frame1,
      &frame2,
      &frame3,
      &frame4,
      &frame5,
      &frame6,
      &frame7,
      &frame8,
      &frame9,
      &frame10,
      &frame11,
      &frame12,
      &frame13,
      &frame14,
      &frame15,
      &frame16,
      &frame17,
      &frame18,
      &frame19,
      &frame20,
      &frame21,
      &frame22,
      &frame23,
      &frame24,
      &frame25,
      &frame26,
      &frame27,
      &frame28,
      &frame29,
      &frame30,
      &frame31,
      &frame32,
      &frame33,
      &frame34,
      &frame35,
      &frame36,
      &frame37,
      &frame38,
      &frame39,
      &frame40,
      &frame41,
      &frame42,
      &frame43,
      &frame44,
      &frame45,
      &frame46,
      &frame47,
      &frame48,
      &frame49,
      &frame50,
      &frame51,
      &frame52,
      &frame53,
      &frame54,
      &frame55,
      &frame56,
      &frame57,
      &frame58,
      &frame59,
      &frame60,
      &frame61,
      &frame62,
      &frame63,
      &frame64,
      &frame65,
      &frame66,
      &frame67,
      &frame68,
      &frame69,
      &frame70,
      &frame71,
      &frame72,
      &frame73,
      &frame74,
      &frame75,
      &frame76,
      &frame77,
      &frame78,
      &frame79,
      &frame80,
      &frame81,
      &frame82,
      &frame83,
      &frame84,
      &frame85,
      &frame86,
      &frame87,
      &frame88,
      &frame89,
      &frame90,
      &frame91,
      &frame92,
      &frame93,
      &frame94,
      &frame95,
      &frame96,
      &frame97,
      &frame98,
      &frame99,
      &frame100,
      &frame101,
      &frame102,
      &frame103,
      &frame104,
      &frame105,
      &frame106,
      &frame107,
      &frame108,
      &frame109,
      &frame110,
      &frame111,
      &frame112,
      &frame113,
      &frame114,
      &frame115,
      &frame116,
      &frame117,
      &frame118,
      &frame119,
      &frame120,
      &frame121,
      &frame122,
      &frame123,
      &frame124,
      &frame125,
      &frame126,
      &frame127,
      &frame128,
      &frame129,
      &frame130,
      &frame131,
      &frame132,
      &frame133,
      &frame134,
      &frame135,
      &frame136,
      &frame137,
      &frame138,
      &frame139,
      &frame140,
      &frame141,
      &frame142,
      &frame143,
      &frame144,
      &frame145,
      &frame146,
      &frame147,
      &frame148,
      &frame149,
      &frame150,
      &frame151,
      &frame152,
      &frame153,
      &frame154,
      &frame155,
      &frame156,
      &frame157,
      &frame158,
      &frame159,
      &frame160,
      &frame161,
      &frame162,
      &frame163,
      &frame164,
      &frame165,
      &frame166,
      &frame167,
      &frame168,
      &frame169,
      &frame170,
      &frame171,
      &frame172,
      &frame173,
      &frame174,
      &frame175,
    &frame176,
    &frame177,
    &frame178,
    &frame179,
    &frame180,
    &frame181,
    &frame182,
    &frame183,
    &frame184,
    &frame185,
    &frame186,
    &frame187,
    &frame188,
    &frame189,
    &frame190,
    &frame191,
    &frame192,
    &frame193,
    &frame194,
    &frame195,
    &frame196,
    &frame197,
    &frame198,
    &frame199,
    &frame200,
    &frame201,
    &frame202,
    &frame203,
    &frame204,
    &frame205,
    &frame206,
    &frame207,
    &frame208,
    &frame209,
    &frame210,
    &frame211,
    &frame212,
    &frame213,
    &frame214
    };

    u16 ind = TILE_USERINDEX;
    u16 i = 0;
    u16 pal = PAL0;
    u16 ypos = 0;
    u16 vpos = 0;
    char str[8];

    //while(1)
    //{

    VDP_drawImageEx(APLAN, &border, TILE_ATTR_FULL(PAL2, FALSE, FALSE, FALSE, ind), 0, 0, TRUE, TRUE);
    //VDP_setBackgroundColor(35);

    ind += border.tileset->numTile;

    u16 newInd = ind;

    u16 maxInd = newInd + 1080;

    intToStr(ind, str, 1);
    VDP_setTextPlan(APLAN);
    VDP_setTextPalette(PAL3);
    VDP_drawText(str, 0, 0);

        for(i = 174; i < 214; i++)
        {
            //if(i == 37) {
               //music
            //    SND_startPlay_PCM(thundercats_music, sizeof(thundercats_music), SOUND_RATE_8000, SOUND_PAN_CENTER, FALSE);
            //}
            if (ind == maxInd) {
                intToStr(maxInd, str, 1);
                VDP_drawText(str, 0, 1);
                ind = newInd;
            }
            u16 nextypos =  ypos ^ 0x20;
            VDP_setVerticalScroll(BPLAN, vpos);
            VDP_drawImageEx(BPLAN, images[i], TILE_ATTR_FULL(pal, FALSE, FALSE, FALSE, ind), 7, vpos + 4, TRUE, TRUE);
            ind += 540;

            pal ^= 1;
            //waitTick(10);
            waitTick(100);
            ypos = nextypos;
        }

    while(1)
    {
            VDP_waitVSync();
    }
    return 0;
}

Posted: Fri Mar 14, 2014 12:03 am
by Stef
Ok, some parts are really obscure and i'm even wondering how t worked ^^ You have 2 variables : vpos and ypos, you modify ypos only and use vpos only to define image position O_o ? Also you test ind with == instead of >= ...

Here is a version that should work better:

Code: Select all

...
maxInd = TILE_USERINDEX + TILE_USERLENGTH - 1;
...

for(i = 174; i < 214; i++)
{
    ...
    Image *img = images[i];
    // number of tile of current image
    u16 numTile = img->tileset->numTile;

    // no enough vram space for the current image ? restart 
    if ((ind + numTile) >= maxInd)
        ind = newInd;
            
    u16 nextvpos =  vpos ^ 0x20;
    VDP_drawImageEx(BPLAN, images[i], TILE_ATTR_FULL(pal, FALSE, FALSE, FALSE, ind), 7, nextvpos + 4, TRUE, TRUE);
    // move to new image
    VDP_waitVSync();
    VDP_setVerticalScroll(BPLAN, nextvpos);

    ind += numTile;
    pal ^= 1;
    vpos = nextvpos;
    waitTick(100);
}