Page 1 sur 1

scrolling rapide

Message non luPosté: 26 Sep 2023, 19:38
de newprog_creator
Bonjour à la communauté,
Je me demande comment coder une fonction de scrolling (vers le haut par exemple, nombre de lignes spécifiées possibles) qui soit rapide. Sur ti83pce, le jeu oiram ce le fait avec une vitesse convenable. On devrait pouvoir faire de même sur ti nspire je pense (en plus le processeur est plus rapide).

J'ai créer le code suivant qui est très lent (seulement 10 exécutions par seconde) :
Code: Tout sélectionner
int scrollup(void)
{
    signed int x,y,w,h,ix,iy,iw,ih;
    int _x,_y,_w,_h,_xori,_wori,n,_xa,_xb;
    unsigned int nb_pix,n32,*uiptr,n16;   //ori
    unsigned short *usptr;
    ptr++;
    x=((*(fonc[*(ptr)]))()); //coin superieur gauche
    y=((*(fonc[*(ptr)]))()); //"           "         "
    w=((*(fonc[*(ptr)]))()); //width
    h=((*(fonc[*(ptr)]))()); //height
    nb_pix=((*(fonc[*(ptr)]))());

    _x= max(x, 0); _y = max(y, 0); _w = min(320 - _x, w - _x + x); _h = min(240 - _y, h - _y + y);

    if(_x%2)
    {
        for(iy=_y;iy<_y+_h-nb_pix;iy++)
        {
            *(lcdad+_x+iy*320)=*(lcdad+_x+(iy+nb_pix)*320);
        }
        _xa=_x+1;
    }
    else _xa=_x;
    if((_x+_w)%2)
    {
        //for(iy=_y+_h-1;iy>_y+nb_pix;iy--)
        for(iy=_y;iy<_y+_h-nb_pix;iy++)
        {
            *(lcdad+(_x+_w-1)+iy*320)=*(lcdad+(_x+_w-1)+(iy+nb_pix)*320);
        }
        _xb=_x+_w-1;
    }
    else _xb=_x+_w;

    //for(iy=_y+_h-1;iy>_y+nb_pix;iy--)
    for(iy=_y;iy<_y+_h-nb_pix;iy++)
    {
       for(ix=_xa;ix<_xb;ix+=2)
       {
           *(unsigned int *)(lcdad+ix+iy*320) = *(unsigned int *)(lcdad+ix+(iy+nb_pix)*320);
       }

    }

}

Re: scrolling rapide

Message non luPosté: 28 Sep 2023, 21:27
de Adriweb
Vogtinator a dit :
Unrolling would probably help and if this works on the framebuffer area in RAM it'll be rather slow as that is uncached. It can be faster to do all the work in an off-screen buffer and memcpy resp. lcd_blit into the active buffer.

Re: scrolling rapide

Message non luPosté: 30 Sep 2023, 11:53
de newprog_creator
Bonjour,
Je ne suis pas sur de comprendre tous les termes techniques. Je peux dire que je n'utilise pas nSDL.
Il y a til moyen d'avoir un exemple de code en se basant par exemple sur le code raccourci suivant (scrolling de 1 pixel sur tout l'écran) :

Code: Tout sélectionner
int scrollup2(void)
{
    signed int x,y,w,h,ix,iy,iw,ih;
    int _x,_y,_w,_h,_xori,_wori,_xa,_xb;
    unsigned int nb_pix,n32,*uiptr,*uiptr1,*uiptr2,n16;   //ori
    unsigned short *usptr,n;

    for(iy=0;iy<240-1;iy++) //lcd heigth == 240
    {
       uiptr1=(unsigned int *)(lcdad+iy*320);
       uiptr2=(unsigned int *)(lcdad+iy*320+320);
       n=0;
       while(n++<160)       //lcd width==320 ; 160=320/2
       {
           *(uiptr1++)=*(uiptr2++);
           //n++;
       }
    }
}


Merci par avance