π
<-
Chat plein-écran
[^]

scrolling rapide

C, C++, ASM...

scrolling rapide

Unread postby newprog_creator » 26 Sep 2023, 19:38

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: Select all
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);
       }

    }

}
User avatar
newprog_creatorProgrammeur
Niveau 7: EP (Espèce Protégée: geek)
Niveau 7: EP (Espèce Protégée: geek)
Level up: 74.2%
 
Posts: 67
Joined: 29 Mar 2014, 19:07
Gender: Not specified
Calculator(s):
MyCalcs profile
Class: bac+13

Re: scrolling rapide

Unread postby Adriweb » 28 Sep 2023, 21:27

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.

MyCalcs: Help the community's calculator documentations by filling out your calculators info!
MyCalcs: Aidez la communauté à documenter les calculatrices en donnant des infos sur vos calculatrices !
Inspired-Lua.org: All about TI-Nspire Lua programming (tutorials, wiki/docs...)
My calculator programs
Mes programmes pour calculatrices
User avatar
AdriwebAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 78.4%
 
Posts: 14675
Images: 1119
Joined: 01 Jun 2007, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Twitter: adriweb
GitHub: adriweb

Re: scrolling rapide

Unread postby newprog_creator » 30 Sep 2023, 11:53

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: Select all
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
User avatar
newprog_creatorProgrammeur
Niveau 7: EP (Espèce Protégée: geek)
Niveau 7: EP (Espèce Protégée: geek)
Level up: 74.2%
 
Posts: 67
Joined: 29 Mar 2014, 19:07
Gender: Not specified
Calculator(s):
MyCalcs profile
Class: bac+13


Return to Native: Ndless, Linux, ...

Who is online

Users browsing this forum: No registered users and 6 guests

-
Search
-
Social TI-Planet
-
Featured topics
Comparaisons des meilleurs prix pour acheter sa calculatrice !
"1 calculatrice pour tous", le programme solidaire de Texas Instruments. Reçois gratuitement et sans aucune obligation d'achat, 5 calculatrices couleur programmables en Python à donner aux élèves les plus nécessiteux de ton lycée. Tu peux recevoir au choix 5 TI-82 Advanced Edition Python ou bien 5 TI-83 Premium CE Edition Python.
Enseignant(e), reçois gratuitement 1 exemplaire de test de la TI-82 Advanced Edition Python. À demander d'ici le 31 décembre 2024.
Reprise de ton ancienne fx-92 Collège ou Graph 25/35/90 à 3€ peu importe son état. Même non fonctionnelle et donc invendable, même ancienne Graph 35 non conforme aux programmes (pas de Python), même ancienne Graph 25/35 inutilisable aux examens (pas de mode examen) et donc invendable. Etiquette de retour fournie, pas de frais de port à payer.
Aidez la communauté à documenter les révisions matérielles en listant vos calculatrices graphiques !
12345
-
Donations / Premium
For more contests, prizes, reviews, helping us pay the server and domains...
Donate
Discover the the advantages of a donor account !
JoinRejoignez the donors and/or premium!les donateurs et/ou premium !


Partner and ad
Notre partenaire Jarrety Calculatrices à acheter chez Calcuso
-
Stats.
1197 utilisateurs:
>1175 invités
>17 membres
>5 robots
Record simultané (sur 6 mois):
6892 utilisateurs (le 07/06/2017)
-
Other interesting websites
Texas Instruments Education
Global | France
 (English / Français)
Banque de programmes TI
ticalc.org
 (English)
La communauté TI-82
tout82.free.fr
 (Français)
cron