1

voici mon algo en C, qui mappe sur un poly une bitmap de taille maxi 64*64...
qqun a-t-il une méthode + rapide
(les tests de clipping prennent bcp de temps)...
(ah vi une précision, je suis une merde en C, ms ça je pense ke vs l'aurez remarqué en parcourant mon code grin il marche bien, mais je suis ouvert à tout (à toutes les suggestions grin))

dans Filltext, x1,x2,x3,y1,y2,y3 sont les coords x et y de la face et txt1,txt2,txt3,tyt1,tyt2,tyt3 sont les coordonnées de chaque sommet de la face dans la texture...
voila:

/*******************************/
/* SCANLINE tracer             */
/*******************************/
void DrHtext(int y,int x1,int x2,long tx1,long ty1,long tx2,long ty2)
{
  long dx,temp;
  if(x1>x2)
  {
    temp=x2;
    x2=x1;
    x1=temp;
    temp=ty2;
    ty2=ty1;
    ty1=temp;
    temp=tx2;
    tx2=tx1;
    tx1=temp;
  }
  tx2-=tx1;
  ty2-=ty1;
  dx=x2-x1;
  tx2/=dx;
  ty2/=dx;
  for(;x1<x2;x1++)
  {
    Pixel4(x1,y,texture[ty1>>10][tx1>>10],(char*)VideoBuffer);
    tx1+=tx2;
    ty1+=ty2;
  }
}
/**************************************/
/* Pseudo ANTIALIASED SCANLINE tracer */
/**************************************/
void DrHtextaa(int y,int x1,int x2,long tx1,long ty1,long tx2,long ty2)
{
  long dx,temp;
  if(x1>x2)
  {
    temp=x2;
    x2=x1;
    x1=temp;
    temp=ty2;
    ty2=ty1;
    ty1=temp;
    temp=tx2;
    tx2=tx1;
    tx1=temp;
  }
  tx2-=tx1;
  ty2-=ty1;
  dx=x2-x1;
  tx2/=dx;
  ty2/=dx;
  for(;x1<x2;x1++)
  {
    Pixel4(x1, y, (texture[ty1>>10][tx1>>10] + texture[(ty1+32)>>10][(tx1+32)>>10] + texture[(ty1-32)>>10][(tx1-32)>>10])/3, (char*)VideoBuffer);
    tx1+=tx2;
    ty1+=ty2;
  }
}

/*******************************/
/* TEXTURE mapper              */
/*******************************/
void FillText(long x1,int y1,long x2,int y2,long x3,int y3,int txt1,int tyt1,int txt2,int tyt2,int txt3,int tyt3,char color)
{
  long temp, dy1, dy2, dy3, dty1, dty2, dty3;
  long dx1, dx2, dx3, x1add, x2add, x3add, dtx1, dtx2, dtx3, tx1add, tx2add, tx3add, ty1add, ty2add, ty3add;

  if(y1>y2) /* Trie les coordonées en fonction des y ascendants */
  {
    temp=y2;   //ué bon ça c'est une méthode de barbare... yapa un truc pour faire l'équivalent
    y2=y1;     //du exg.x dx,dx en asm 68000 ou du xchg en x86??? je ve dire, une fonction C ?
    y1=temp;
    temp=x2;
    x2=x1;
    x1=temp;
    temp=tyt2;
    tyt2=tyt1;
    tyt1=temp;
    temp=txt2;
    txt2=txt1;
    txt1=temp;
  }
  if(y1>y3)
  {
    temp=y3;
    y3=y1;
    y1=temp;
    temp=x3;
    x3=x1;
    x1=temp;
    temp=tyt3;
    tyt3=tyt1;
    tyt1=temp;
    temp=txt3;
    txt3=txt1;
    txt1=temp;
  }
  if(y2>y3)
  {
    temp=y2;
    y2=y3;
    y3=temp;
    temp=x2;
    x2=x3;
    x3=temp;
    temp=tyt2;
    tyt2=tyt3;
    tyt3=temp;
    temp=txt2;
    txt2=txt3;
    txt3=temp;
  }
  x1<<=8;
  x2<<=8;
  x3<<=8;
  txt1<<=10;
  txt2<<=10;
  txt3<<=10;
  tyt1<<=10;
  tyt2<<=10;
  tyt3<<=10;

  dx1=x2-x1;
  dy1=y2-y1;
  dx2=x3-x2;
  dy2=y3-y2;
  dx3=x1-x3;
  dy3=y1-y3;

  dtx1=txt2-txt1;
  dty1=tyt2-tyt1;
  dtx2=txt3-txt2;
  dty2=tyt3-tyt2;
  dtx3=txt1-txt3;
  dty3=tyt1-tyt3;

  if(dy1)
  {
    x1add=(dx1)/dy1;
    tx1add=(dtx1)/dy1;
    ty1add=(dty1)/dy1;
  }
  if(dy2)
  {
    x2add=(dx2)/dy2;
    tx2add=(dtx2)/dy2;
    ty2add=(dty2)/dy2;
  }
  if(dy3)
  {
    x3add=(dx3)/dy3;
    tx3add=(dtx3)/dy3;
    ty3add=(dty3)/dy3;
  }
/*******************************************/
/* PREMIERE PARTIE DE LA FACE              */
/*******************************************/
  txt3=txt1;
  tyt3=tyt1;
  x3=x1;
  for (;y1<y2;y1++)
  {
    if(y1>=0&&y1<=159)
      if(render_mode==4)
        DrHtextaa(y1,x3>>8,x1>>8,txt1,tyt1,txt3,tyt3);
      else
        DrHtext(y1,x3>>8,x1>>8,txt1,tyt1,txt3,tyt3);
    txt3+=tx3add;
    txt1+=tx1add;
    tyt3+=ty3add;
    tyt1+=ty1add;
    x3+=x1add;
    x1+=x3add;
  }
/*******************************************/
/* SECONDE PARTIE DE LA FACE               */
/*******************************************/
  for(;y2<y3;y2++)
  {
    if(y2>=0&&y2<=159)
      if(render_mode==4)
        DrHtextaa(y2,x2>>8,x1>>8,txt2,tyt2,txt3,tyt3);
      else
        DrHtext(y2,x2>>8,x1>>8,txt2,tyt2,txt3,tyt3);
    txt3+=tx3add;
    txt2+=tx2add;
    tyt3+=ty3add;
    tyt2+=ty2add;
    x2+=x2add;
    x1+=x3add;
  }
}

In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

2

et merde g trouvé le moyen de faire une fote de frappe dans le titre... grrrr
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

3

Avec les extensions du GNU C, tu devrais pouvoir arriver à faire des exg de 2 variables... Mais il faut bien évidemment mettre des register [nom de variable]...
Je ne sais pas comment faire avec le exg, mais pour le swap on fait comme ça (FastDrawHLine de ExtGraph):
#define ASM_SWAP(val) ({
register unsigned long tmp = val;
asm volatile ("swap %0" : "=d" (tmp) : "0" (tmp));
tmp;})
(quand on a un tableau d'unsigned shorts...)
avatar
Membre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
Co-admin de TI-Planet.

4

ah bon... merci smile (g pas tout compris, ms bon... le GNU asm et moi, ça fait pa la paire...)
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

5

euh, à part ça qqun aurait une idée pour ça?confus
personne?
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

6

Ben heu. Tu es tres loin de l'optimum je pense. Surtout dans la routine d'affichage horizontal.

7

T'as maté les sources de TN avec son FAT engine ? ca pourrrait etre instructif a mon avis wink

8

Pas vraiment. C'est assez fixe comme lecture de texture : soit horizontal, soit vertical. Pas obblique

9

vi, je me doute que j'en suis très loin, c'est pour ça que je poste ça ici smile
et l' "optimum" selon toi, ça ressemblerait à quoi?
(pas de code, juste un principe)
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

10

ahhhh j"ai les yeux qui burlent en voyant un code aussi nul !!! grin grin grin grin
"I read the game.dll assembly more easily than you read the joke on the back of your box of Cocoa Pebbles, and have spent the past 2 1/2 years navigating it." ©

11

ben vazy je t'en prie, arrange le grin
t'as tout le nécessaire pour le faire tongue
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

12

glandeur !!!!!! grin
*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & sabrina

13

ki?? moi???
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

14

vi, toi oui grin >> triso
*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & sabrina

15

je temmerde!!!
commence pas a flooder un topic sérieu kom ça grin
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

16

trop tard, lé déjà partit en cou*lle grin
*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & sabrina

17

ouiiinn mourn
trisohum
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

18

soit pas triste, be happy smile
*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & sabrina

19

bon, g fé ça: ça va un pe + vite ms pa bcp+...
verrai ça demain...
ah, vi, la texture est 16*16 (d'où le <<4 dans ((ty1)>>10)<<4))
et ne soyez pas tentés de dire qu'on peut simplifier ((ty1)>>10)<<4 en (ty1)>>6, pke ça ne marche PAS, il faut l'arrondi...
vala...

void DrHtext(int y,int x1,int x2,long tx1,long ty1,long tx2,long ty2)
{
  long dx,temp;
  unsigned char *dstt=(&texture[0][0]),*dsts=(char*)VideoBuffer;
  if(x1>x2)
  {
    temp=x2;
    x2=x1;
    x1=temp;
    temp=ty2;
    ty2=ty1;
    ty1=temp;
    temp=tx2;
    tx2=tx1;
    tx1=temp;
  }
  tx2-=tx1;
  ty2-=ty1;
  dx=x2-x1;
  tx2/=dx;
  ty2/=dx;
  dsts+=(y<<8)-(y<<4);
  for(;x1<x2;x1++)
  {
  *(dsts+x1)=*(dstt+(tx1>>10)+(((ty1)>>10)<<4));
    tx1+=tx2;
    ty1+=ty2;
  }
}

[edit]Edité par sBibi le 19-03-2002 à 01:22:39[/edit]
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

20

ouiiin c devenu un truc de barbare mourn
c gigantesque et g quasiment rien gagné... snif
put1 c koi le truc??!!
fé chier v le passer a l'asm et puis merde
en attendant qqun voit comment l'améliorer? (en vitesse)

ah oui... y a plus de fonction extérieure...
en + c dégeulasse comme truc, regardez un pe la quantité de vars qu'il y a... sad
c quasiment tout des longs, certains peuvent passer en int... mais à part ça vous voyez quelquechose a accélérer et comment le faire??

void FillText(long x1,int y1,long x2,int y2,long x3,int y3,int txt1,int tyt1,int txt2,int tyt2,int txt3,int tyt3,char color)
{
    long temp,dy1,dy2,dy3,dty1,dty2,dty3,xm1,xm2,dx,txtm1,txtm2,txtm3,tytm1,tytm2,tytm3;
    long dx1,dx2,dx3,x1add,x2add,x3add,dtx1,dtx2,dtx3,tx1add,tx2add,tx3add,ty1add,ty2add,ty3add;
    char *dstt=(&texture[0][0]),*dst=(char*)VideoBuffer,*dsts,*bla,*gni;

    if(y1>y2)        /* Trie les coordonées en fonction des y ascendants */
    {
        temp=y2;
        y2=y1;
        y1=temp;
        temp=x2;
        x2=x1;
        x1=temp;
        temp=tyt2;
        tyt2=tyt1;
        tyt1=temp;
        temp=txt2;
        txt2=txt1;
        txt1=temp;
    }
    if(y1>y3)
    {
        temp=y3;
        y3=y1;
        y1=temp;
        temp=x3;
        x3=x1;
        x1=temp;
        temp=tyt3;
        tyt3=tyt1;
        tyt1=temp;
        temp=txt3;
        txt3=txt1;
        txt1=temp;
    }
    if(y2>y3)
    {
        temp=y2;
        y2=y3;
        y3=temp;
        temp=x2;
        x2=x3;
        x3=temp;
        temp=tyt2;
        tyt2=tyt3;
        tyt3=temp;
        temp=txt2;
        txt2=txt3;
        txt3=temp;
    }
    x1<<=8;
    x2<<=8;
    x3<<=8;
    txt1<<=10;
    txt2<<=10;
    txt3<<=10;
    tyt1<<=10;
    tyt2<<=10;
    tyt3<<=10;

    dx1=x2-x1;
    dy1=y2-y1;
    dx2=x3-x2;
    dy2=y3-y2;
    dx3=x1-x3;
    dy3=y1-y3;

    dtx1=txt2-txt1;
    dty1=tyt2-tyt1;
    dtx2=txt3-txt2;
    dty2=tyt3-tyt2;
    dtx3=txt1-txt3;
    dty3=tyt1-tyt3;

    if(dy1)
    {
        x1add=(dx1)/dy1;
        tx1add=(dtx1)/dy1;
        ty1add=(dty1)/dy1;
    }
    if(dy2)
    {
        x2add=(dx2)/dy2;
        tx2add=(dtx2)/dy2;
        ty2add=(dty2)/dy2;
    }
    if(dy3)
    {
        x3add=(dx3)/dy3;
        tx3add=(dtx3)/dy3;
        ty3add=(dty3)/dy3;
    }
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

21

(suite)

/*******************************************/
/*       PREMIERE PARTIE DE LA FACE        */
/*******************************************/
    txt3=txt1;
    tyt3=tyt1;
    x3=x1;
    dst+=((y1<<8)-(y1<<4));
    if(x3add<x1add)
    {
        for (y1;y1<y2;y1++)
        {
            if(y1>=0&&y1<=159)
            {
                xm1=x1>>8;
                xm2=x3>>8;
                txtm1=txt3;
                tytm1=tyt3;
                txtm3=txt1;
                tytm3=tyt1;

                txtm3-=txtm1;
                tytm3-=tytm1;
                dx=xm2-xm1;
                txtm3/=dx;
                tytm3/=dx;
                dsts=dst+xm1;
                gni=dst+xm2;
                for(;dsts<gni;*(dsts++)=*(dstt+(txtm1>>10)+(((tytm1)>>10)<<4)))
                {
                    txtm1+=txtm3;
                    tytm1+=tytm3;
                }
            }
            dst+=240;
            txt3+=tx3add;
            txt1+=tx1add;
            tyt3+=ty3add;
            tyt1+=ty1add;
            x3+=x1add;
            x1+=x3add;
        }
        if(x2<x1)
        {
            temp=x2;
            x2=x1;
            x1=temp;
            temp=x2add;
            x2add=x3add;
            x3add=temp;
            temp=tytm3;
            tytm3=tytm2;
            tytm2=temp;
            temp=txtm3;
            txtm3=txtm2;
            txtm2=temp;
        }
        for(y2;y2<y3;y2++)
        {
            if(y2>=0&&y2<=159)
            {
                xm1=x1>>8;
                xm2=x2>>8;
                txtm2=txt3;
                tytm2=tyt3;
                txtm3=txt2;
                tytm3=tyt2;

                txtm3-=txtm2;
                tytm3-=tytm2;
                dx=xm2-xm1;
                txtm3/=dx;
                tytm3/=dx;
                dsts=dst+xm1;
                gni=dst+xm2;
                for(;dsts<gni;*(dsts++)=*(dstt+(txtm2>>10)+(((tytm2)>>10)<<4)))
                {
                    txtm2+=txtm3;
                    tytm2+=tytm3;
                }
            }
            dst+=240;
            txt3+=tx3add;
            txt2+=tx2add;
            tyt3+=ty3add;
            tyt2+=ty2add;
            x2+=x2add;
            x1+=x3add;
        }
    }else{
        for (y1;y1<y2;y1++)
        {
            if(y1>=0&&y1<=159)
            {
                xm1=x3>>8;
                xm2=x1>>8;
                txtm1=txt1;
                tytm1=tyt1;
                txtm3=txt3;
                tytm3=tyt3;

                txtm3-=txtm1;
                tytm3-=tytm1;
                dx=xm2-xm1;
                txtm3/=dx;
                tytm3/=dx;
                dsts=dst+xm1;
                gni=dst+xm2;
                for(;dsts<gni;*(dsts++)=*(dstt+(txtm1>>10)+(((tytm1)>>10)<<4)))
                {
                    txtm1+=txtm3;
                    tytm1+=tytm3;
                }
            }
            dst+=240;
            txt3+=tx3add;
            txt1+=tx1add;
            tyt3+=ty3add;
            tyt1+=ty1add;
            x3+=x1add;
            x1+=x3add;
        }
        if(x2>x1)
        {
            temp=x2;
            x2=x1;
            x1=temp;
            temp=x2add;
            x2add=x3add;
            x3add=temp;
            temp=tytm3;
            tytm3=tytm2;
            tytm2=temp;
            temp=txtm3;
            txtm3=txtm2;
            txtm2=temp;
        }
        for(y2;y2<y3;y2++)
        {
            if(y2>=0&&y2<=159)
            {
                xm1=x2>>8;
                xm2=x1>>8;
                txtm2=txt2;
                tytm2=tyt2;
                txtm3=txt3;
                tytm3=tyt3;

                txtm3-=txtm2;
                tytm3-=tytm2;
                dx=xm2-xm1;
                txtm3/=dx;
                tytm3/=dx;
                dsts=dst+xm1;
                gni=dst+xm2;
                for(;dsts<gni;*(dsts++)=*(dstt+(txtm2>>10)+(((tytm2)>>10)<<4)))
                {
                    txtm2+=txtm3;
                    tytm2+=tytm3;
                }
            }
            dst+=240;
            txt3+=tx3add;
            txt2+=tx2add;
            tyt3+=ty3add;
            tyt2+=ty2add;
            x2+=x2add;
            x1+=x3add;
        }
    }
}
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

23

euh... ué grin et a part ça t'as pas une idée pour l'accélérer un peu? grin
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

24

mouarf il a des idées lui ?

...flooder de merde vtff
avatar
All right. Keep doing whatever it is you think you're doing.
------------------------------------------
Besoin d'aide sur le site ? Essayez par ici :)

25

Ta routine est destinée à etre en asm, non?
Donc faut accelerer l'algo?
ATARI ruuullllleeeezzzzz!!!!!!

26

oui, la c'est juste pour accélérer l'algo en lui même...
mais je la teste en c sur la gba...
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

27

moi, j'ai un petit probleme ...

j'ai fais une routine de texture de triangles mais je me pose une petite qn, comment je fais pr que ts les triangles texturés fassent qqch de correct, car ca risque de faire en gros une texture potable avec pleins de petits bouts de textures autours !

28

Je me demande si la vitesse de la mem video de la gba n'est pas limite.

SBibi: penses a la boucle critique : lectue / incrementation / ecriture.

Perso en 68k, c'est :

 addx.w d0,d1
 add.w d2,d3
 tst.b d1
 bge.s ok
  and.b d4,d1
  add.w d5,d3
ok
 add.w d6,d6
 or.b 0(a1,d3.w),d6

Voila.

29

>Je me demande si la vitesse de la mem video de la gba n'est pas limite.
surement... mais mon flat filler sur gba utilise une boucle barbare qui remplit les octets un a un, juste un for(;x1<x2;x1++) et un putpixel... et ça va plus vite que le texture mapper, dc je pense pas que ça vienne de là... menfin bon... v le passer en asm 68k, là ça devrait être mieux... smile
merci smile

ce code, c'est la boucle du traceur de scanlines de ton texture mapper sur 68k ?
In many respects the Yoshi is like a beautiful woman. A man can come so enamoured that he bestows on her all his time, his energy and his fortune.
- Fred whipple, 1960

*** Ne sous-estimez pas la puissance de la Marmotte ***
© Marmotte Team : LaMarmotte, sBibi, Vark & Sabrina

30

C'est la routine d'avancee du pointeur dans la texture, de lecture d'un pixel dans la texture, et d'ecriture dans le tampon de sortie smile