Index: proj/include/rectangle.h
===================================================================
--- proj/include/rectangle.h	(revision 284)
+++ proj/include/rectangle.h	(nonexistent)
@@ -1,24 +0,0 @@
-#ifndef RECTANGLE_H_INCLUDED
-#define RECTANGLE_H_INCLUDED
-
-struct rectangle;
-typedef struct rectangle rectangle_t;
-
-rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h);
-void         (rectangle_dtor)(rectangle_t *p);
-
-void (rectangle_set_pos)          (rectangle_t *p,  int16_t x,  int16_t y);
-void (rectangle_set_size)         (rectangle_t *p, uint16_t w, uint16_t h);
-void (rectangle_set_fill_color)   (rectangle_t *p, uint32_t color);
-void (rectangle_set_outline_color)(rectangle_t *p, uint32_t color);
-void (rectangle_set_outline_width)(rectangle_t *p,  int16_t width);
-
-int16_t  (rectangle_get_x)(const rectangle_t *p);
-int16_t  (rectangle_get_y)(const rectangle_t *p);
-uint16_t (rectangle_get_w)(const rectangle_t *p);
-uint16_t (rectangle_get_h)(const rectangle_t *p);
-int      (rectangle_collide_point)(const rectangle_t *p, int x, int y);
-
-void (rectangle_draw)(const rectangle_t *p);
-
-#endif //RECTANGLE_H_INCLUDED

Property changes on: proj/include/rectangle.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/include/font.h
===================================================================
--- proj/include/font.h	(revision 284)
+++ proj/include/font.h	(nonexistent)
@@ -1,34 +0,0 @@
-#ifndef FONT_H_INCLUDED
-#define FONT_H_INCLUDED
-
-enum text_valign{
-    text_valign_top    = -1,
-    text_valign_center =  0,
-    text_valign_bottom =  1
-};
-
-enum text_halign{
-    text_halign_left   = -1,
-    text_halign_center =  0,
-    text_halign_right  =  1
-};
-
-struct font;
-typedef struct font font_t;
-font_t* (font_ctor)(const char *s);
-void    (font_dtor)(font_t *p);
-
-struct text;
-typedef struct text text_t;
-text_t* (text_ctor)(const font_t *fnt, const char *txt);
-void    (text_dtor)(text_t *p);
-char* (text_get_string)(const text_t *p);
-void (text_set_text)  (text_t *p, const char *txt);
-void (text_set_pos)   (text_t *p, int16_t x, int16_t y);
-void (text_set_size)  (text_t *p, unsigned size);
-void (text_set_color) (text_t *p, uint32_t color);
-void (text_set_valign)(text_t *p, enum text_valign valign);
-void (text_set_halign)(text_t *p, enum text_halign halign);
-int (text_draw)     (const text_t *p);
-
-#endif //FONT_H_INCLUDED

Property changes on: proj/include/font.h
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/include/errors.h
===================================================================
--- proj/include/errors.h	(revision 284)
+++ proj/include/errors.h	(nonexistent)
@@ -1,27 +0,0 @@
-#ifndef ERRORS_H_INCLUDED
-#define ERRORS_H_INCLUDED
-
-/** @brief Error Codes */
-enum errors {
-    SUCCESS = 0,        /** @brief Sucessful */
-    NULL_PTR = 250,     /** @brief Null Pointer Error */
-    LCF_ERROR,          /** @brief Error originated on LCF */
-    SBCR_ERROR,         /** @brief Error on Subscribing Interrupt */
-    UNSBCR_ERROR,       /** @brief Error on Unsubscring Interrupt*/
-    READ_ERROR,         /** @brief Error on Reading from Port */
-    WRITE_ERROR,        /** @brief Error on Writing to Port */
-    TIMEOUT_ERROR,      /** @brief Timeout error */
-    INVALID_COMMAND,    /** @brief Invalid Command issued */
-    INVALID_STATE,      /** @brief State machine reached an invalid state */
-    BIOS_CALL_ERROR,    /** @brief Error upon BIOS call */
-    OUT_OF_RANGE,       /** @brief Accessing area out of range of memory */
-    ALLOC_ERROR,        /** @brief Memory allocation error */
-    LOGIC_ERROR,        /** @brief Logic error */
-    INVALID_ARG,        /** @brief Invalid argument */
-    NOK,                /** @brief Not OK */
-    TRANS_REFUSED,      /** @brief Transmission refused */
-    TRANS_FAILED,       /** @brief Transmission failed */
-    OTHER_ERROR         /** @brief Unspecified error */
-};
-
-#endif //ERRORS_H_INCLUDED

Property changes on: proj/include/errors.h
___________________________________________________________________
Deleted: svn:executable
Index: proj/src/rectangle.c
===================================================================
--- proj/src/rectangle.c	(revision 284)
+++ proj/src/rectangle.c	(nonexistent)
@@ -1,78 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "rectangle.h"
-
-#include "graph.h"
-#include "utils.h"
-
-struct rectangle{
-    int16_t  x, y;
-    uint16_t w, h;
-    uint32_t fill_color;
-    uint32_t outline_color;
-    int16_t  outline_width;
-};
-
-rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h){
-    rectangle_t *ret = (rectangle_t*)malloc(sizeof(rectangle_t));
-    if(ret == NULL) return NULL;
-    ret->x = x;
-    ret->y = y;
-    ret->w = w;
-    ret->h = h;
-    ret->fill_color    = 0xFFFFFF;
-    ret->outline_color = 0x000000;
-    ret->outline_width = 0;
-    return ret;
-}
-void (rectangle_dtor)(rectangle_t *p){
-    if(p == NULL) return;
-    free(p);
-}
-
-void (rectangle_set_pos)          (rectangle_t *p,  int16_t x,  int16_t y){ p->x = x; p->y = y; }
-void (rectangle_set_size)         (rectangle_t *p, uint16_t w, uint16_t h){ p->w = w; p->h = h; }
-void (rectangle_set_fill_color)   (rectangle_t *p, uint32_t color        ){ p->fill_color = color; }
-void (rectangle_set_outline_color)(rectangle_t *p, uint32_t color        ){ p->outline_color = color; }
-void (rectangle_set_outline_width)(rectangle_t *p,  int16_t width        ){ p->outline_width = width; }
-
-int16_t  (rectangle_get_x)(const rectangle_t *p){ return p->x; }
-int16_t  (rectangle_get_y)(const rectangle_t *p){ return p->y; }
-uint16_t (rectangle_get_w)(const rectangle_t *p){ return p->w; }
-uint16_t (rectangle_get_h)(const rectangle_t *p){ return p->h; }
-
-int (rectangle_collide_point)(const rectangle_t *p, int x, int y) {
-    int16_t x0 = p->x, y0 = p->y;
-    return (x >= x0 && x <= x0 + p->w) && (y >= y0 && y <= y0 + p->h);
-}
-
-static void (rectangle_draw_hline)(int16_t x, int16_t y, int16_t l, uint32_t color){
-    if(l < 0){ rectangle_draw_hline(x+l, y, -l, color); return; }
-    for(int16_t x_ = max(0,x); x_ < min(x+l,graph_get_XRes()); ++x_){
-        graph_set_pixel(x_, y, color);
-    }
-}
-
-static void (rectangle_draw_vline)(int16_t x, int16_t y, int16_t l, uint32_t color){
-    if(l < 0){ rectangle_draw_vline(x, y+l, -l, color); return; }
-    for(int16_t y_ = max(0,y); y_ < min(y+l,graph_get_YRes()); ++y_){
-        graph_set_pixel(x, y_, color);
-    }
-}
-
-void (rectangle_draw)(const rectangle_t *p){
-    for(int16_t y = max(p->y,0); y < min(p->y+p->h, graph_get_YRes()); ++y)
-        rectangle_draw_hline(p->x, y, p->w, p->fill_color);
-
-    int16_t step = (p->outline_width > 0 ? 1 : -1);
-    int16_t l = p->x, r = p->x+p->w, t = p->y, b = p->y+p->h;
-    if(step > 0){
-        --l; ++r; --t; ++b;
-    }
-    for(int16_t i = 0; i != p->outline_width; i += step, l -= step, r += step, t -= step, b += step){
-        rectangle_draw_hline(l  , t  , r-l, p->outline_color);
-        rectangle_draw_hline(l  , b-1, r-l, p->outline_color);
-        rectangle_draw_vline(l  , t  , b-t, p->outline_color);
-        rectangle_draw_vline(r-1, t  , b-t, p->outline_color);
-    }
-}

Property changes on: proj/src/rectangle.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/src/font.c
===================================================================
--- proj/src/font.c	(revision 284)
+++ proj/src/font.c	(nonexistent)
@@ -1,209 +0,0 @@
-#include <lcom/lcf.h>
-
-#include "font.h"
-
-#include "xpm_utils.h"
-#include "graph.h"
-#include "utils.h"
-#include "errors.h"
-#include <assert.h>
-
-struct glyph{
-    uint16_t w, h;
-    uint8_t *map;
-};
-typedef struct glyph glyph_t;
-static glyph_t* (glyph_ctor)(const char **xpm){
-    if(xpm == NULL) return NULL;
-    glyph_t *ret = malloc(sizeof(glyph_t));
-    if(ret == NULL) return NULL;
-    enum xpm_image_type type = XPM_8_8_8_8;
-    xpm_image_t img;
-    ret->map = NULL;
-    uint8_t *map = xpm_load((xpm_map_t)xpm, type, &img);
-    if(map == NULL){
-        free(ret);
-        return NULL;
-    }
-    ret->w = img.width;
-    ret->h = img.height;
-    ret->map = malloc(ret->w*ret->h*sizeof(uint8_t));
-    if(ret->map == NULL){
-        free(ret);
-        return NULL;
-    }
-    for(unsigned i = 0; i < ret->w*ret->h; ++i){
-        ret->map[i] = map[4*i+3];
-    }
-    return ret;
-}
-static void (glyph_dtor)(glyph_t *p){
-    if(p == NULL) return;
-    free(p->map);
-    free(p);
-}
-static int (glyph_draw_to_alpha_buffer)(const glyph_t *p, int16_t x, int16_t y, uint8_t *alp_buf, uint16_t W, uint16_t H){
-    if(p == NULL) return NULL_PTR;
-    for(int16_t h = 0; h < p->h; ++h){
-        for(int16_t w = 0; w < p->w; ++w){
-            uint8_t a = *(p->map + w + h*p->w);
-            int16_t x_ = x+w, y_ = y-p->h+h;
-            unsigned pos = x_ +y_*W;
-            alp_buf[pos] = a;
-        }
-    }
-    return SUCCESS;
-}
-
-struct font{
-    size_t nchars;
-    glyph_t **glyphs;
-};
-#include "sprite.h"
-#include "rectangle.h"
-font_t* (font_ctor)(const char *s){
-    font_t *ret = malloc(sizeof(font_t));
-    if(ret == NULL) return NULL;
-    ret->nchars = 128;
-    ret->glyphs = malloc(ret->nchars*sizeof(glyph_t*));
-    if(ret->glyphs == NULL){
-        free(ret->glyphs);
-        free(ret);
-        return NULL;
-    }
-    int good = false;
-    char filepath[1024];
-    for(size_t i = 0; i < ret->nchars; ++i){
-        sprintf(filepath, "%s/ascii%03d.xpm2", s, i);
-        char **xpm = xpm_load_xpm2(filepath);
-        ret->glyphs[i] = glyph_ctor((const char**)xpm);
-        if(ret->glyphs[i] != NULL) good = true;
-    }
-    if(good) return ret;
-    else{
-        //font_dtor(ret);
-        return NULL;
-    }
-}
-void (font_dtor)(font_t *p){
-    if(p == NULL) return;
-    for(size_t i = 0; i < p->nchars; ++i)
-        glyph_dtor(p->glyphs[i]);
-    free(p->glyphs);
-    free(p);
-}
-
-struct text{
-    const font_t *fnt;
-    char *txt;
-    int16_t x, y;
-    int size;
-    uint32_t color;
-    enum text_valign valign;
-    enum text_halign halign;
-};
-text_t* (text_ctor)(const font_t *fnt, const char *txt){
-    if(fnt == NULL) return NULL;
-    text_t *ret = malloc(sizeof(text_t));
-    if(ret == NULL) return NULL;
-    ret->fnt = fnt;
-    ret->txt = NULL;
-    text_set_text(ret, txt);
-    ret->x = 0;
-    ret->y = 0;
-    ret->size = 25;
-    ret->color = GRAPH_BLACK;
-    ret->valign = text_valign_top;
-    ret->halign = text_halign_left;
-    return ret;
-}
-void (text_dtor)(text_t *p){
-    if(p == NULL) return;
-    free(p->txt);
-    free(p);
-}
-void (text_set_text) (text_t *p, const char *txt){
-    size_t sz = strlen(txt);
-    p->txt = realloc(p->txt, (sz+1)*sizeof(char));
-    if(p->txt == NULL) return;
-    strcpy(p->txt, txt);
-}
-char* (text_get_string)(const text_t *p){return p->txt; }
-void (text_set_pos)   (text_t *p, int16_t x, int16_t y   ){ p->x = x; p->y = y; }
-void (text_set_size)  (text_t *p, unsigned size          ){ p->size = size    ; }
-void (text_set_color) (text_t *p, uint32_t color         ){ p->color = color  ; }
-void (text_set_valign)(text_t *p, enum text_valign valign){ p->valign = valign; }
-void (text_set_halign)(text_t *p, enum text_halign halign){ p->halign = halign; }
-
-int (text_draw)(const text_t *p){
-    if(p == NULL) return NULL_PTR;
-    int ret = SUCCESS;
-    // Get buffer with rescaled text
-    uint8_t *alp_new_buf = NULL;
-    uint16_t newH, newW;{
-        const size_t len = strlen(p->txt);
-        uint16_t W = 0, H = 0; {
-            for(size_t i = 0; i < len; ++i){
-                const glyph_t *g = p->fnt->glyphs[(size_t)p->txt[i]];
-                if(g != NULL){ W += g->w; H = max(H, g->h); }
-            }
-        }
-        uint8_t *alp_buf = malloc(W*H);
-        if(alp_buf == NULL) return ALLOC_ERROR;{
-            int16_t y = H;
-            int16_t x = 0;
-            for(size_t i = 0; i < len; ++i){
-                const glyph_t *g = p->fnt->glyphs[(size_t)p->txt[i]];
-                if(g != NULL){
-                    if((ret = glyph_draw_to_alpha_buffer(g, x, y, alp_buf, W, H))) return ret;
-                    x += g->w;
-                }
-            }
-        }
-
-        double factor = (double)p->size/(double)H;
-
-        newH = H*factor;
-        newW = W*factor;
-        alp_new_buf = malloc(newW*newH);
-        if(alp_new_buf == NULL) return ALLOC_ERROR;
-
-        for(size_t newy = 0; newy < newH; ++newy){
-            size_t y = newy/factor;
-            for(size_t newx = 0; newx < newW; ++newx){
-                size_t x = newx/factor;
-                *(alp_new_buf+newx+newy*newW) = *(alp_buf+x+y*W);
-            }
-        }
-        free(alp_buf);
-
-
-    }
-    // Get initial value of x
-    int16_t initx;{
-        switch(p->halign){
-            case text_halign_left  : initx = p->x         ; break;
-            case text_halign_center: initx = p->x - newW/2; break;
-            case text_halign_right : initx = p->x - newW  ; break;
-            default: return LOGIC_ERROR;
-        }
-    }
-    // Get initial value of y
-    int16_t inity;{
-        switch(p->valign){
-            case text_valign_top   : inity = p->y         ; break;
-            case text_valign_center: inity = p->y - newH/2; break;
-            case text_valign_bottom: inity = p->y - newH  ; break;
-            default: return LOGIC_ERROR;
-        }
-    }
-    // Draw text
-    for(int16_t newy = 0; newy < newH; ++newy){
-        for(int16_t newx = 0; newx < newW; ++newx){
-            uint8_t a = *(alp_new_buf+newx+newy*newW);
-            if(a < 0x7F) graph_set_pixel(initx+newx,inity+newy,p->color);
-        }
-    }
-    free(alp_new_buf);
-    return SUCCESS;
-}

Property changes on: proj/src/font.c
___________________________________________________________________
Deleted: svn:executable
## -1 +0,0 ##
-*
\ No newline at end of property
Index: proj/include/sprite.h
===================================================================
--- proj/include/sprite.h	(revision 284)
+++ proj/include/sprite.h	(revision 285)
@@ -1,51 +1,6 @@
 #ifndef SPRITE_H_INCLUDED
 #define SPRITE_H_INCLUDED
 
-struct basic_sprite;
-typedef struct basic_sprite basic_sprite_t;
 
-basic_sprite_t* (basic_sprite_ctor)(const char **xpm, int16_t u0, int16_t v0);
-void            (basic_sprite_dtor)(basic_sprite_t *p);
-const uint8_t* (basic_sprite_get_map)(const basic_sprite_t *p);
-uint16_t       (basic_sprite_get_w)  (const basic_sprite_t *p);
-uint16_t       (basic_sprite_get_h)  (const basic_sprite_t *p);
-int16_t        (basic_sprite_get_u0) (const basic_sprite_t *p);
-int16_t        (basic_sprite_get_v0) (const basic_sprite_t *p);
-/*
-struct basic_sprite_alpha;
-typedef struct basic_sprite_alpha basic_sprite_alpha_t;
 
-basic_sprite_alpha_t* (basic_sprite_alpha_ctor)(const char **xpm, int16_t u0, int16_t v0);
-void                  (basic_sprite_alpha_dtor)(basic_sprite_alpha_t *p);
-const uint8_t*        (basic_sprite_alpha_get_map)(const basic_sprite_alpha_t *p);
-uint16_t              (basic_sprite_alpha_get_w)  (const basic_sprite_alpha_t *p);
-uint16_t              (basic_sprite_alpha_get_h)  (const basic_sprite_alpha_t *p);
-int16_t               (basic_sprite_alpha_get_u0) (const basic_sprite_alpha_t *p);
-int16_t               (basic_sprite_alpha_get_v0) (const basic_sprite_alpha_t *p);
-*/
-struct sprite;
-typedef struct sprite sprite_t;
-
-sprite_t* (sprite_ctor)(const basic_sprite_t *bsp);
-/*
- * /!\ WARNING: Entity destructor does not destruct the basic_sprite passed as
- * constructor arguments, since it is assumed the same basic_sprite may be used to
- * draw several sprites. It is thus YOUR responsibility to delete basic_sprite's.
- * @param   p   Pointer to sprite_t to be destructed
- */
-void      (sprite_dtor)(sprite_t *p);
-
-void (sprite_set_pos)   (sprite_t *p, int16_t x, int16_t y);
-void (sprite_set_center)(sprite_t *p, int16_t u0, int16_t v0);
-void (sprite_set_angle) (sprite_t *p, double angle);
-void (sprite_set_scale) (sprite_t *p, double scale);
-
-int16_t  (sprite_get_x)(const sprite_t *p);
-int16_t  (sprite_get_y)(const sprite_t *p);
-double   (sprite_get_angle)(const sprite_t *p);
-uint16_t (sprite_get_w)(const sprite_t *p);
-uint16_t (sprite_get_h)(const sprite_t *p);
-
-void (sprite_draw)(const sprite_t *p);
-
 #endif //SPRITE_H_INCLUDED
Index: proj/libs/graph/include/font.h
===================================================================
--- proj/libs/graph/include/font.h	(nonexistent)
+++ proj/libs/graph/include/font.h	(revision 285)
@@ -0,0 +1,34 @@
+#ifndef FONT_H_INCLUDED
+#define FONT_H_INCLUDED
+
+enum text_valign{
+    text_valign_top    = -1,
+    text_valign_center =  0,
+    text_valign_bottom =  1
+};
+
+enum text_halign{
+    text_halign_left   = -1,
+    text_halign_center =  0,
+    text_halign_right  =  1
+};
+
+struct font;
+typedef struct font font_t;
+font_t* (font_ctor)(const char *s);
+void    (font_dtor)(font_t *p);
+
+struct text;
+typedef struct text text_t;
+text_t* (text_ctor)(const font_t *fnt, const char *txt);
+void    (text_dtor)(text_t *p);
+char* (text_get_string)(const text_t *p);
+void (text_set_text)  (text_t *p, const char *txt);
+void (text_set_pos)   (text_t *p, int16_t x, int16_t y);
+void (text_set_size)  (text_t *p, unsigned size);
+void (text_set_color) (text_t *p, uint32_t color);
+void (text_set_valign)(text_t *p, enum text_valign valign);
+void (text_set_halign)(text_t *p, enum text_halign halign);
+int (text_draw)     (const text_t *p);
+
+#endif //FONT_H_INCLUDED

Property changes on: proj/libs/graph/include/font.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/graph/include/graph.h
===================================================================
--- proj/libs/graph/include/graph.h	(revision 284)
+++ proj/libs/graph/include/graph.h	(revision 285)
@@ -50,4 +50,41 @@
 /// DRAW
 int (graph_draw)(void);
 
+/// SPRITE ================================
+struct basic_sprite;
+typedef struct basic_sprite basic_sprite_t;
+
+basic_sprite_t* (basic_sprite_ctor)(const char **xpm, int16_t u0, int16_t v0);
+void            (basic_sprite_dtor)(basic_sprite_t *p);
+const uint8_t* (basic_sprite_get_map)(const basic_sprite_t *p);
+uint16_t       (basic_sprite_get_w)  (const basic_sprite_t *p);
+uint16_t       (basic_sprite_get_h)  (const basic_sprite_t *p);
+int16_t        (basic_sprite_get_u0) (const basic_sprite_t *p);
+int16_t        (basic_sprite_get_v0) (const basic_sprite_t *p);
+
+struct sprite;
+typedef struct sprite sprite_t;
+
+sprite_t* (sprite_ctor)(const basic_sprite_t *bsp);
+/*
+ * /!\ WARNING: Entity destructor does not destruct the basic_sprite passed as
+ * constructor arguments, since it is assumed the same basic_sprite may be used to
+ * draw several sprites. It is thus YOUR responsibility to delete basic_sprite's.
+ * @param   p   Pointer to sprite_t to be destructed
+ */
+void      (sprite_dtor)(sprite_t *p);
+
+void (sprite_set_pos)   (sprite_t *p, int16_t x, int16_t y);
+void (sprite_set_center)(sprite_t *p, int16_t u0, int16_t v0);
+void (sprite_set_angle) (sprite_t *p, double angle);
+void (sprite_set_scale) (sprite_t *p, double scale);
+
+int16_t  (sprite_get_x)(const sprite_t *p);
+int16_t  (sprite_get_y)(const sprite_t *p);
+double   (sprite_get_angle)(const sprite_t *p);
+uint16_t (sprite_get_w)(const sprite_t *p);
+uint16_t (sprite_get_h)(const sprite_t *p);
+
+void (sprite_draw)(const sprite_t *p);
+
 #endif /* end of include guard: GRAPH_H_INCLUDED */
Index: proj/libs/graph/include/rectangle.h
===================================================================
--- proj/libs/graph/include/rectangle.h	(nonexistent)
+++ proj/libs/graph/include/rectangle.h	(revision 285)
@@ -0,0 +1,24 @@
+#ifndef RECTANGLE_H_INCLUDED
+#define RECTANGLE_H_INCLUDED
+
+struct rectangle;
+typedef struct rectangle rectangle_t;
+
+rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h);
+void         (rectangle_dtor)(rectangle_t *p);
+
+void (rectangle_set_pos)          (rectangle_t *p,  int16_t x,  int16_t y);
+void (rectangle_set_size)         (rectangle_t *p, uint16_t w, uint16_t h);
+void (rectangle_set_fill_color)   (rectangle_t *p, uint32_t color);
+void (rectangle_set_outline_color)(rectangle_t *p, uint32_t color);
+void (rectangle_set_outline_width)(rectangle_t *p,  int16_t width);
+
+int16_t  (rectangle_get_x)(const rectangle_t *p);
+int16_t  (rectangle_get_y)(const rectangle_t *p);
+uint16_t (rectangle_get_w)(const rectangle_t *p);
+uint16_t (rectangle_get_h)(const rectangle_t *p);
+int      (rectangle_collide_point)(const rectangle_t *p, int x, int y);
+
+void (rectangle_draw)(const rectangle_t *p);
+
+#endif //RECTANGLE_H_INCLUDED

Property changes on: proj/libs/graph/include/rectangle.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/graph/src/font.c
===================================================================
--- proj/libs/graph/src/font.c	(nonexistent)
+++ proj/libs/graph/src/font.c	(revision 285)
@@ -0,0 +1,209 @@
+#include <lcom/lcf.h>
+
+#include "font.h"
+
+#include "xpm_utils.h"
+#include "graph.h"
+#include "utils.h"
+#include "errors.h"
+#include <assert.h>
+
+struct glyph{
+    uint16_t w, h;
+    uint8_t *map;
+};
+typedef struct glyph glyph_t;
+static glyph_t* (glyph_ctor)(const char **xpm){
+    if(xpm == NULL) return NULL;
+    glyph_t *ret = malloc(sizeof(glyph_t));
+    if(ret == NULL) return NULL;
+    enum xpm_image_type type = XPM_8_8_8_8;
+    xpm_image_t img;
+    ret->map = NULL;
+    uint8_t *map = xpm_load((xpm_map_t)xpm, type, &img);
+    if(map == NULL){
+        free(ret);
+        return NULL;
+    }
+    ret->w = img.width;
+    ret->h = img.height;
+    ret->map = malloc(ret->w*ret->h*sizeof(uint8_t));
+    if(ret->map == NULL){
+        free(ret);
+        return NULL;
+    }
+    for(unsigned i = 0; i < ret->w*ret->h; ++i){
+        ret->map[i] = map[4*i+3];
+    }
+    return ret;
+}
+static void (glyph_dtor)(glyph_t *p){
+    if(p == NULL) return;
+    free(p->map);
+    free(p);
+}
+static int (glyph_draw_to_alpha_buffer)(const glyph_t *p, int16_t x, int16_t y, uint8_t *alp_buf, uint16_t W, uint16_t H){
+    if(p == NULL) return NULL_PTR;
+    for(int16_t h = 0; h < p->h; ++h){
+        for(int16_t w = 0; w < p->w; ++w){
+            uint8_t a = *(p->map + w + h*p->w);
+            int16_t x_ = x+w, y_ = y-p->h+h;
+            unsigned pos = x_ +y_*W;
+            alp_buf[pos] = a;
+        }
+    }
+    return SUCCESS;
+}
+
+struct font{
+    size_t nchars;
+    glyph_t **glyphs;
+};
+#include "sprite.h"
+#include "rectangle.h"
+font_t* (font_ctor)(const char *s){
+    font_t *ret = malloc(sizeof(font_t));
+    if(ret == NULL) return NULL;
+    ret->nchars = 128;
+    ret->glyphs = malloc(ret->nchars*sizeof(glyph_t*));
+    if(ret->glyphs == NULL){
+        free(ret->glyphs);
+        free(ret);
+        return NULL;
+    }
+    int good = false;
+    char filepath[1024];
+    for(size_t i = 0; i < ret->nchars; ++i){
+        sprintf(filepath, "%s/ascii%03d.xpm2", s, i);
+        char **xpm = xpm_load_xpm2(filepath);
+        ret->glyphs[i] = glyph_ctor((const char**)xpm);
+        if(ret->glyphs[i] != NULL) good = true;
+    }
+    if(good) return ret;
+    else{
+        //font_dtor(ret);
+        return NULL;
+    }
+}
+void (font_dtor)(font_t *p){
+    if(p == NULL) return;
+    for(size_t i = 0; i < p->nchars; ++i)
+        glyph_dtor(p->glyphs[i]);
+    free(p->glyphs);
+    free(p);
+}
+
+struct text{
+    const font_t *fnt;
+    char *txt;
+    int16_t x, y;
+    int size;
+    uint32_t color;
+    enum text_valign valign;
+    enum text_halign halign;
+};
+text_t* (text_ctor)(const font_t *fnt, const char *txt){
+    if(fnt == NULL) return NULL;
+    text_t *ret = malloc(sizeof(text_t));
+    if(ret == NULL) return NULL;
+    ret->fnt = fnt;
+    ret->txt = NULL;
+    text_set_text(ret, txt);
+    ret->x = 0;
+    ret->y = 0;
+    ret->size = 25;
+    ret->color = GRAPH_BLACK;
+    ret->valign = text_valign_top;
+    ret->halign = text_halign_left;
+    return ret;
+}
+void (text_dtor)(text_t *p){
+    if(p == NULL) return;
+    free(p->txt);
+    free(p);
+}
+void (text_set_text) (text_t *p, const char *txt){
+    size_t sz = strlen(txt);
+    p->txt = realloc(p->txt, (sz+1)*sizeof(char));
+    if(p->txt == NULL) return;
+    strcpy(p->txt, txt);
+}
+char* (text_get_string)(const text_t *p){return p->txt; }
+void (text_set_pos)   (text_t *p, int16_t x, int16_t y   ){ p->x = x; p->y = y; }
+void (text_set_size)  (text_t *p, unsigned size          ){ p->size = size    ; }
+void (text_set_color) (text_t *p, uint32_t color         ){ p->color = color  ; }
+void (text_set_valign)(text_t *p, enum text_valign valign){ p->valign = valign; }
+void (text_set_halign)(text_t *p, enum text_halign halign){ p->halign = halign; }
+
+int (text_draw)(const text_t *p){
+    if(p == NULL) return NULL_PTR;
+    int ret = SUCCESS;
+    // Get buffer with rescaled text
+    uint8_t *alp_new_buf = NULL;
+    uint16_t newH, newW;{
+        const size_t len = strlen(p->txt);
+        uint16_t W = 0, H = 0; {
+            for(size_t i = 0; i < len; ++i){
+                const glyph_t *g = p->fnt->glyphs[(size_t)p->txt[i]];
+                if(g != NULL){ W += g->w; H = max(H, g->h); }
+            }
+        }
+        uint8_t *alp_buf = malloc(W*H);
+        if(alp_buf == NULL) return ALLOC_ERROR;{
+            int16_t y = H;
+            int16_t x = 0;
+            for(size_t i = 0; i < len; ++i){
+                const glyph_t *g = p->fnt->glyphs[(size_t)p->txt[i]];
+                if(g != NULL){
+                    if((ret = glyph_draw_to_alpha_buffer(g, x, y, alp_buf, W, H))) return ret;
+                    x += g->w;
+                }
+            }
+        }
+
+        double factor = (double)p->size/(double)H;
+
+        newH = H*factor;
+        newW = W*factor;
+        alp_new_buf = malloc(newW*newH);
+        if(alp_new_buf == NULL) return ALLOC_ERROR;
+
+        for(size_t newy = 0; newy < newH; ++newy){
+            size_t y = newy/factor;
+            for(size_t newx = 0; newx < newW; ++newx){
+                size_t x = newx/factor;
+                *(alp_new_buf+newx+newy*newW) = *(alp_buf+x+y*W);
+            }
+        }
+        free(alp_buf);
+
+
+    }
+    // Get initial value of x
+    int16_t initx;{
+        switch(p->halign){
+            case text_halign_left  : initx = p->x         ; break;
+            case text_halign_center: initx = p->x - newW/2; break;
+            case text_halign_right : initx = p->x - newW  ; break;
+            default: return LOGIC_ERROR;
+        }
+    }
+    // Get initial value of y
+    int16_t inity;{
+        switch(p->valign){
+            case text_valign_top   : inity = p->y         ; break;
+            case text_valign_center: inity = p->y - newH/2; break;
+            case text_valign_bottom: inity = p->y - newH  ; break;
+            default: return LOGIC_ERROR;
+        }
+    }
+    // Draw text
+    for(int16_t newy = 0; newy < newH; ++newy){
+        for(int16_t newx = 0; newx < newW; ++newx){
+            uint8_t a = *(alp_new_buf+newx+newy*newW);
+            if(a < 0x7F) graph_set_pixel(initx+newx,inity+newy,p->color);
+        }
+    }
+    free(alp_new_buf);
+    return SUCCESS;
+}

Property changes on: proj/libs/graph/src/font.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/graph/src/rectangle.c
===================================================================
--- proj/libs/graph/src/rectangle.c	(nonexistent)
+++ proj/libs/graph/src/rectangle.c	(revision 285)
@@ -0,0 +1,78 @@
+#include <lcom/lcf.h>
+
+#include "rectangle.h"
+
+#include "graph.h"
+#include "utils.h"
+
+struct rectangle{
+    int16_t  x, y;
+    uint16_t w, h;
+    uint32_t fill_color;
+    uint32_t outline_color;
+    int16_t  outline_width;
+};
+
+rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h){
+    rectangle_t *ret = (rectangle_t*)malloc(sizeof(rectangle_t));
+    if(ret == NULL) return NULL;
+    ret->x = x;
+    ret->y = y;
+    ret->w = w;
+    ret->h = h;
+    ret->fill_color    = 0xFFFFFF;
+    ret->outline_color = 0x000000;
+    ret->outline_width = 0;
+    return ret;
+}
+void (rectangle_dtor)(rectangle_t *p){
+    if(p == NULL) return;
+    free(p);
+}
+
+void (rectangle_set_pos)          (rectangle_t *p,  int16_t x,  int16_t y){ p->x = x; p->y = y; }
+void (rectangle_set_size)         (rectangle_t *p, uint16_t w, uint16_t h){ p->w = w; p->h = h; }
+void (rectangle_set_fill_color)   (rectangle_t *p, uint32_t color        ){ p->fill_color = color; }
+void (rectangle_set_outline_color)(rectangle_t *p, uint32_t color        ){ p->outline_color = color; }
+void (rectangle_set_outline_width)(rectangle_t *p,  int16_t width        ){ p->outline_width = width; }
+
+int16_t  (rectangle_get_x)(const rectangle_t *p){ return p->x; }
+int16_t  (rectangle_get_y)(const rectangle_t *p){ return p->y; }
+uint16_t (rectangle_get_w)(const rectangle_t *p){ return p->w; }
+uint16_t (rectangle_get_h)(const rectangle_t *p){ return p->h; }
+
+int (rectangle_collide_point)(const rectangle_t *p, int x, int y) {
+    int16_t x0 = p->x, y0 = p->y;
+    return (x >= x0 && x <= x0 + p->w) && (y >= y0 && y <= y0 + p->h);
+}
+
+static void (rectangle_draw_hline)(int16_t x, int16_t y, int16_t l, uint32_t color){
+    if(l < 0){ rectangle_draw_hline(x+l, y, -l, color); return; }
+    for(int16_t x_ = max(0,x); x_ < min(x+l,graph_get_XRes()); ++x_){
+        graph_set_pixel(x_, y, color);
+    }
+}
+
+static void (rectangle_draw_vline)(int16_t x, int16_t y, int16_t l, uint32_t color){
+    if(l < 0){ rectangle_draw_vline(x, y+l, -l, color); return; }
+    for(int16_t y_ = max(0,y); y_ < min(y+l,graph_get_YRes()); ++y_){
+        graph_set_pixel(x, y_, color);
+    }
+}
+
+void (rectangle_draw)(const rectangle_t *p){
+    for(int16_t y = max(p->y,0); y < min(p->y+p->h, graph_get_YRes()); ++y)
+        rectangle_draw_hline(p->x, y, p->w, p->fill_color);
+
+    int16_t step = (p->outline_width > 0 ? 1 : -1);
+    int16_t l = p->x, r = p->x+p->w, t = p->y, b = p->y+p->h;
+    if(step > 0){
+        --l; ++r; --t; ++b;
+    }
+    for(int16_t i = 0; i != p->outline_width; i += step, l -= step, r += step, t -= step, b += step){
+        rectangle_draw_hline(l  , t  , r-l, p->outline_color);
+        rectangle_draw_hline(l  , b-1, r-l, p->outline_color);
+        rectangle_draw_vline(l  , t  , b-t, p->outline_color);
+        rectangle_draw_vline(r-1, t  , b-t, p->outline_color);
+    }
+}

Property changes on: proj/libs/graph/src/rectangle.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/libs/utils/include/errors.h
===================================================================
--- proj/libs/utils/include/errors.h	(nonexistent)
+++ proj/libs/utils/include/errors.h	(revision 285)
@@ -0,0 +1,27 @@
+#ifndef ERRORS_H_INCLUDED
+#define ERRORS_H_INCLUDED
+
+/** @brief Error Codes */
+enum errors {
+    SUCCESS = 0,        /** @brief Sucessful */
+    NULL_PTR = 250,     /** @brief Null Pointer Error */
+    LCF_ERROR,          /** @brief Error originated on LCF */
+    SBCR_ERROR,         /** @brief Error on Subscribing Interrupt */
+    UNSBCR_ERROR,       /** @brief Error on Unsubscring Interrupt*/
+    READ_ERROR,         /** @brief Error on Reading from Port */
+    WRITE_ERROR,        /** @brief Error on Writing to Port */
+    TIMEOUT_ERROR,      /** @brief Timeout error */
+    INVALID_COMMAND,    /** @brief Invalid Command issued */
+    INVALID_STATE,      /** @brief State machine reached an invalid state */
+    BIOS_CALL_ERROR,    /** @brief Error upon BIOS call */
+    OUT_OF_RANGE,       /** @brief Accessing area out of range of memory */
+    ALLOC_ERROR,        /** @brief Memory allocation error */
+    LOGIC_ERROR,        /** @brief Logic error */
+    INVALID_ARG,        /** @brief Invalid argument */
+    NOK,                /** @brief Not OK */
+    TRANS_REFUSED,      /** @brief Transmission refused */
+    TRANS_FAILED,       /** @brief Transmission failed */
+    OTHER_ERROR         /** @brief Unspecified error */
+};
+
+#endif //ERRORS_H_INCLUDED

Property changes on: proj/libs/utils/include/errors.h
___________________________________________________________________
Added: svn:executable
