Advertisement
PierrotLL

Animation LuAFX

May 20th, 2011
605
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.17 KB | None | 0 0
  1. #include <stdlib.h>
  2. #include <fxlib.h>
  3. #include "gray.h"
  4. #include "grayscreenshotlib.h"
  5.  
  6. void draw_bmp_or_cl(unsigned char *bmp, int x, int y, int width, int height, char* buffer)
  7. {
  8.     unsigned short line;
  9.     char shift, *screen, *p;
  10.     int i, j, real_width, begin_x, end_x, begin_y, end_y;
  11.     char bool1=1, bool2=1, bool3;
  12.     if(!bmp || x<1-width || x>127 || y<1-height || y>63 || height<1 || width<1) return;
  13.     p = (char*)&line;
  14.     real_width = (width-1>>3<<3)+8;
  15.     if(y < 0) begin_y = -y;
  16.     else begin_y = 0;
  17.     if(y+height > 64) end_y = 64-y;
  18.     else end_y = height;
  19.     shift = 8-(x&7);
  20.     if(x<0)
  21.     {
  22.         begin_x = -x>>3;
  23.         if(shift != 8) bool1 = 0;
  24.     } else begin_x = 0;
  25.     if(x+real_width > 128) end_x = 15-(x>>3), bool2 = 0;
  26.     else end_x = real_width-1>>3;
  27.     bool3 = (end_x == real_width-1>>3);
  28.     screen = buffer+(y+begin_y<<4)+(x>>3);
  29.  
  30.     for(i=begin_y ; i<end_y ; i++)
  31.     {
  32.         if(begin_x < end_x)
  33.         {
  34.             line = bmp[i*(real_width>>3)+begin_x] << shift;
  35.             if(bool1) screen[begin_x] |= *p;
  36.             if(shift!=8) screen[begin_x+1] |= *(p+1);
  37.             for(j=begin_x+1 ; j<end_x ; j++)
  38.             {
  39.                 line = bmp[i*(real_width>>3)+j] << shift;
  40.                 screen[j] |= *p;
  41.                 if(shift!=8) screen[j+1] |= *(p+1);
  42.             }
  43.         }
  44.         line = bmp[i*(real_width>>3)+end_x];
  45.         if(bool3) line &= -1<<real_width-width;
  46.         line <<= shift;
  47.         if(begin_x < end_x || bool1) screen[end_x] |= *p;
  48.         if(bool2) screen[end_x+1] |= *(p+1);
  49.         screen += 16;
  50.     }
  51. }
  52.  
  53. void intro()
  54. {
  55.  
  56. char buffer1[] = {3,128,0,15,224,0,63,248,0,255,254,0,255,250,0,255,226,0,255,130,0,255,2,0,255,2,0,255,3,128,255,3,224,255,3,248,255,3,254,255,3,250,255,3,226,255,3,130,255,2,2,255,0,2,255,0,6,255,0,24,255,0,96,255,1,128,255,6,0,63,24,0,15,96,0,3,128,0,0,0,0,0,0,0,0,0,0,0,0,0};
  57. char buffer2[] = {3,128,0,12,96,0,48,24,0,192,6,0,240,30,0,252,126,0,255,254,0,255,254,0,255,254,0,255,255,128,255,254,96,255,254,24,255,254,6,255,254,30,255,254,126,255,255,254,255,255,254,255,255,254,255,255,254,255,255,248,255,255,224,255,255,128,255,254,0,63,248,0,15,224,0,3,128,0,0,0,0,0,0,0,0,0,0,0,0,0};
  58.     char image[5][2][90] = {
  59.         {
  60. {3,128,0,15,224,0,63,248,0,255,254,0,255,250,0,255,226,0,255,130,0,255,2,0,255,2,0,255,3,128,255,3,224,255,3,248,255,3,254,255,3,250,255,3,226,255,3,130,255,2,2,255,0,2,255,0,6,255,0,24,255,0,96,255,1,128,255,6,0,63,24,0,15,96,0,3,128,0,0,0,0,0,0,0,0,0,0,0,0,0},
  61. {3,128,0,12,96,0,48,24,0,192,6,0,240,30,0,252,126,0,255,254,0,255,254,0,255,254,0,255,255,128,255,254,96,255,254,24,255,254,6,255,254,30,255,254,126,255,255,254,255,255,254,255,255,254,255,255,254,255,255,248,255,255,224,255,255,128,255,254,0,63,248,0,15,224,0,3,128,0,0,0,0,0,0,0,0,0,0,0,0,0}
  62.         },
  63.         {
  64. {0,3,128,0,15,224,0,63,248,0,63,254,0,63,250,14,63,226,63,191,194,255,255,194,255,255,194,255,239,194,255,143,194,255,15,194,255,15,194,255,15,194,255,15,194,255,15,194,255,15,194,255,15,194,255,15,194,255,15,2,255,12,2,255,0,2,255,0,6,255,0,24,255,0,96,255,1,128,255,6,0,63,24,0,15,96,0,3,128,0},
  65. {0,3,128,0,12,96,0,48,24,0,60,6,0,63,30,14,63,254,49,191,254,192,127,254,240,31,254,252,127,254,255,255,254,255,255,254,255,255,254,255,255,254,255,255,254,255,255,254,255,255,254,255,255,254,255,255,254,255,255,254,255,255,254,255,255,254,255,255,254,255,255,248,255,255,224,255,255,128,255,254,0,63,248,0,15,224,0,3,128,0}
  66.         },
  67.         {
  68. {0,3,0,0,15,192,0,63,240,0,255,252,3,255,244,15,255,196,63,255,4,255,252,4,255,240,4,255,192,4,255,0,4,254,1,132,254,7,132,254,31,132,254,31,132,254,31,132,254,30,4,254,24,4,254,0,4,254,1,132,254,7,132,254,31,132,254,31,140,254,23,176,254,17,192,254,16,0,254,16,0,62,48,0,14,192,0,3,0,0},
  69. {0,3,0,0,12,192,0,48,48,0,192,12,3,0,60,12,0,252,48,3,252,192,15,252,240,63,252,252,255,252,255,255,252,255,255,252,255,255,252,255,255,252,255,255,252,255,255,252,255,255,252,255,255,252,255,255,252,255,255,252,255,255,252,255,255,252,255,255,252,255,247,240,255,241,192,255,240,0,255,240,0,63,240,0,15,192,0,3,0,0}
  70.         },
  71.         {
  72. {0,3,0,0,15,192,0,63,240,0,255,252,3,255,252,15,255,228,63,255,132,255,254,4,255,248,4,255,224,24,255,128,96,255,1,128,255,7,0,255,7,192,255,7,240,255,7,208,255,7,16,255,4,16,255,0,16,255,0,96,255,1,128,255,6,0,255,4,0,255,4,0,255,4,0,255,4,0,255,4,0,63,24,0,15,96,0,3,128,0},
  73. {0,3,0,0,12,192,0,48,48,0,192,12,3,0,28,12,0,124,48,1,252,192,7,252,240,31,252,252,127,248,255,255,224,255,255,128,255,255,0,255,252,192,255,252,48,255,252,240,255,255,240,255,255,240,255,255,240,255,255,224,255,255,128,255,254,0,255,252,0,255,252,0,255,252,0,255,252,0,255,252,0,63,248,0,15,224,0,3,128,0}
  74.         },
  75.         {
  76. {0,3,128,0,15,224,0,63,248,0,63,254,0,63,250,14,63,226,63,191,194,255,255,194,255,255,194,255,239,194,255,143,196,255,15,196,255,15,196,127,15,196,127,15,132,127,6,4,127,128,2,127,128,2,127,129,130,127,135,194,127,143,194,255,143,194,255,143,198,255,11,216,255,8,224,255,8,0,255,8,0,63,24,0,15,96,0,3,128,0},
  77. {0,3,128,0,12,96,0,48,24,0,60,6,0,63,30,14,63,254,49,191,254,192,127,254,240,31,254,252,127,254,255,255,252,255,255,252,255,255,252,127,255,252,127,255,252,127,255,252,127,255,254,127,255,254,127,255,254,127,255,254,127,255,254,255,255,254,255,255,254,255,251,248,255,248,224,255,248,0,255,248,0,63,248,0,15,224,0,3,128,0}
  78.         }
  79.     };
  80.     int coord[5][4] = {{5,11,-20,0}, {30,19,-18,0}, {54,31,-16,0}, {77,19,-14,0}, {99,8,-12,0}};
  81.     int i, j, dy, y;
  82.     for(dy=-20 ; dy<20 ; dy++) {
  83.         gray_clearVRAM();
  84.         for(i=0 ; i<5 ; i++) {
  85.             y = 0;
  86.             if(coord[i][2] < 0) {
  87.                 for(j=-1 ; j>= coord[i][2] ; j--) y += j;
  88.             } else if(coord[i][2] > 0) {
  89.                 for(j=1 ; j<= coord[i][2] ; j++) y += j;
  90.             } else {
  91.                 coord[i][3]++;
  92.                 if(coord[i][3] > 10) coord[i][2] = 1;
  93.             }
  94.             if(coord[i][2]) coord[i][2]++;
  95.             draw_bmp_or_cl(image[i][0], coord[i][0], coord[i][1]+y, 23, 30, gray_getScreen()->VRAM1);
  96.             draw_bmp_or_cl(image[i][1], coord[i][0], coord[i][1]+y, 23, 30, gray_getScreen()->VRAM2);
  97.         }
  98.         gray_swapBuffers();
  99.         gsl_screenshot(gray_getScreen()->DD1, gray_getScreen()->DD2);
  100.         for(i=0 ; i<300000 ; i++);
  101.     }
  102. }
  103.  
  104. int AddIn_main(int isAppli,unsigned short OptionNum)
  105. {
  106.     gray_init();
  107.     gsl_init(100);
  108.     intro();
  109.     gsl_quit();
  110.     gray_quit();
  111.     reset_calc();
  112.     return 1;
  113. }
  114.  
  115. #pragma section _BR_Size
  116. unsigned long BR_Size;
  117. #pragma section
  118. #pragma section _TOP
  119.  
  120. int InitializeSystem(int isAppli,unsigned short OptionNum)
  121. {
  122.     return INIT_ADDIN_APPLICATION(isAppli,OptionNum);
  123. }
  124. #pragma section
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement