Index: proj/bmp/pistol.bmp
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = image/x-ms-bmp
Index: proj/bmp/pistol.bmp
===================================================================
--- proj/bmp/pistol.bmp	(nonexistent)
+++ proj/bmp/pistol.bmp	(revision 160)

Property changes on: proj/bmp/pistol.bmp
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+image/x-ms-bmp
\ No newline at end of property
Index: proj/bmp/pistol.xcf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = image/x-xcf
Index: proj/bmp/pistol.xcf
===================================================================
--- proj/bmp/pistol.xcf	(nonexistent)
+++ proj/bmp/pistol.xcf	(revision 160)

Property changes on: proj/bmp/pistol.xcf
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+image/x-xcf
\ No newline at end of property
Index: proj/bmp/shooter.bmp
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = image/x-ms-bmp
Index: proj/bmp/shooter.bmp
===================================================================
--- proj/bmp/shooter.bmp	(nonexistent)
+++ proj/bmp/shooter.bmp	(revision 160)

Property changes on: proj/bmp/shooter.bmp
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+image/x-ms-bmp
\ No newline at end of property
Index: proj/bmp/shooter.xcf
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = image/x-xcf
Index: proj/bmp/shooter.xcf
===================================================================
--- proj/bmp/shooter.xcf	(nonexistent)
+++ proj/bmp/shooter.xcf	(revision 160)

Property changes on: proj/bmp/shooter.xcf
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+image/x-xcf
\ No newline at end of property
Index: proj/xpm/pistol.xpm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = image/x-xpmi
Index: proj/xpm/pistol.xpm
===================================================================
--- proj/xpm/pistol.xpm	(nonexistent)
+++ proj/xpm/pistol.xpm	(revision 160)

Property changes on: proj/xpm/pistol.xpm
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+image/x-xpmi
\ No newline at end of property
Index: proj/xpm/plus.xpm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = image/x-xpmi
Index: proj/xpm/plus.xpm
===================================================================
--- proj/xpm/plus.xpm	(nonexistent)
+++ proj/xpm/plus.xpm	(revision 160)

Property changes on: proj/xpm/plus.xpm
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+image/x-xpmi
\ No newline at end of property
Index: proj/xpm/plus_trans.xpm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = image/x-xpmi
Index: proj/xpm/plus_trans.xpm
===================================================================
--- proj/xpm/plus_trans.xpm	(nonexistent)
+++ proj/xpm/plus_trans.xpm	(revision 160)

Property changes on: proj/xpm/plus_trans.xpm
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+image/x-xpmi
\ No newline at end of property
Index: proj/xpm/shooter.xpm
===================================================================
Cannot display: file marked as a binary type.
svn:mime-type = image/x-xpmi
Index: proj/xpm/shooter.xpm
===================================================================
--- proj/xpm/shooter.xpm	(nonexistent)
+++ proj/xpm/shooter.xpm	(revision 160)

Property changes on: proj/xpm/shooter.xpm
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+image/x-xpmi
\ No newline at end of property
Index: proj/DR.mk
===================================================================
--- proj/DR.mk	(revision 159)
+++ proj/DR.mk	(revision 160)
@@ -2,7 +2,7 @@
 
 SRCS= proj.c graphics.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c
 
-CPPFLAGS += -pedantic -D DIOGO # -D __LCOM_OPTIMIZED_ 
+CPPFLAGS += -pedantic -I./bmp -I./xpm -D DIOGO # -D __LCOM_OPTIMIZED_ 
 
 DPADD += ${LIBLCF}
 LDADD += -llcf
Index: proj/Makefile
===================================================================
--- proj/Makefile	(revision 159)
+++ proj/Makefile	(revision 160)
@@ -2,7 +2,7 @@
 
 SRCS= proj.c graphics.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c
 
-CPPFLAGS += -pedantic -D __LCOM_OPTIMIZED_
+CPPFLAGS += -pedantic -I./bmp -I./xpm -D __LCOM_OPTIMIZED_
 
 DPADD += ${LIBLCF}
 LDADD += -llcf
Index: proj/TB.mk
===================================================================
--- proj/TB.mk	(revision 159)
+++ proj/TB.mk	(revision 160)
@@ -2,7 +2,7 @@
 
 SRCS= proj.c graphics.c sprite.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c
 
-CPPFLAGS += -pedantic -D __LCOM_OPTIMIZED_ -D TELMO
+CPPFLAGS += -pedantic -I./bmp -I./xpm -D __LCOM_OPTIMIZED_ -D TELMO
 
 DPADD += ${LIBLCF}
 LDADD += -llcf
Index: proj/graphics.c
===================================================================
--- proj/graphics.c	(revision 159)
+++ proj/graphics.c	(revision 160)
@@ -198,7 +198,6 @@
     return SUCCESS;
 }
 
-
 int (set_pixel)(uint16_t x, uint16_t y, uint32_t color) {
     if (x >= vbe_mem_info.XResolution || y >= vbe_mem_info.YResolution) {
         printf("%s: invalid pixel.\n", __func__);
@@ -208,6 +207,17 @@
     memcpy((void*)((unsigned int)video_mem + pos), &color, get_bytes_pixel());
     return SUCCESS;
 }
+int (set_pixel_alpha)(uint16_t x, uint16_t y, uint32_t color, uint8_t alpha){
+    unsigned int pos = (x + y * vbe_mem_info.XResolution) * get_bytes_pixel();
+    uint32_t color_;
+    memcpy(&color_, (void*)((unsigned int)video_mem + pos), get_bytes_pixel());
+    float a = 1.0-(alpha&0xFF)/(float)0xFF;
+    uint8_t r = GET_RED(color)*a + GET_RED(color_)*(1.0-a);
+    uint8_t g = GET_GRE(color)*a + GET_GRE(color_)*(1.0-a);
+    uint8_t b = GET_BLU(color)*a + GET_BLU(color_)*(1.0-a);
+    return set_pixel(x,y,SET_RGB(r,g,b));
+    //return set_pixel(x,y,color);
+}
 
 int (draw_hline)(uint16_t x, uint16_t y, uint16_t len, uint32_t color){
     int r;
Index: proj/graphics.h
===================================================================
--- proj/graphics.h	(revision 159)
+++ proj/graphics.h	(revision 160)
@@ -4,13 +4,16 @@
 #include <lcom/lcf.h>
 #include <stdint.h>
 
+#define GET_ALP(n)          (0xFF & ((n) >> 24))
 #define GET_RED(n)          (0xFF & ((n) >> 16))
 #define GET_GRE(n)          (0xFF & ((n) >>  8))
 #define GET_BLU(n)          (0xFF & (n      ))
+#define SET_ALP(n)          (((n)&0xFF) << 24)
 #define SET_RED(n)          (((n)&0xFF) << 16)
 #define SET_GRE(n)          (((n)&0xFF) <<  8)
 #define SET_BLU(n)          (((n)&0xFF)      )
-#define SET_COLOR(r,g,b)    (SET_RED(r) | SET_GRE(g) | SET_BLU(b))
+#define SET_RGB(r,g,b)      (             SET_RED(r) | SET_GRE(g) | SET_BLU(b))
+#define SET_ARGB(a,r,g,b)   (SET_ALP(a) | SET_RED(r) | SET_GRE(g) | SET_BLU(b))
 #define FAR2PHYS(n)         ((((n)>>12) & 0xFFFFFFF0) + ((n) & 0x0000FFFF))
 
 typedef struct __attribute__((packed)) {
@@ -61,7 +64,8 @@
 
 int (free_memory_map)(void);
 
-int (set_pixel)(uint16_t row, uint16_t col, uint32_t color);
+int (set_pixel)      (uint16_t x, uint16_t y, uint32_t color);
+int (set_pixel_alpha)(uint16_t x, uint16_t y, uint32_t color, uint8_t alpha);
 
 /**
  * @brief
Index: proj/proj.c
===================================================================
--- proj/proj.c	(revision 159)
+++ proj/proj.c	(revision 160)
@@ -23,7 +23,8 @@
 #include "proj_func.h"
 
 #ifdef DIOGO
-    #include "plus.xpm"
+    #include "shooter.xpm"
+    #include "pistol.xpm"
 #endif
 
 int main(int argc, char* argv[]) {
@@ -60,8 +61,15 @@
     };
 
     #ifdef DIOGO
-        sprite_t *sp = sprite_ctor((xpm_map_t)plus_xpm);
-        sprite_draw(sp);
+        paint_screen(0x777777);
+        sprite_t *shooter = sprite_ctor((xpm_map_t)shooter_xpm); sprite_set_pos(shooter, 100, 100); sprite_set_center(shooter, 25, 25);
+        for(double angle = 0; angle < 6.29; angle += 0.01){
+             sprite_set_angle(shooter, angle);
+             //paint_screen(0x777777);
+             sprite_draw(shooter);
+             tickdelay(micros_to_ticks(10000));
+        }
+        sprite_draw(shooter);
     #endif
 
     /// loop stuff
Index: proj/proj_macros.h
===================================================================
--- proj/proj_macros.h	(revision 159)
+++ proj/proj_macros.h	(revision 160)
@@ -19,6 +19,6 @@
 #define REFRESH_RATE    60      /** @brief Screen refresh rate */
 
 //Graphics mode
-#define GRAPH_MODE      DIRECT_800_600 /** @brief Graphic mode used */
+#define GRAPH_MODE      DIRECT_1280_1024_888 /** @brief Graphic mode used */
 
 #endif /* end of include guard: PROJ_MACROS_H_INCLUDED */
Index: proj/sprite.c
===================================================================
--- proj/sprite.c	(revision 159)
+++ proj/sprite.c	(revision 160)
@@ -3,10 +3,13 @@
 #include "sprite.h"
 
 #include "graphics.h"
+#include <math.h>
 
 struct sprite{
     int x, y;
     int w, h;
+    int u0, v0;
+    double theta;
     uint8_t *map;
 };
 
@@ -13,7 +16,7 @@
 sprite_t* sprite_ctor(const xpm_map_t xpm){
     sprite_t *ret = (sprite_t*)malloc(sizeof(sprite_t));
     if(ret == NULL) return NULL;
-    enum xpm_image_type type = XPM_8_8_8;
+    enum xpm_image_type type = XPM_8_8_8_8;
     xpm_image_t img;
     ret->map = xpm_load(xpm, type, &img);
     if(ret->map == NULL){
@@ -24,6 +27,9 @@
     ret->y = 0;
     ret->w = img.width;
     ret->h = img.height;
+    ret->u0 = 0;
+    ret->v0 = 0;
+    ret->theta = 0;
     return ret;
 }
 
@@ -39,17 +45,36 @@
     sprite_set_x(p, x);
     sprite_set_y(p, y);
 }
+void sprite_set_angle(sprite_t *p, double angle){ p->theta = angle; }
+void sprite_set_center(sprite_t *p, int u0, int v0){
+    p->u0 = u0;
+    p->v0 = v0;
+}
 
 int sprite_get_w(const sprite_t *p){ return p->w; }
 int sprite_get_h(const sprite_t *p){ return p->h; }
 
+void sprite_src2pic(const sprite_t *p, int x, int y, int *u, int *v){
+    int dx = x - p->x;
+    int dy = y - p->y;
+    int du = dx*cos(p->theta) - dy*sin(p->theta);
+    int dv = dx*sin(p->theta) + dy*cos(p->theta);
+    *u = du + p->u0;
+    *v = dv + p->v0;
+}
+
 void sprite_draw(const sprite_t *p){
-    uint8_t *m = p->map;
-    for (int i = 0; i < p->w; i++) {
-        for (int j = 0; j < p->h; j++, m += 3) {
-            if (p->x + i < get_XRes() && p->y + j < get_YRes()){
-                uint32_t color = SET_COLOR(*m,*(m+1),*(m+2));
-                set_pixel(p->x + i, p->y + j, color);
+    const int diag = sqrt(p->w*p->w + p->h*p->h)+2;
+    int u, v;
+    for(int y = p->y - diag; y < p->y + diag; ++y){
+        for(int x = p->x - diag; x < p->x + diag; ++x){
+            if (p->x + x < get_XRes() && p->y + y < get_YRes()){
+                sprite_src2pic(p, x, y, &u, &v);
+                if(0 <= u && u < p->w && 0 <= v && v < p->h){
+                    uint8_t *m = p->map + (v*p->w + u)*4;
+                    uint32_t color = SET_RGB(*(m+2), *(m+1), *(m));
+                    set_pixel_alpha(p->x + x, p->y + y, color, *(m+3));
+                }
             }
         }
     }
Index: proj/sprite.h
===================================================================
--- proj/sprite.h	(revision 159)
+++ proj/sprite.h	(revision 160)
@@ -7,9 +7,11 @@
 sprite_t* sprite_ctor(const xpm_map_t xpm);
 void      sprite_dtor(sprite_t *p);
 
-void sprite_set_x(sprite_t *p, int x);
-void sprite_set_y(sprite_t *p, int y);
-void sprite_set_pos(sprite_t *p, int x, int y);
+void sprite_set_x     (sprite_t *p, int x);
+void sprite_set_y     (sprite_t *p, int y);
+void sprite_set_pos   (sprite_t *p, int x, int y);
+void sprite_set_angle (sprite_t *p, double angle);
+void sprite_set_center(sprite_t *p, int u0, int v0);
 
 int sprite_get_h(const sprite_t *p);
 int sprite_get_w(const sprite_t *p);
