π
<-

nKaruga

C, C++, ASM...

Re: nKaruga

Unread postby Hayleia » 31 May 2014, 08:18

matref wrote:Je crois que j'ai rien oublié niveau include etoo.

Je crois que t'as oublié quelque chose :P
J'ai error: unknown type name 'Fixed'. Il doit juste manquer un #define :)

Image
ImageImageImage
Pokemon Topaze (Axe) discussion and download links here
(19:29:36) noelnadal: plus sérieusemen​t, j'ai très peu de problèmes
(22:45:44) Clifward: J'aime rire du malheur des autres :troll:

(2017.11.18 - 17:07:12) Fireworks: Hayleia !!!!!
(2017.11.18 - 17:07:19) TI-Bot: Fireworks has been logged out (Kicked).
(2017.11.18 - 17:07:22) TI-Bot: Ban of user Fireworks revoked.
(2017.11.18 - 17:07:25) TI-Bot: Fireworks logs into the Chat.
(2017.11.18 - 17:07:28) Fireworks: <3
(2017.11.18 - 17:07:31) Fireworks: 208
User avatar
HayleiaGénéreux
Niveau 17: GM (Grand Maître des calculatrices)
Niveau 17: GM (Grand Maître des calculatrices)
Level up: 43.8%
 
Posts: 2509
Images: 2
Joined: 30 Aug 2011, 08:22
Gender: Not specified
Calculator(s):
MyCalcs profile
Class: Templar

Re: nKaruga

Unread postby Lionel Debroux » 31 May 2014, 08:26

Ou un include.
Membre de la TI-Chess Team.
Co-mainteneur de GCC4TI (documentation en ligne de GCC4TI), TIEmu et TILP.
User avatar
Lionel DebrouxSuper Modo
Niveau 14: CI (Calculateur de l'Infini)
Niveau 14: CI (Calculateur de l'Infini)
Level up: 11.3%
 
Posts: 6865
Joined: 23 Dec 2009, 00:00
Location: France
Gender: Male
Calculator(s):
MyCalcs profile
Class: -
GitHub: debrouxl

Re: nKaruga

Unread postby matref » 31 May 2014, 08:30

Ben non, juste typedef int Fixed;.
User avatar
matref
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 25%
 
Posts: 506
Joined: 11 Dec 2011, 03:08
Location: France, Châteaurenard
Gender: Male
Calculator(s):
MyCalcs profile
Class: Prépa MPSI

Re: nKaruga

Unread postby Hayleia » 31 May 2014, 08:47

matref wrote:Ben non, juste typedef int Fixed;.

Merci, ça compile ^^

Par contre même s'il compile, mon adaptation de ton code ne marche pas :'(
Code: Select all
#include <nspireio.h>
#include <stdio.h>
#include <os.h>
#include <libndls.h>
#include <stdlib.h>

#define K_ESC isKeyPressed(KEY_NSPIRE_ESC)
#define K_ENTER isKeyPressed(KEY_NSPIRE_ENTER)
#define K_TAB isKeyPressed(KEY_NSPIRE_TAB)
#define K_A isKeyPressed(KEY_NSPIRE_A)
#define K_7 isKeyPressed(KEY_NSPIRE_7)
#define K_9 isKeyPressed(KEY_NSPIRE_9)
#define K_8 isKeyPressed(KEY_NSPIRE_8)
#define K_5 isKeyPressed(KEY_NSPIRE_5)
#define K_4 isKeyPressed(KEY_NSPIRE_4)
#define K_6 isKeyPressed(KEY_NSPIRE_6)

typedef int Fixed;
// Fixed
// 24.8 fixed point
#define itofix(x) ((x)<<8)
#define fixtoi(x) ((x) >> 8)
#define fixmul(x, y) ((x)*  (y) >> 8)
#define fixdiv(x, y) (((x)<<8) / (y))

#define fixsin(x) fixcos((x)-64)

//le format utilisé par NTI est:
//42 dans le premier octet suivi de la version dans le deuxième octet
//le deuxième short est la hauteur
//le troisième short est la largeur
//le quatrième short est 0
//les autres sont les pixels au format rgb565
//
//on elève le premier short
//on remplace le 3e short (à 0x0000 pour NTI) par la couleur qu'on veut transparente
static unsigned short sprite[] = {
   0x0011,0x000C,0x001f,0x001f,0x001f,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0x001f,0x001f,0x001f,0x001f,0xb5b6,0xffff,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0x001f,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xdc2b,0xdc2b,0xdc2b,0xdc2b,0xdc2b,0xdc2b,0xdc2b,0xffff,0xffff,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xdc2b,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xdc2b,0xffff,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xfced,0xfced,0x0000,0xfced,0xfced,0xfced,0xfced,0x0000,0xfced,0xffff,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xfced,0xfced,0x0000,0xfced,0xfbad,0xfbad,0xfced,0x0000,0xfced,0xffff,0xffff,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xffff,0x001f,0xffff,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0x001f,0x001f,0xb5b6,0xffff,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0xb5b6,0x001f,0x001f,0x001f,0x001f,0x001f,0xb5b6,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0xb5b6,0x001f,0x001f,0x001f,0x001f,0x001f,0xb5b6,0x001f,0x001f,0x001f,0x001f
};

struct Rect {
   int x;
   int y;
   int h;
   int w;
};

Fixed fixcos(Fixed angle) {
   static Fixed cosLUT[] = { 256, 255, 255, 255, 254, 254, 253, 252, 251, 249, 248, 246, 244, 243, 241, 238, 236, 234, 231, 228, 225, 222, 219, 216, 212, 209, 205, 201, 197, 193, 189, 185, 181, 176, 171, 167, 162, 157, 152, 147, 142, 136, 131, 126, 120, 115, 109, 103, 97, 92, 86, 80, 74, 68, 62, 56, 49, 43, 37, 31, 25, 18, 12, 6, 0, -6, -12, -18, -25, -31, -37, -43, -49, -56, -62, -68, -74, -80, -86, -92, -97, -103, -109, -115, -120, -126, -131, -136, -142, -147, -152, -157, -162, -167, -171, -176, -181, -185, -189, -193, -197, -201, -205, -209, -212, -216, -219, -222, -225, -228, -231, -234, -236, -238, -241, -243, -244, -246, -248, -249, -251, -252, -253, -254, -254, -255, -255, -255, -256, -255, -255, -255, -254, -254, -253, -252, -251, -249, -248, -246, -244, -243, -241, -238, -236, -234, -231, -228, -225, -222, -219, -216, -212, -209, -205, -201, -197, -193, -189, -185, -181, -176, -171, -167, -162, -157, -152, -147, -142, -136, -131, -126, -120, -115, -109, -103, -97, -92, -86, -80, -74, -68, -62, -56, -49, -43, -37, -31, -25, -18, -12, -6, 0, 6, 12, 18, 25, 31, 37, 43, 49, 56, 62, 68, 74, 80, 86, 92, 97, 103, 109, 115, 120, 126, 131, 136, 142, 147, 152, 157, 162, 167, 171, 176, 181, 185, 189, 193, 197, 201, 205, 209, 212, 216, 219, 222, 225, 228, 231, 234, 236, 238, 241, 243, 244, 246, 248, 249, 251, 252, 253, 254, 254, 255, 255, 255 };
   return cosLUT[angle & 0xff];
}

inline void setPixel565(int x, int y, unsigned short v) {
   if(is_cx) {
      *((unsigned short*)(SCREEN_BASE_ADDRESS+(x<<1)+(y<<9)+(y<<7))) = v;
   }else{
      unsigned char* p = (unsigned char*)(SCREEN_BASE_ADDRESS +(x>>1)+(y<<7)+(y<<5));
      char c=(v>>12)/3+((v>>7)&15)/3+((v>>1)&15)/3;
      *p=(x&1)?((*p&0xF0)|c):((*p&0x0F)|(c<<4));
   }
}

inline void setPixelRGB(int x, int y, int r, int g, int b) {
   if(is_cx) {
      *((unsigned short*)(SCREEN_BASE_ADDRESS+(x<<1)+(y<<9)+(y<<7)))=((r>>3)<<11)|((g>>2)<<5)|(b>>3);
   }else{
      unsigned char* p = (unsigned char*)(SCREEN_BASE_ADDRESS  + ((x >> 1) + (y << 7) + (y << 5)));
      char c = (r>>4)/3 + (g>>4)/3 + (b>>4)/3;
      *p = (x & 1) ? ((*p & 0xF0) | c) : ((*p & 0x0F) | (c << 4));
   }
}

void rotate(int x, int y, Fixed ca, Fixed sa, struct Rect* out) {
   out->x = fixtoi(fixmul(itofix(x), ca)+fixmul(itofix(y), sa));
   out->y = fixtoi(fixmul(itofix(x), -sa)+fixmul(itofix(y), ca));
}

void custom_rotosprite(unsigned short* source, struct Rect sr, Fixed angle) {
   // Rotated points
   struct Rect upleft, upright, downleft, downright;
   // Final rectangle, the rectangle containing all of the four rotated points
   // x,y = top-left corner
   // w,h = bottom-right corner
   struct Rect fr;
   
   Fixed dX = fixcos(angle), dY = fixsin(angle);
   
   rotate(-source[1] / 2, -source[0] / 2, dX, dY, &upleft);
   rotate(source[1] / 2, -source[0] / 2, dX, dY, &upright);
   rotate(-source[1] / 2, source[0] / 2, dX, dY, &downleft);
   rotate(source[1] / 2, source[0] / 2, dX, dY, &downright);
   
   fr.x = min(min(min(upleft.x, upright.x), downleft.x), downright.x)+sr.x;
   fr.y = min(min(min(upleft.y, upright.y), downleft.y), downright.y)+sr.y;
   fr.w = max(max(max(upleft.x, upright.x), downleft.x), downright.x)+sr.x;
   fr.h = max(max(max(upleft.y, upright.y), downleft.y), downright.y)+sr.y;
   // Current pixel
   struct Rect cp;
   
   // De-rotated pixel starting the line
   struct Rect lsp;
   // Current de-rotated pixel
   struct Rect cdrp;
   
   // De-rotates the pixel
   // Basically the same as rotate() with cos(-angle) and sin(-angle), but without the fixtoi()
   // Also, remember cos(-x) = cos(x) and sin(-x) = -sin(x)
   lsp.x = fixmul(itofix(fr.x-sr.x), dX)+fixmul(itofix(fr.y-sr.y), -dY);
   lsp.y = fixmul(itofix(fr.x-sr.x), dY)+fixmul(itofix(fr.y-sr.y), dX);
   
   for(cp.y = fr.y; cp.y < fr.h; cp.y++) {
      cdrp.x = lsp.x;
      cdrp.y = lsp.y;
      for(cp.x = fr.x; cp.x < fr.w; cp.x++) {
         if(cp.x>=0 && cp.x<320 && cp.y>=0 && cp.y<240) {
            if(abs(fixtoi(cdrp.x))<source[1]/2 && abs(fixtoi(cdrp.y))<source[0]/2) {
               unsigned short currentPixel=source[fixtoi(cdrp.x)+source[1]/2+(fixtoi(cdrp.y)+source[0]/2)*source[1]+3];
               if(currentPixel!=source[2]) {
                  setPixel565(cp.x, cp.y, currentPixel);
               }
            }
         }
         cdrp.x += dX;
         cdrp.y += dY;
      }
      lsp.x -= dY;
      lsp.y += dX;
   }
}

void putsprite(int x, int y, unsigned short* ptr) {
   int c=3, i, j;
   for(i=0; i<ptr[1]; i++) {
      for(j = 0; j < ptr[0]; j++, c++) {
         if (!(ptr[c] == ptr[2])) {
            setPixel565(j+x, i+y, ptr[c]);
         }
      }
   }
}

int main(void) {
   int x;
   int y;
   for(y=0;y<240;y++) {
      for(x=0;x<320;x++) {
         setPixelRGB(x,y,255,128,255);
      }
   }
   putsprite(4,5,sprite);
   struct Rect p;
   int i;
   for(i=0;i<5;i++) {
      p.x=20;p.y=i*20+40;custom_rotosprite(sprite,p,i*16);
   }
   while(!K_ESC);
   return 1;
}

rotofail.png
You do not have the required permissions to view the files attached to this post.

Image
ImageImageImage
Pokemon Topaze (Axe) discussion and download links here
(19:29:36) noelnadal: plus sérieusemen​t, j'ai très peu de problèmes
(22:45:44) Clifward: J'aime rire du malheur des autres :troll:

(2017.11.18 - 17:07:12) Fireworks: Hayleia !!!!!
(2017.11.18 - 17:07:19) TI-Bot: Fireworks has been logged out (Kicked).
(2017.11.18 - 17:07:22) TI-Bot: Ban of user Fireworks revoked.
(2017.11.18 - 17:07:25) TI-Bot: Fireworks logs into the Chat.
(2017.11.18 - 17:07:28) Fireworks: <3
(2017.11.18 - 17:07:31) Fireworks: 208
User avatar
HayleiaGénéreux
Niveau 17: GM (Grand Maître des calculatrices)
Niveau 17: GM (Grand Maître des calculatrices)
Level up: 43.8%
 
Posts: 2509
Images: 2
Joined: 30 Aug 2011, 08:22
Gender: Not specified
Calculator(s):
MyCalcs profile
Class: Templar

Re: nKaruga

Unread postby Hayleia » 31 May 2014, 13:35

Fixed. Tout marche :D

Merci encore pour ta routine et n'hésite pas à utiliser ces routines toi aussi si tu veux accélérer ton programme :)

Code: Select all
#include <nspireio.h>
#include <stdio.h>
#include <os.h>
#include <libndls.h>
#include <stdlib.h>

#define K_ESC isKeyPressed(KEY_NSPIRE_ESC)
#define K_ENTER isKeyPressed(KEY_NSPIRE_ENTER)
#define K_TAB isKeyPressed(KEY_NSPIRE_TAB)
#define K_A isKeyPressed(KEY_NSPIRE_A)
#define K_7 isKeyPressed(KEY_NSPIRE_7)
#define K_9 isKeyPressed(KEY_NSPIRE_9)
#define K_8 isKeyPressed(KEY_NSPIRE_8)
#define K_5 isKeyPressed(KEY_NSPIRE_5)
#define K_4 isKeyPressed(KEY_NSPIRE_4)
#define K_6 isKeyPressed(KEY_NSPIRE_6)

typedef int Fixed;
// Fixed
// 24.8 fixed point
#define itofix(x) ((x)<<8)
#define fixtoi(x) ((x) >> 8)
#define fixmul(x, y) ((x)*  (y) >> 8)
#define fixdiv(x, y) (((x)<<8) / (y))

#define fixsin(x) fixcos((x)-64)

//le format utilisé par NTI est:
//42 dans le premier octet suivi de la version dans le deuxième octet
//le deuxième short est la hauteur
//le troisième short est la largeur
//le quatrième short est 0
//les autres sont les pixels au format rgb565
//
//on elève le premier short
//on remplace le 3e short (à 0x0000 pour NTI) par la couleur qu'on veut transparente
static unsigned short sprite[] = {
   0x0011,0x000C,0x001f,0x001f,0x001f,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0x001f,0x001f,0x001f,0x001f,0xb5b6,0xffff,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0x001f,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xdc2b,0xdc2b,0xdc2b,0xdc2b,0xdc2b,0xdc2b,0xdc2b,0xffff,0xffff,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xdc2b,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xdc2b,0xffff,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xfced,0xfced,0x0000,0xfced,0xfced,0xfced,0xfced,0x0000,0xfced,0xffff,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xfced,0xfced,0x0000,0xfced,0xfbad,0xfbad,0xfced,0x0000,0xfced,0xffff,0xffff,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xfced,0xffff,0x001f,0xffff,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0x001f,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0x001f,0x001f,0xb5b6,0xffff,0x001f,0xb5b6,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0xffff,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0xb5b6,0x001f,0x001f,0x001f,0x001f,0x001f,0xb5b6,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0x001f,0xb5b6,0x001f,0x001f,0x001f,0x001f,0x001f,0xb5b6,0x001f,0x001f,0x001f,0x001f
};

struct Rect {
   int x;
   int y;
   int h;
   int w;
};

Fixed fixcos(Fixed angle) {
   static Fixed cosLUT[] = { 256, 255, 255, 255, 254, 254, 253, 252, 251, 249, 248, 246, 244, 243, 241, 238, 236, 234, 231, 228, 225, 222, 219, 216, 212, 209, 205, 201, 197, 193, 189, 185, 181, 176, 171, 167, 162, 157, 152, 147, 142, 136, 131, 126, 120, 115, 109, 103, 97, 92, 86, 80, 74, 68, 62, 56, 49, 43, 37, 31, 25, 18, 12, 6, 0, -6, -12, -18, -25, -31, -37, -43, -49, -56, -62, -68, -74, -80, -86, -92, -97, -103, -109, -115, -120, -126, -131, -136, -142, -147, -152, -157, -162, -167, -171, -176, -181, -185, -189, -193, -197, -201, -205, -209, -212, -216, -219, -222, -225, -228, -231, -234, -236, -238, -241, -243, -244, -246, -248, -249, -251, -252, -253, -254, -254, -255, -255, -255, -256, -255, -255, -255, -254, -254, -253, -252, -251, -249, -248, -246, -244, -243, -241, -238, -236, -234, -231, -228, -225, -222, -219, -216, -212, -209, -205, -201, -197, -193, -189, -185, -181, -176, -171, -167, -162, -157, -152, -147, -142, -136, -131, -126, -120, -115, -109, -103, -97, -92, -86, -80, -74, -68, -62, -56, -49, -43, -37, -31, -25, -18, -12, -6, 0, 6, 12, 18, 25, 31, 37, 43, 49, 56, 62, 68, 74, 80, 86, 92, 97, 103, 109, 115, 120, 126, 131, 136, 142, 147, 152, 157, 162, 167, 171, 176, 181, 185, 189, 193, 197, 201, 205, 209, 212, 216, 219, 222, 225, 228, 231, 234, 236, 238, 241, 243, 244, 246, 248, 249, 251, 252, 253, 254, 254, 255, 255, 255 };
   return cosLUT[angle & 0xff];
}

/*
inline void setPixel565(int x, int y, unsigned short v) {
   if(is_cx) {
      *((unsigned short*)(SCREEN_BASE_ADDRESS+(x<<1)+(y<<9)+(y<<7))) = v;
   }else{
      unsigned char* p = (unsigned char*)(SCREEN_BASE_ADDRESS +(x>>1)+(y<<7)+(y<<5));
      char c=(v>>12)/3+((v>>7)&15)/3+((v>>1)&15)/3;
      *p=(x&1)?((*p&0xF0)|c):((*p&0x0F)|(c<<4));
   }
}
*/
inline void setPixel565(int x, int y, uint16_t c) {
   if(is_cx) {
      *((unsigned short*)(SCREEN_BASE_ADDRESS + (x << 1) + (y << 9) + (y << 7))) = c;
   }else{
      unsigned char* p = (unsigned char*)(SCREEN_BASE_ADDRESS  + ((x >> 1) + (y << 7) + (y << 5)));
      char black_and_white = ((c>>11)+((c&0x7E0)>>5)+(c&0x1F))>>3;
      *p = (x & 1) ? ((*p & 0xF0) | black_and_white) : ((*p & 0x0F) | (black_and_white << 4));
   }
}

/*
inline void setPixelRGB(int x, int y, int r, int g, int b) {
   if(is_cx) {
      *((unsigned short*)(SCREEN_BASE_ADDRESS+(x<<1)+(y<<9)+(y<<7)))=((r>>3)<<11)|((g>>2)<<5)|(b>>3);
   }else{
      unsigned char* p = (unsigned char*)(SCREEN_BASE_ADDRESS  + ((x >> 1) + (y << 7) + (y << 5)));
      char c = (r>>4)/3 + (g>>4)/3 + (b>>4)/3;
      *p = (x & 1) ? ((*p & 0xF0) | c) : ((*p & 0x0F) | (c << 4));
   }
}
*/
inline void setPixelRGB(int x, int y, int r, int g, int b) {
   if(is_cx) {
      *((unsigned short*)(SCREEN_BASE_ADDRESS + (x << 1) + (y << 9) + (y << 7))) = (((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3);
   }else{
      unsigned char* p = (unsigned char*)(SCREEN_BASE_ADDRESS  + ((x >> 1) + (y << 7) + (y << 5)));
      char black_and_white = (r>>6) + (g>>5) + (b>>6);
      *p = (x & 1) ? ((*p & 0xF0) | black_and_white) : ((*p & 0x0F) | (black_and_white << 4));
   }
}

void rotate(int x, int y, Fixed ca, Fixed sa, struct Rect* out) {
   out->x = fixtoi(fixmul(itofix(x), ca)+fixmul(itofix(y), sa));
   out->y = fixtoi(fixmul(itofix(x), -sa)+fixmul(itofix(y), ca));
}

void custom_rotosprite(unsigned short* source, struct Rect sr, Fixed angle) {
   // Rotated points
   struct Rect upleft, upright, downleft, downright;
   // Final rectangle, the rectangle containing all of the four rotated points
   // x,y = top-left corner
   // w,h = bottom-right corner
   struct Rect fr;
   
   Fixed dX = fixcos(angle), dY = fixsin(angle);
   
   rotate(-source[0] / 2, -source[1] / 2, dX, dY, &upleft);
   rotate(source[0] / 2, -source[1] / 2, dX, dY, &upright);
   rotate(-source[0] / 2, source[1] / 2, dX, dY, &downleft);
   rotate(source[0] / 2, source[1] / 2, dX, dY, &downright);
   
   fr.x = min(min(min(upleft.x, upright.x), downleft.x), downright.x)+sr.x;
   fr.y = min(min(min(upleft.y, upright.y), downleft.y), downright.y)+sr.y;
   fr.w = max(max(max(upleft.x, upright.x), downleft.x), downright.x)+sr.x;
   fr.h = max(max(max(upleft.y, upright.y), downleft.y), downright.y)+sr.y;
   // Current pixel
   struct Rect cp;
   
   // De-rotated pixel starting the line
   struct Rect lsp;
   // Current de-rotated pixel
   struct Rect cdrp;
   
   // De-rotates the pixel
   // Basically the same as rotate() with cos(-angle) and sin(-angle), but without the fixtoi()
   // Also, remember cos(-x) = cos(x) and sin(-x) = -sin(x)
   lsp.x = fixmul(itofix(fr.x-sr.x), dX)+fixmul(itofix(fr.y-sr.y), -dY);
   lsp.y = fixmul(itofix(fr.x-sr.x), dY)+fixmul(itofix(fr.y-sr.y), dX);
   
   for(cp.y = fr.y; cp.y < fr.h; cp.y++) {
      cdrp.x = lsp.x;
      cdrp.y = lsp.y;
      for(cp.x = fr.x; cp.x < fr.w; cp.x++) {
         if(cp.x>=0 && cp.x<320 && cp.y>=0 && cp.y<240) {
            if(abs(fixtoi(cdrp.x))<source[0]/2 && abs(fixtoi(cdrp.y))<source[1]/2) {
               unsigned short currentPixel=source[fixtoi(cdrp.x)+source[0]/2+(fixtoi(cdrp.y)+source[1]/2)*source[0]+3];
               if(currentPixel!=source[2]) {
                  setPixel565(cp.x, cp.y, currentPixel);
               }
            }
         }
         cdrp.x += dX;
         cdrp.y += dY;
      }
      lsp.x -= dY;
      lsp.y += dX;
   }
}

/*
void putsprite(int x, int y, unsigned short* ptr) {
   int c=3, i, j;
   for(i=0; i<ptr[1]; i++) {
      for(j = 0; j < ptr[0]; j++, c++) {
         if (!(ptr[c] == ptr[2])) {
            setPixel565(j+x, i+y, ptr[c]);
         }
      }
   }
}
*/
void putsprite(int x, int y, unsigned short* ptr) {
   int c=3, i, j;
   uint16_t w = ptr[0];
   uint16_t h = ptr[1];
   for(j=0; j<h; j++) {
      for(i=0; i<w; i++,c++) {
         if (ptr[c] != ptr[2]) {
            setPixel565(x+i, y+j, ptr[c]);
         }
      }
   }
}

int main(void) {
   int x;
   int y;
   for(y=0;y<240;y++) {
      for(x=0;x<320;x++) {
         setPixelRGB(x,y,255,128,255);
      }
   }
   putsprite(4,5,sprite);
   struct Rect p;
   int i;
   for(i=0;i<5;i++) {
      p.x=20;p.y=i*20+40;custom_rotosprite(sprite,p,i*16);
   }
   while(!K_ESC);
   return 1;
}

rotowin.png
You do not have the required permissions to view the files attached to this post.

Image
ImageImageImage
Pokemon Topaze (Axe) discussion and download links here
(19:29:36) noelnadal: plus sérieusemen​t, j'ai très peu de problèmes
(22:45:44) Clifward: J'aime rire du malheur des autres :troll:

(2017.11.18 - 17:07:12) Fireworks: Hayleia !!!!!
(2017.11.18 - 17:07:19) TI-Bot: Fireworks has been logged out (Kicked).
(2017.11.18 - 17:07:22) TI-Bot: Ban of user Fireworks revoked.
(2017.11.18 - 17:07:25) TI-Bot: Fireworks logs into the Chat.
(2017.11.18 - 17:07:28) Fireworks: <3
(2017.11.18 - 17:07:31) Fireworks: 208
User avatar
HayleiaGénéreux
Niveau 17: GM (Grand Maître des calculatrices)
Niveau 17: GM (Grand Maître des calculatrices)
Level up: 43.8%
 
Posts: 2509
Images: 2
Joined: 30 Aug 2011, 08:22
Gender: Not specified
Calculator(s):
MyCalcs profile
Class: Templar

Re: nKaruga

Unread postby matref » 31 May 2014, 17:58

Je suis pas sûr que ça accélère par rapport à la nSDL ... tu fais un if dans chaque setPixel, tu devrais plutôt utiliser des pointeurs sur fonction et les initialiser en début de programme, comme ça y'a aucun test.
User avatar
matref
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 25%
 
Posts: 506
Joined: 11 Dec 2011, 03:08
Location: France, Châteaurenard
Gender: Male
Calculator(s):
MyCalcs profile
Class: Prépa MPSI

Re: nKaruga

Unread postby Excale » 31 May 2014, 18:00

matref wrote:Je suis pas sûr que ça accélère par rapport à la nSDL ... tu fais un if dans chaque setPixel, tu devrais plutôt utiliser des pointeurs sur fonction et les initialiser en début de programme, comme ça y'a aucun test.


Tu perds le jeu et l'aspect inline du setpixel dans ce cas.
User avatar
ExcaleAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 3.9%
 
Posts: 2955
Images: 3
Joined: 10 Sep 2010, 00:00
Gender: Male
Calculator(s):
MyCalcs profile

Re: nKaruga

Unread postby matref » 31 May 2014, 18:04

Qu'est-ce que t'entends par "le jeu" ?

Et certes c'est plus inline, mais de toute façon sur la nSDL le setPixel n'est pas inline, et un appel custom est toujours plus rapide qu'un test.

EDIT : d'autant que is_cx c'est pas juste 0 ou 1, c'est une fonction.
User avatar
matref
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 25%
 
Posts: 506
Joined: 11 Dec 2011, 03:08
Location: France, Châteaurenard
Gender: Male
Calculator(s):
MyCalcs profile
Class: Prépa MPSI

Re: nKaruga

Unread postby Excale » 31 May 2014, 18:05

et un appel custom est toujours plus rapide qu'un test.

Nope.
User avatar
ExcaleAdmin
Niveau 16: CC2 (Commandeur des Calculatrices)
Niveau 16: CC2 (Commandeur des Calculatrices)
Level up: 3.9%
 
Posts: 2955
Images: 3
Joined: 10 Sep 2010, 00:00
Gender: Male
Calculator(s):
MyCalcs profile

Re: nKaruga

Unread postby matref » 31 May 2014, 18:06

Ah ben d'après les tests de Vogtinator sur nGL, je peux te dire que si.
User avatar
matref
Niveau 15: CC (Chevalier des Calculatrices)
Niveau 15: CC (Chevalier des Calculatrices)
Level up: 25%
 
Posts: 506
Joined: 11 Dec 2011, 03:08
Location: France, Châteaurenard
Gender: Male
Calculator(s):
MyCalcs profile
Class: Prépa MPSI

PreviousNext

Return to Native: Ndless, Linux, ...

Who is online

Users browsing this forum: ClaudeBot [spider] and 1 guest

-
Search
-
Social TI-Planet
-
Featured topics
Grand Concours 2024-2025 - Programmation Python
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.
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.
769 utilisateurs:
>738 invités
>24 membres
>7 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)