Index: proj/include/ent.h
===================================================================
--- proj/include/ent.h	(revision 322)
+++ proj/include/ent.h	(revision 323)
@@ -69,8 +69,8 @@
 int    (map_collides_point)(const map_t *p, double x, double y);
 int    (map_collides_gunner)(const map_t *p, const gunner_t *gunner);
 int    (map_collides_bullet)(const map_t *p, const bullet_t *bullet);
-int16_t (map_get_width)   (const map_t *p);
-int16_t (map_get_height)  (const map_t *p);
+uint16_t (map_get_width)   (const map_t *p);
+uint16_t (map_get_height)  (const map_t *p);
 int (map_make_dijkstra)(map_t *p, double x_, double y_);
 int (map_where_to_follow)(const map_t *p, double x, double y, double *theta);
 int (gunner_collides_bullet)(const gunner_t *shooter, const bullet_t *bull);
Index: proj/include/interrupts_func.h
===================================================================
--- proj/include/interrupts_func.h	(revision 322)
+++ proj/include/interrupts_func.h	(revision 323)
@@ -21,6 +21,6 @@
  */
 void interrupt_handler(uint8_t handler);
 
-int get_interrupts_vector(uint32_t *p);
+int get_interrupts_vector(uint64_t *p);
 
 #endif /* end of include guard: INTERRUPTS_FUNC_H_INCLUDED */
Index: proj/libs/graph/include/font.h
===================================================================
--- proj/libs/graph/include/font.h	(revision 322)
+++ proj/libs/graph/include/font.h	(revision 323)
@@ -95,11 +95,11 @@
  */
 void (text_set_pos)   (text_t *p, int16_t x, int16_t y);
 /**
- * @brief Set text size (letter size).
+ * @brief Set text size (letter size, in pixels).
  * @param   p       Pointer to text
  * @param   size    Letter size of the text
  */
-void (text_set_size)  (text_t *p, unsigned size);
+void (text_set_size)  (text_t *p, uint16_t size);
 /**
  * @brief Set text color.
  * @param   p       Pointer to text
Index: proj/libs/graph/src/font.c
===================================================================
--- proj/libs/graph/src/font.c	(revision 322)
+++ proj/libs/graph/src/font.c	(revision 323)
@@ -20,7 +20,7 @@
  * @param   xpm XPM describing the glyph
  * @return      Pointer to created glyph
  */
-static glyph_t* (glyph_ctor)(const char **xpm){
+static glyph_t* (glyph_ctor)(const char *const *xpm){
     if(xpm == NULL) return NULL;
     glyph_t *ret = malloc(sizeof(glyph_t));
     if(ret == NULL) return NULL;
@@ -71,8 +71,8 @@
         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;
+            int32_t pos = x_ +y_*W;
+            if(0 <= pos && pos < W*H) alp_buf[pos] = a;
         }
     }
     return SUCCESS;
@@ -98,7 +98,7 @@
     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);
+        ret->glyphs[i] = glyph_ctor((const char *const *)xpm);
         if(ret->glyphs[i] != NULL) good = true;
     }
     if(good) return ret;
@@ -137,10 +137,10 @@
     const font_t *fnt;
     char *txt;
     int16_t x, y;
-    int size;
-    uint32_t color;
+    uint16_t size;
     text_valign valign;
     text_halign halign;
+    uint32_t color;
 };
 text_t* (text_ctor)(const font_t *fnt, const char *txt){
     if(fnt == NULL) return NULL;
@@ -170,7 +170,7 @@
 }
 const 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_size)  (text_t *p, uint16_t size       ){ p->size = size    ; }
 void (text_set_color) (text_t *p, uint32_t color      ){ p->color = color  ; }
 void (text_set_valign)(text_t *p, text_valign valign  ){ p->valign = valign; }
 void (text_set_halign)(text_t *p, text_halign halign  ){ p->halign = halign; }
@@ -186,12 +186,12 @@
         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); }
+                if(g != NULL){ W += g->w; H = umax16(H, g->h); }
             }
         }
         uint8_t *alp_buf = malloc(W*H);
         if(alp_buf == NULL) return ALLOC_ERROR;{
-            int16_t y = H;
+            int16_t y = (int16_t)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]];
@@ -204,15 +204,15 @@
 
         double factor = (double)p->size/(double)H;
 
-        newH = H*factor;
-        newW = W*factor;
+        newH = (uint16_t)(H*factor);
+        newW = (uint16_t)(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;
+        for(uint16_t newy = 0; newy < newH; ++newy){
+            uint16_t y = (uint16_t)(newy/factor);
+            for(uint16_t newx = 0; newx < newW; ++newx){
+                uint16_t x = (uint16_t)(newx/factor);
                 *(alp_new_buf+newx+newy*newW) = *(alp_buf+x+y*W);
             }
         }
@@ -224,7 +224,7 @@
             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;
+            //default: return LOGIC_ERROR;
         }
     }
     // Get initial value of y
@@ -233,7 +233,7 @@
             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;
+            //default: return LOGIC_ERROR;
         }
     }
     // Draw text
@@ -244,7 +244,7 @@
             if(!(0 <= x && x < graph_get_XRes() &&
                  0 <= y && y < graph_get_YRes())) continue;
             uint8_t a = *(alp_new_buf+newx+newy*newW);
-            if(a < ALPHA_THRESHOLD) graph_set_pixel(x,y,p->color);
+            if(a < ALPHA_THRESHOLD) graph_set_pixel((uint16_t)x,(uint16_t)y,p->color);
         }
     }
     free(alp_new_buf);
Index: proj/libs/graph/src/graph.c
===================================================================
--- proj/libs/graph/src/graph.c	(revision 322)
+++ proj/libs/graph/src/graph.c	(revision 323)
@@ -8,22 +8,22 @@
 #define VC_BIOS_SERV  0x10 /** @brief Interrupt service of video card */
 #define VBE_CALL      0x4F /** @brief VBE call function specifier */
 
-#define MBYTE_BASE  0x0         /** @brief Base address (zero address) */
-#define MBYTE_SIZE  0xFFFFF     /** @brief Size of a mebibyte */
+//#define MBYTE_BASE  0x0         /** @brief Base address (zero address) */
+//#define MBYTE_SIZE  0xFFFFF     /** @brief Size of a mebibyte */
 
 // Graphics Functions
-#define VBE_CTRL_INFO       0x00    /** @brief Get VBE Controller Information */
+//#define VBE_CTRL_INFO       0x00    /** @brief Get VBE Controller Information */
 #define VBE_MD_INFO         0x01    /** @brief Get VBE Mode Information */
 #define SET_VBE_MD          0x02    /** @brief Set VBE Mode */
 
 // Error codes (AH)
 #define AH_SUCCESS          0x00    /** @brief Success code on BIOS call */
-#define AH_FUNC_CALL_FAIL   0x01    /** @brief Function call failed */
-#define AH_FUNC_NOT_SUPP    0x02    /** @brief Function call is not supported in current HW configuration */
-#define AH_FUNC_INVALID     0x03    /** @brief Invalid function in current video mode */
+//#define AH_FUNC_CALL_FAIL   0x01    /** @brief Function call failed */
+//#define AH_FUNC_NOT_SUPP    0x02    /** @brief Function call is not supported in current HW configuration */
+//#define AH_FUNC_INVALID     0x03    /** @brief Invalid function in current video mode */
 
 /// MACROS
-#define FAR2PHYS(n)         ((((n)>>12) & 0xFFFFFFF0) + ((n) & 0x0000FFFF))
+//#define FAR2PHYS(n)         ((((n)>>12) & 0xFFFFFFF0) + ((n) & 0x0000FFFF))
 
 /// STRUCT
 typedef struct __attribute__((packed)) {
@@ -211,11 +211,6 @@
 */
 
 /// INIT
-/**
- * @brief
- * @param mode
- * @return
- */
 static int (graph_set_mode)(uint16_t mode) {
     struct reg86 reg_86;
 
@@ -314,46 +309,6 @@
 int16_t        (basic_sprite_get_u0) (const basic_sprite_t *p){ return p->u0 ; }
 int16_t        (basic_sprite_get_v0) (const basic_sprite_t *p){ return p->v0 ; }
 
-/*
-struct basic_sprite_alpha{
-    uint8_t *map;
-    uint16_t w, h;
-    int16_t u0, v0;
-};
-basic_sprite_alpha_t* (basic_sprite_alpha_ctor)(const char **xpm, int16_t u0, int16_t v0){
-    basic_sprite_alpha_t *ret = malloc(sizeof(basic_sprite_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 *m = xpm_load((xpm_map_t)xpm, type, &img);
-    if(m == NULL){
-        basic_sprite_alpha_dtor(ret);
-        return NULL;
-    }
-    ret->map = m;
-    if(ret->map == NULL){
-        basic_sprite_alpha_dtor(ret);
-        return NULL;
-    }
-    ret->w = img.width;
-    ret->h = img.height;
-    ret->u0 = u0;
-    ret->v0 = v0;
-    return ret;
-}
-void (basic_sprite_alpha_dtor)(basic_sprite_alpha_t *p){
-    if(p == NULL) return;
-    free(p->map);
-    free(p);
-}
-const uint8_t* (basic_sprite_alpha_get_map)(const basic_sprite_alpha_t *p){ return p->map; }
-uint16_t       (basic_sprite_alpha_get_w)  (const basic_sprite_alpha_t *p){ return p->w  ; }
-uint16_t       (basic_sprite_alpha_get_h)  (const basic_sprite_alpha_t *p){ return p->h  ; }
-int16_t        (basic_sprite_alpha_get_u0) (const basic_sprite_alpha_t *p){ return p->u0 ; }
-int16_t        (basic_sprite_alpha_get_v0) (const basic_sprite_alpha_t *p){ return p->v0 ; }
-*/
-
 struct sprite{
     const basic_sprite_t *bsp;
     int16_t x, y; //position in screen
@@ -381,20 +336,20 @@
 void (sprite_set_pos)   (sprite_t *p, int16_t x , int16_t y ){ p->x = x; p->y = y; }
 void (sprite_set_angle) (sprite_t *p, double angle          ){ p->theta = angle; p->c = fm_cos(p->theta); p->s = fm_sin(p->theta); }
 void (sprite_set_scale) (sprite_t *p, double scale          ){
-    if(p->scale == scale) return;
+    if(deq(p->scale, scale)) return;
     p->scale = scale;
 
-    p->su0 = p->bsp->u0*p->scale;
-    p->sv0 = p->bsp->u0*p->scale;
+    p->su0 = (int16_t)(p->bsp->u0*p->scale);
+    p->sv0 = (int16_t)(p->bsp->u0*p->scale);
 
     const uint16_t W = basic_sprite_get_w(p->bsp),
                    H = basic_sprite_get_h(p->bsp);
-    uint16_t sW = W*scale, sH = H*scale;
+    uint16_t sW = (uint16_t)(W*scale), sH = (uint16_t)(H*scale);
     p->sbuf = realloc(p->sbuf, sW*sH*4);
     const uint8_t *map = basic_sprite_get_map(p->bsp);
     for(uint16_t sx = 0; sx < sW; ++sx){
         for(uint16_t sy = 0; sy < sH; ++sy){
-            uint16_t x = sx/scale, y = sy/scale;
+            uint16_t x = (uint16_t)(sx/scale), y = (uint16_t)(sy/scale);
             if(x > W || y > H) continue;
             memcpy(p->sbuf+4*(sx+sy*sW), map+4*(x+y*W), 4);
         }
@@ -405,7 +360,7 @@
 double   (sprite_get_angle)(const sprite_t *p){ return p->theta; }
 uint16_t (sprite_get_w)(const sprite_t *p){ return basic_sprite_get_w(p->bsp); }
 uint16_t (sprite_get_h)(const sprite_t *p){ return basic_sprite_get_h(p->bsp); }
-void (sprite_src2sbuf)(const sprite_t *p, int16_t x, int16_t y, int16_t *u, int16_t *v){
+static void (sprite_src2sbuf)(const sprite_t *p, int16_t x, int16_t y, int16_t *u, int16_t *v){
     if(p->theta == 0.0){
         *u = x - p->x + p->su0;
         *v = y - p->y + p->sv0;
@@ -412,36 +367,36 @@
     }else{
         double dx = x - p->x;
         double dy = y - p->y;
-        int16_t du = dx*p->c - dy*p->s - 0.5f;
-        int16_t dv = dx*p->s + dy*p->c - 0.5f;
+        int16_t du = (int16_t)(dx*p->c - dy*p->s - 0.5f);
+        int16_t dv = (int16_t)(dx*p->s + dy*p->c - 0.5f);
         *u = du + p->su0;
         *v = dv + p->sv0;
     }
 }
-void (sprite_sbuf2src)(const sprite_t *p, int16_t u, int16_t v, int16_t *x, int16_t *y){
+static void (sprite_sbuf2src)(const sprite_t *p, int16_t u, int16_t v, int16_t *x, int16_t *y){
     int16_t du = u - p->su0;
     int16_t dv = v - p->sv0;
     double dx =  du*p->c + dv*p->s;
     double dy = -du*p->s + dv*p->c;
-    *x = dx + 0.5 + p->x;
-    *y = dy + 0.5 + p->y;
+    *x = (int16_t)(dx + 0.5 + p->x);
+    *y = (int16_t)(dy + 0.5 + p->y);
 }
 
 void (sprite_draw)(const sprite_t *p){
-    const uint16_t sw = p->scale*basic_sprite_get_w(p->bsp);
-    const uint16_t sh = p->scale*basic_sprite_get_h(p->bsp);
+    const uint16_t sw = (uint16_t)(p->scale*basic_sprite_get_w(p->bsp));
+    const uint16_t sh = (uint16_t)(p->scale*basic_sprite_get_h(p->bsp));
     int16_t xmin, xmax, ymin, ymax; {
         int16_t x, y;
-        sprite_sbuf2src(p, 0 , 0 , &x, &y);
+        sprite_sbuf2src(p, 0          , 0          , &x, &y);
         xmin = x; xmax = x; ymin = y; ymax = y;
-        sprite_sbuf2src(p, sw, 0 , &x, &y);
-        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
-        sprite_sbuf2src(p, 0 , sh, &x, &y);
-        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
-        sprite_sbuf2src(p, sw, sh, &x, &y);
-        xmin = min(x, xmin); xmax = max(x, xmax); ymin = min(y, ymin); ymax = max(y, ymax);
-        xmin = max(xmin-2, 0); xmax = min(xmax+2, graph_get_XRes());
-        ymin = max(ymin-2, 0); ymax = min(ymax+2, graph_get_YRes());
+        sprite_sbuf2src(p, (int16_t)sw, 0          , &x, &y);
+        xmin = min16(x, xmin); xmax = max16(x, xmax); ymin = min16(y, ymin); ymax = max16(y, ymax);
+        sprite_sbuf2src(p, 0          , (int16_t)sh, &x, &y);
+        xmin = min16(x, xmin); xmax = max16(x, xmax); ymin = min16(y, ymin); ymax = max16(y, ymax);
+        sprite_sbuf2src(p, (int16_t)sw, (int16_t)sh, &x, &y);
+        xmin = min16(x, xmin); xmax = max16(x, xmax); ymin = min16(y, ymin); ymax = max16(y, ymax);
+        xmin = max16(xmin-2, 0); xmax = min16(xmax+2, (int16_t)graph_get_XRes());
+        ymin = max16(ymin-2, 0); ymax = min16(ymax+2, (int16_t)graph_get_YRes());
     }
     const uint16_t bytes_pixel = 3/*graph_get_bytes_pixel()*/;
     for(int16_t u, v, y = ymin; y < ymax; ++y){
Index: proj/libs/graph/src/rectangle.c
===================================================================
--- proj/libs/graph/src/rectangle.c	(revision 322)
+++ proj/libs/graph/src/rectangle.c	(revision 323)
@@ -8,10 +8,10 @@
 struct rectangle{
     int16_t  x, y;
     uint16_t w, h;
+    uint32_t outline_color;
     uint32_t fill_color;
+    int16_t  outline_width;
     uint8_t  fill_alpha;
-    uint32_t outline_color;
-    int16_t  outline_width;
 };
 
 rectangle_t* (rectangle_ctor)(int16_t x, int16_t y, uint16_t w, uint16_t h){
@@ -51,14 +51,14 @@
 
 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);
+    for(int16_t x_ = max16(0,x); x_ < min16(x+l,(int16_t)graph_get_XRes()); ++x_){
+        graph_set_pixel((uint16_t)x_, (uint16_t)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);
+    for(int16_t y_ = max16(0,y); y_ < min16(y+l,(int16_t)graph_get_YRes()); ++y_){
+        graph_set_pixel((uint16_t)x, (uint16_t)y_, color);
     }
 }
 
@@ -65,8 +65,8 @@
 void (rectangle_draw)(const rectangle_t *p){
     /// fill
     if(p->fill_alpha > ALPHA_THRESHOLD)
-        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);
+        for(int16_t y = max16(p->y,0); y < min16(p->y+p->h, (int16_t)graph_get_YRes()); ++y)
+            rectangle_draw_hline(p->x, y, (int16_t)p->w, p->fill_color);
     /// border
     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;
Index: proj/libs/kbc/include/mouse.h
===================================================================
--- proj/libs/kbc/include/mouse.h	(revision 322)
+++ proj/libs/kbc/include/mouse.h	(revision 323)
@@ -14,11 +14,8 @@
 int (mouse_get_got_error_mouse_ih)(void);
 const uint8_t* (mouse_get_packet_mouse_ih)(void);
 int (mouse_get_counter_mouse_ih)(void);
+void (mouse_set_counter_mouse_ih)(int n);
 
-int got_error_mouse_ih;
-uint8_t packet_mouse_ih[3];
-int counter_mouse_ih;
-
 /**
  * @brief   Parse 3 bytes and returns it as a parsed, struct packet.
  * @param   packet_bytes    array of bytes to parse
@@ -61,7 +58,7 @@
  * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
  * @see {_ERRORS_H_::errors}
  */
-int (mouse_issue_cmd)(uint32_t cmd);
+int (mouse_issue_cmd)(uint8_t cmd);
 
 /**
  * @brief Reads byte from mouse
Index: proj/libs/kbc/src/kbc.c
===================================================================
--- proj/libs/kbc/src/kbc.c	(revision 322)
+++ proj/libs/kbc/src/kbc.c	(revision 323)
@@ -18,8 +18,8 @@
     if((ret = kbc_issue_arg(cmd))) return ret;
     return SUCCESS;
 }
-
-int (kbc_restore_kbd)(){
+/*
+static int (kbc_restore_kbd)(){
     int ret = 0;
     uint8_t cmd = 0;
     if((ret = kbc_read_cmd(&cmd))) return ret;
@@ -27,7 +27,7 @@
     if((ret = kbc_change_cmd(cmd))) return ret;
     return SUCCESS;
 }
-
+*/
 int (kbc_issue_cmd)(uint8_t cmd){
     int ret = 0;
     uint8_t stat;
Index: proj/libs/kbc/src/mouse.c
===================================================================
--- proj/libs/kbc/src/mouse.c	(revision 322)
+++ proj/libs/kbc/src/mouse.c	(revision 323)
@@ -19,23 +19,23 @@
 // Byte 2 - Y delta
 
 /* Mouse Commands */
-#define RESET           0xFF /* @brief Reset mouse */
-#define RESEND          0xFE /* @brief Resend command */
-#define DEFAULT         0xF6 /* @brief Set default values */
+//#define RESET           0xFF /* @brief Reset mouse */
+//#define RESEND          0xFE /* @brief Resend command */
+//#define DEFAULT         0xF6 /* @brief Set default values */
 #define DIS_DATA_REP    0xF5 /* @brief Disable Data Reporting */
 #define ENABLE_DATA_REP 0xF4 /* @brief Enable Data Reporting */
-#define SET_SAMPLE_RT   0xF3 /* @brief Sets state sampling rate */
-#define SET_REMOTE_MD   0xF0 /* @brief Sets Mouse on Remote Mode, data on request */
+//#define SET_SAMPLE_RT   0xF3 /* @brief Sets state sampling rate */
+//#define SET_REMOTE_MD   0xF0 /* @brief Sets Mouse on Remote Mode, data on request */
 #define READ_DATA       0xEB /* @brief Sends data packet request */
-#define SET_STREAM_MD   0xEA /* @brief Sets mouse on Stream Mode, data on events */
-#define STATUS_REQUEST  0xE9 /* @brief Get mouse configuration */
-#define SET_RESOLUTION  0xE8 /* @brief Sets resolution for mouse movement */
-#define SCALING_ACC_MD  0xE7 /* @brief Sets scaling on acceleration mode */
-#define SCALING_LIN_MD  0xE6 /* @brief Sets scaling on linear mode */
+//#define SET_STREAM_MD   0xEA /* @brief Sets mouse on Stream Mode, data on events */
+//#define STATUS_REQUEST  0xE9 /* @brief Get mouse configuration */
+//#define SET_RESOLUTION  0xE8 /* @brief Sets resolution for mouse movement */
+//#define SCALING_ACC_MD  0xE7 /* @brief Sets scaling on acceleration mode */
+//#define SCALING_LIN_MD  0xE6 /* @brief Sets scaling on linear mode */
 
 /* Mouse Controller Responses */
 #define ACK_OK      0xFA /* @brief Operation sucessful */
-#define ACK_INVALID 0xFE /* @brief Invalid Byte, first occurence */
+//#define ACK_INVALID 0xFE /* @brief Invalid Byte, first occurence */
 #define ACK_ERROR   0xFC /* @brief Invalid Byte on resend */
 
 int (subscribe_mouse_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
@@ -45,12 +45,13 @@
     return SUCCESS;
 }
 
-int got_error_mouse_ih = 0;
-uint8_t packet_mouse_ih[3];
-int counter_mouse_ih = 0;
+static int got_error_mouse_ih = 0;
+static uint8_t packet_mouse_ih[3];
+static int counter_mouse_ih = 0;
 int (mouse_get_got_error_mouse_ih)(void){return got_error_mouse_ih; }
 const uint8_t* (mouse_get_packet_mouse_ih)(void){return packet_mouse_ih; }
 int (mouse_get_counter_mouse_ih)(void){return counter_mouse_ih; }
+void (mouse_set_counter_mouse_ih)(int n){ counter_mouse_ih = n; }
 
 void (mouse_ih)(void) {
     uint8_t status = 0;
@@ -117,7 +118,7 @@
     return SUCCESS;
 }
 
-int (mouse_issue_cmd)(uint32_t cmd) {
+int (mouse_issue_cmd)(uint8_t cmd) {
     int ret;
     uint8_t ack = 0;
     for (unsigned int i = 0; i < KBC_NUM_TRIES; i++) {
Index: proj/libs/timer/include/timer.h
===================================================================
--- proj/libs/timer/include/timer.h	(revision 322)
+++ proj/libs/timer/include/timer.h	(revision 323)
@@ -9,6 +9,8 @@
 
 int (subscribe_timer_interrupt)(uint8_t interrupt_bit, int *interrupt_id);
 
+void (timer_int_handler)(void);
+
 uint32_t (timer_get_no_interrupts)(void);
 
 #endif //TIMER_H_INCLUDED
Index: proj/libs/timer/src/timer.c
===================================================================
--- proj/libs/timer/src/timer.c	(revision 322)
+++ proj/libs/timer/src/timer.c	(revision 323)
@@ -2,55 +2,55 @@
 
 #include "timer.h"
 
-#define TIMER_FREQ     1193182                                                          /**< @brief clock frequency for timer in PC and AT */
-#define TIMER_MIN_FREQ (TIMER_FREQ/UINT16_MAX) + ((TIMER_FREQ % UINT16_MAX) ? 1 : 0)    /**< @brief mininum frequency for timer */
+//#define TIMER_FREQ     1193182                                                          /**< @brief clock frequency for timer in PC and AT */
+//#define TIMER_MIN_FREQ (TIMER_FREQ/UINT16_MAX) + ((TIMER_FREQ % UINT16_MAX) ? 1 : 0)    /**< @brief mininum frequency for timer */
 
 /* I/O port addresses */
 
-#define TIMER_0    0x40         /**< @brief Timer 0 count register */
-#define TIMER_1    0x41         /**< @brief Timer 1 count register */
-#define TIMER_2    0x42         /**< @brief Timer 2 count register */
-#define TIMER_CTRL 0x43         /**< @brief Control register */
+//#define TIMER_0    0x40         /**< @brief Timer 0 count register */
+//#define TIMER_1    0x41         /**< @brief Timer 1 count register */
+//#define TIMER_2    0x42         /**< @brief Timer 2 count register */
+//#define TIMER_CTRL 0x43         /**< @brief Control register */
 
-#define SPEAKER_CTRL 0x61       /**< @brief Register for speaker control  */
+//#define SPEAKER_CTRL 0x61       /**< @brief Register for speaker control  */
 
 /* Timer control */
 
 /* Timer selection: bits 7 and 6 */
 
-#define TIMER_SEL0   0x00              /**< @brief Control Word for Timer 0 */
-#define TIMER_SEL1   BIT(6)            /**< @brief Control Word for Timer 1 */
-#define TIMER_SEL2   BIT(7)            /**< @brief Control Word for Timer 2 */
-#define TIMER_RB_CMD (BIT(7) | BIT(6)) /**< @brief Read Back Command */
+//#define TIMER_SEL0   0x00              /**< @brief Control Word for Timer 0 */
+//#define TIMER_SEL1   BIT(6)            /**< @brief Control Word for Timer 1 */
+//#define TIMER_SEL2   BIT(7)            /**< @brief Control Word for Timer 2 */
+//#define TIMER_RB_CMD (BIT(7) | BIT(6)) /**< @brief Read Back Command */
 
 /* Register selection: bits 5 and 4 */
 
-#define TIMER_LSB     BIT(4)                    /**< @brief Initialize Counter LSB only */
-#define TIMER_MSB     BIT(5)                    /**< @brief Initialize Counter MSB only */
-#define TIMER_LSB_MSB (TIMER_LSB | TIMER_MSB)   /**< @brief Initialize LSB first and MSB afterwards */
-#define TIMER_INMODE_MASK 0x30                  /**< @brief Mask for Timer Counter Mode */
-#define TIMER_INMODE_POS  4                     /**< @brief Bit position of Timer Counter Mode */
+//#define TIMER_LSB     BIT(4)                    /**< @brief Initialize Counter LSB only */
+//#define TIMER_MSB     BIT(5)                    /**< @brief Initialize Counter MSB only */
+//#define TIMER_LSB_MSB (TIMER_LSB | TIMER_MSB)   /**< @brief Initialize LSB first and MSB afterwards */
+//#define TIMER_INMODE_MASK 0x30                  /**< @brief Mask for Timer Counter Mode */
+//#define TIMER_INMODE_POS  4                     /**< @brief Bit position of Timer Counter Mode */
 
 /* Operating mode: bits 3, 2 and 1 */
 
-#define TIMER_SQR_WAVE (BIT(2) | BIT(1)) /**< @brief Mode 3: square wave generator */
-#define TIMER_RATE_GEN BIT(2)            /**< @brief Mode 2: rate generator */
-#define TIMER_MODE_MASK 0x0E             /**< @brief Mask for mode */
-#define TIMER_MODE_POS  1                /**< @brief Position of smallest bit from mode */
-#define TIMER_MODE_2ALT 0x6              /**< @brief Alternative notation for mode 2 */
-#define TIMER_MODE_3ALT 0x7              /**< @brief Alternative notation for mode 3 */
-#define TIMER_MODE_RED2 0x03             /**< @brief Reduce 3-bit mode to 2-bit mode */
+//#define TIMER_SQR_WAVE (BIT(2) | BIT(1)) /**< @brief Mode 3: square wave generator */
+//#define TIMER_RATE_GEN BIT(2)            /**< @brief Mode 2: rate generator */
+//#define TIMER_MODE_MASK 0x0E             /**< @brief Mask for mode */
+//#define TIMER_MODE_POS  1                /**< @brief Position of smallest bit from mode */
+//#define TIMER_MODE_2ALT 0x6              /**< @brief Alternative notation for mode 2 */
+//#define TIMER_MODE_3ALT 0x7              /**< @brief Alternative notation for mode 3 */
+//#define TIMER_MODE_RED2 0x03             /**< @brief Reduce 3-bit mode to 2-bit mode */
 
 /* Counting mode: bit 0 */
 
-#define TIMER_BCD 0x01 /**< @brief Count in BCD */
-#define TIMER_BIN 0x00 /**< @brief Count in binary */
+//#define TIMER_BCD 0x01 /**< @brief Count in BCD */
+//#define TIMER_BIN 0x00 /**< @brief Count in binary */
 
 /* READ-BACK COMMAND FORMAT */
 
-#define TIMER_RB_COUNT_  BIT(5)         /**< @brief Read counter value on read-back (0 to activate) */
-#define TIMER_RB_STATUS_ BIT(4)         /**< @brief Read status value on read-back (0 to activate) */
-#define TIMER_RB_SEL(n)  BIT((n) + 1)   /**< @brief Select timer to read information from */
+//#define TIMER_RB_COUNT_  BIT(5)         /**< @brief Read counter value on read-back (0 to activate) */
+//#define TIMER_RB_STATUS_ BIT(4)         /**< @brief Read status value on read-back (0 to activate) */
+//#define TIMER_RB_SEL(n)  BIT((n) + 1)   /**< @brief Select timer to read information from */
 
 int (subscribe_timer_interrupt)(uint8_t interrupt_bit, int *interrupt_id) {
     if (interrupt_id == NULL) return 1;
@@ -59,8 +59,10 @@
 }
 
 static uint32_t no_interrupts = 0;
-void (timer_int_handler)() {
+
+void (timer_int_handler)(void) {
     no_interrupts++;
 }
 
+
 uint32_t (timer_get_no_interrupts)(void){ return no_interrupts; }
Index: proj/libs/uart/include/uart.h
===================================================================
--- proj/libs/uart/include/uart.h	(revision 322)
+++ proj/libs/uart/include/uart.h	(revision 323)
@@ -57,7 +57,7 @@
 
 int nctp_send(size_t num, uint8_t* ptr[], size_t sz[]);
 
-int nctp_ih_err;
+int (nctp_get_ih_error)(void);
 void nctp_ih(void);
 
 #endif //UART_H_INCLUDED
Index: proj/libs/uart/src/uart.c
===================================================================
--- proj/libs/uart/src/uart.c	(revision 322)
+++ proj/libs/uart/src/uart.c	(revision 323)
@@ -365,7 +365,8 @@
     return SUCCESS;
 }
 
-int nctp_ih_err = SUCCESS;
+static int nctp_ih_err = SUCCESS;
+int (nctp_get_ih_error)(void){ return nctp_ih_err; }
 void nctp_ih(void){
     uint8_t iir;
     if((nctp_ih_err = uart_get_iir(COM1_ADDR, &iir))) return;
Index: proj/libs/utils/include/utils.h
===================================================================
--- proj/libs/utils/include/utils.h	(revision 322)
+++ proj/libs/utils/include/utils.h	(revision 323)
@@ -15,7 +15,7 @@
 /**
  * @brief Gets the most significant byte of a 16-bit variable
  * @param val 16-bit variable
- * @param lsb Pointer to a 8-bit variable to store the value of the MSB
+ * @param msb Pointer to a 8-bit variable to store the value of the MSB
  * @return ERROR_CODE code representing the result of the operation, SUCCESS code is returned if everything is OK
  */
 int(util_get_MSB)(uint16_t val, uint8_t *msb);
@@ -42,7 +42,10 @@
  * @param b     Second value
  * @return  The minimum of the two values
  */
-int32_t min(int32_t a, int32_t b);
+int16_t min16(int16_t a, int16_t b);
+uint16_t umin16(uint16_t a, uint16_t b);
+int32_t min32(int32_t a, int32_t b);
+double  dmin (double  a, double  b);
 
 /**
  * @brief Gets the maximum value out of two values.
@@ -50,26 +53,13 @@
  * @param b     Second value
  * @return  The maximum of the two values
  */
-int32_t max(int32_t a, int32_t b);
+int16_t max16(int16_t a, int16_t b);
+uint16_t umax16(uint16_t a, uint16_t b);
+int32_t max32(int32_t a, int32_t b);
+double  dmax (double  a, double  b);
 
-/**
- * @brief Gets the minimum value out of two doubles.
- * @param a     First value
- * @param b     Second value
- * @return  The minimum of the two values
- */
-double min_d(double a, double b);
+double dabs(double a);
 
-/**
- * @brief Gets the maximum value out of two doubles.
- * @param a     First value
- * @param b     Second value
- * @return  The maximum of the two values
- */
-double max_d(double a, double b);
+int deq(double a, double b);
 
-
-double abs_d(double a);
-
-
 #endif //UTILS_H_INCLUDED
Index: proj/libs/utils/include/xpm_utils.h
===================================================================
--- proj/libs/utils/include/xpm_utils.h	(revision 322)
+++ proj/libs/utils/include/xpm_utils.h	(revision 323)
@@ -1,7 +1,7 @@
 #ifndef XMP_UTILS_H_INCLUDED
 #define XMP_UTILS_H_INCLUDED
 
-void xpm_save_as_xpm2(const char **p, const char *s);
+void xpm_save_as_xpm2(const char* const* p, const char *s);
 
 char** xpm_load_xpm2(const char *s);
 
Index: proj/libs/utils/src/utils.c
===================================================================
--- proj/libs/utils/src/utils.c	(revision 322)
+++ proj/libs/utils/src/utils.c	(revision 323)
@@ -7,7 +7,7 @@
 
 int(util_get_LSB)(uint16_t val, uint8_t *lsb) {
     if (lsb == NULL) return NULL_PTR;
-    *lsb = val;
+    *lsb = (uint8_t)val;
     return SUCCESS;
 }
 
@@ -21,7 +21,7 @@
     if(value == NULL) return NULL_PTR;
     uint32_t n = 0;
     if(sys_inb(port, &n)) return READ_ERROR;
-    *value = n;
+    *value = (uint8_t)n;
     return SUCCESS;
 }
 
@@ -31,9 +31,16 @@
     return SUCCESS;
 }
 
-int32_t min(int32_t a, int32_t b){ return (b < a ? b : a); }
-int32_t max(int32_t a, int32_t b){ return (a < b ? b : a); }
+int16_t min16(int16_t a, int16_t b){ return (b < a ? b : a); }
+uint16_t umin16(uint16_t a, uint16_t b){ return (b < a ? b : a); }
+int32_t min32(int32_t a, int32_t b){ return (b < a ? b : a); }
+double  dmin (double  a, double  b){ return (b < a ? b : a); }
 
-double min_d(double a, double b){ return (b < a ? b : a); }
-double max_d(double a, double b){ return (a < b ? b : a); }
-double abs_d(double a)          { return (a < 0 ? -a: a); }
+int16_t max16(int16_t a, int16_t b){ return (a < b ? b : a); }
+uint16_t umax16(uint16_t a, uint16_t b){ return (a < b ? b : a); }
+int32_t max32(int32_t a, int32_t b){ return (a < b ? b : a); }
+double  dmax (double  a, double  b){ return (a < b ? b : a); }
+
+double dabs(double a)          { return (a < 0 ? -a: a); }
+
+int deq(double a, double b){ return (dabs(a-b) < 1e-10 ? true : false); }
Index: proj/libs/utils/src/xpm_utils.c
===================================================================
--- proj/libs/utils/src/xpm_utils.c	(revision 322)
+++ proj/libs/utils/src/xpm_utils.c	(revision 323)
@@ -8,7 +8,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-void xpm_save_as_xpm2(const char **p, const char *s){
+void xpm_save_as_xpm2(const char* const* p, const char *s){
     FILE *f = fopen(s, "w");
     int w, h, num_colors, chars_per_pixel;
     sscanf(p[0], "%d %d %d %d", &w, &h, &num_colors, &chars_per_pixel);
@@ -22,24 +22,24 @@
     FILE *f = fopen(fpath, "r");
     if(f == NULL) return NULL;
     size_t len = 1024; char *line_buf = malloc(len*sizeof(char));
-    int sz;
+    ssize_t sz;
 
     char **ret = NULL;
 
-    int w, h, num_colors, chars_per_pixel;
+    unsigned w, h, num_colors, chars_per_pixel;
 
     sz = getline(&line_buf, &len, f);{
         sscanf(line_buf, "%d %d %d %d", &w, &h, &num_colors, &chars_per_pixel);
         ret = malloc((1+num_colors+h)*sizeof(char*));
     }
-    ret[0] = malloc((sz+1)*sizeof(char)); if(ret[0] == NULL){ free(ret); return NULL; }
+    ret[0] = malloc(((unsigned)sz+1)*sizeof(char)); if(ret[0] == NULL){ free(ret); return NULL; }
     strcpy(ret[0], line_buf);
 
-    for(int i = 1; i < 1+num_colors+h; ++i){
+    for(size_t i = 1; i < 1+num_colors+h; ++i){
         sz = getline(&line_buf, &len, f);
-        ret[i] = malloc((sz+1)*sizeof(char));
+        ret[i] = malloc(((unsigned)sz+1)*sizeof(char));
         if(ret[i] == NULL){
-            for(int j = 0; j < i; ++j)
+            for(size_t j = 0; j < i; ++j)
                 free(ret[i]);
             free(ret);
             return NULL;
@@ -48,5 +48,6 @@
         ret[i][sz-1] = '\0';
     }
     fclose(f); f = NULL;
+    free(line_buf); line_buf = NULL;
     return ret;
 }
Index: proj/src/ent.c
===================================================================
--- proj/src/ent.c	(revision 322)
+++ proj/src/ent.c	(revision 323)
@@ -13,8 +13,8 @@
 #define GREEN_HEALTH_COLOR      0x009900
 
 static double scale = 1.0;
-static int16_t x_origin = 0;
-static int16_t y_origin = 0;
+static double x_origin = 0;
+static double y_origin = 0;
 
 void (ent_set_scale) (double n){ scale = n; }
 void (ent_set_origin)(double x, double y){ x_origin = x; y_origin = y; }
@@ -91,8 +91,8 @@
 double  (gunner_get_angle)          (const gunner_t *p){ return sprite_get_angle(p->dude); }
 double  (gunner_get_health)         (const gunner_t *p){ return p->health; }
 double  (gunner_get_curr_health)    (const gunner_t *p){ return p->current_health; }
-int16_t (gunner_get_x_screen)       (const gunner_t *p){ return (p->x-x_origin)*scale; }
-int16_t (gunner_get_y_screen)       (const gunner_t *p){ return (p->y-y_origin)*scale; }
+int16_t (gunner_get_x_screen)       (const gunner_t *p){ return (int16_t)((p->x-x_origin)*scale); }
+int16_t (gunner_get_y_screen)       (const gunner_t *p){ return (int16_t)((p->y-y_origin)*scale); }
 uint16_t (gunner_get_type)          (const gunner_t *p){ return p->type; }
 int     (gunner_get_team)           (const gunner_t *p){ return p->team; }
 void (gunner_draw)(gunner_t *p){
@@ -107,15 +107,15 @@
     gunner_draw_health(p);
 }
 void (gunner_draw_health)(const gunner_t *p) {
-    int16_t w = sprite_get_w(p->dude);
-    int16_t h = sprite_get_h(p->dude);
-    double x = gunner_get_x_screen(p) - w/2;
-    double y = gunner_get_y_screen(p) - h/2 - 10;
+    const uint16_t w = sprite_get_w(p->dude);
+    const uint16_t h = sprite_get_h(p->dude);
+    int16_t x = gunner_get_x_screen(p) - w/2;
+    int16_t y = gunner_get_y_screen(p) - h/2 - 10;
     double curr_health = gunner_get_curr_health(p);
     double health = gunner_get_health(p);
     double perc = curr_health/health;
-    rectangle_set_pos(p->green_bar, x, y); rectangle_set_size(p->green_bar, (int16_t)(w*perc), 10);
-    rectangle_set_pos(p->red_bar, x+(int16_t)(w*perc), y); rectangle_set_size(p->red_bar, (int16_t)(w*(1-perc)), 10);
+    rectangle_set_pos(p->green_bar, x, y); rectangle_set_size(p->green_bar, (uint16_t)(w*perc), 10);
+    rectangle_set_pos(p->red_bar, x+(int16_t)(w*perc), y); rectangle_set_size(p->red_bar, (uint16_t)(w*(1.0-perc)), 10);
     char buf[20]; sprintf(buf, "%d/%d", (int)p->current_health, (int)p->health);
     text_set_string(p->txt, buf);
     text_set_pos(p->txt, x+w/2, y+10/2);
@@ -165,8 +165,8 @@
 double  (bullet_get_y)       (const bullet_t *p){ return p->y; }
 double  (bullet_get_vx)      (const bullet_t *p){ return p->vx; }
 double  (bullet_get_vy)      (const bullet_t *p){ return p->vy; }
-int16_t (bullet_get_x_screen)(const bullet_t *p){ return (p->x-x_origin)*scale; }
-int16_t (bullet_get_y_screen)(const bullet_t *p){ return (p->y-y_origin)*scale; }
+int16_t (bullet_get_x_screen)(const bullet_t *p){ return (int16_t)((p->x-x_origin)*scale); }
+int16_t (bullet_get_y_screen)(const bullet_t *p){ return (int16_t)((p->y-y_origin)*scale); }
 double  (bullet_get_damage)  (const bullet_t *p){ return p->damage; }
 void    (bullet_set_damage)  (bullet_t *p, double damage) {
     if (damage < 0) damage = 0;
@@ -262,7 +262,7 @@
     ret->collide_gunner = malloc(W*H*sizeof(uint8_t));
     if(ret->collide_gunner == NULL){ map_dtor(ret); return NULL; }
     for(size_t i = 0; i < W*H; ++i){
-        int16_t x = i%W, y = i/W;
+        uint16_t x = i%W, y = (uint16_t)(i/W);
         ret->collide_gunner[i] = (map_collides_gunner_pos(ret, x, y, 36) ? 1 : 0);
     }
 
@@ -284,19 +284,20 @@
     free(p->visited);
     free(p);
 }
-int16_t (map_get_x_screen)(const map_t *p){ return (-x_origin)*scale; }
-int16_t (map_get_y_screen)(const map_t *p){ return (-y_origin)*scale; }
-int16_t (map_get_width)   (const map_t *p){ return sprite_get_w(p->background); }
-int16_t (map_get_height)  (const map_t *p){ return sprite_get_h(p->background); }
+static int16_t (map_get_x_screen)(const map_t *p){ return (int16_t)((-x_origin)*scale); }
+static int16_t (map_get_y_screen)(const map_t *p){ return (int16_t)((-y_origin)*scale); }
+uint16_t (map_get_width)   (const map_t *p){ return sprite_get_w(p->background); }
+uint16_t (map_get_height)  (const map_t *p){ return sprite_get_h(p->background); }
 int (map_collides_point)(const map_t *p, double x, double y){
     const uint16_t w = sprite_get_w(p->background), h = sprite_get_h(p->background);
-    int16_t x_ = x, y_ = y;
+    int16_t x_ = (int16_t)x, y_ = (int16_t)y;
     if(x_ < 0 || w <= x_ || y_ < 0 || h <= y_) return 0;
-    uint32_t pos = x_ + y_*w;
-    return p->collide[pos];
+    int32_t pos = x_ + y_*w;
+    if(0 <= pos && pos < w*h) return p->collide[pos];
+    else return false;
 }
 int (map_collides_gunner)(const map_t *p, const gunner_t *shooter) {
-    double radius = max(sprite_get_w(shooter->dude), sprite_get_h(shooter->dude))/2.0;
+    double radius = dmax(sprite_get_w(shooter->dude), sprite_get_h(shooter->dude))/2.0;
     return map_collides_gunner_pos(p, gunner_get_x(shooter), gunner_get_y(shooter), radius);
 }
 int (map_make_dijkstra)(map_t *p, double x_, double y_){
@@ -347,7 +348,7 @@
 }
 
 int (map_collides_bullet)(const map_t *p, const bullet_t *bull){
-    double radius = max(sprite_get_w(bull->b), sprite_get_h(bull->b))/2.0;
+    double radius = dmax(sprite_get_w(bull->b), sprite_get_h(bull->b))/2.0;
     double bullet_x = bullet_get_x(bull);
     double bullet_y = bullet_get_y(bull);
     for (double x = -radius; x < radius; x += 1){
@@ -361,11 +362,11 @@
 int (gunner_collides_bullet)(const gunner_t *shooter, const bullet_t *bull){
     if(bull->shooter == shooter) return false;
 
-    double shooter_radius = max(sprite_get_w(shooter->dude), sprite_get_h(shooter->dude))/2.0;
+    double shooter_radius = dmax(sprite_get_w(shooter->dude), sprite_get_h(shooter->dude))/2.0;
     double shooter_x = gunner_get_x(shooter);
     double shooter_y = gunner_get_y(shooter);
 
-    double bullet_radius = max(sprite_get_w(bull->b), sprite_get_h(bull->b))/2.0;
+    double bullet_radius = dmax(sprite_get_w(bull->b), sprite_get_h(bull->b))/2.0;
     double bullet_x = bullet_get_x(bull);
     double bullet_y = bullet_get_y(bull);
 
@@ -389,8 +390,8 @@
 
 int (gunner_collides_gunner)(const gunner_t *shooter1, const gunner_t *shooter2) {
     if (shooter1 == shooter2) return false;
-    double shooter1_radius = max(sprite_get_w(shooter1->dude), sprite_get_h(shooter1->dude))/2.0;
-    double shooter2_radius = max(sprite_get_w(shooter2->dude), sprite_get_h(shooter2->dude))/2.0;
+    double shooter1_radius = dmax(sprite_get_w(shooter1->dude), sprite_get_h(shooter1->dude))/2.0;
+    double shooter2_radius = dmax(sprite_get_w(shooter2->dude), sprite_get_h(shooter2->dude))/2.0;
     double distance = distance_gunners(shooter1, shooter2);
     return distance <= shooter1_radius+shooter2_radius;
 }
Index: proj/src/interrupts_func.c
===================================================================
--- proj/src/interrupts_func.c	(revision 322)
+++ proj/src/interrupts_func.c	(revision 323)
@@ -191,15 +191,7 @@
     (*ih[handler])();
 }
 
-void (timer_manager)() {
-
-}
-
-void (mouse_manager)() {
-
-}
-
-int get_interrupts_vector(uint32_t *p){
+int get_interrupts_vector(uint64_t *p){
     int r;
 
     *p = 0;
Index: proj/src/proj.c
===================================================================
--- proj/src/proj.c	(revision 322)
+++ proj/src/proj.c	(revision 323)
@@ -38,9 +38,9 @@
 
     lcf_set_language("EN-US");
 
-    //lcf_trace_calls("/home/lcom/labs/proj/trace.txt");
+    lcf_trace_calls("/home/lcom/labs/proj/trace.txt");
 
-    //lcf_log_output("/home/lcom/labs/proj/output.txt");
+    lcf_log_output("/home/lcom/labs/proj/output.txt");
 
     if (lcf_start(argc, argv)) return 1;
 
@@ -113,7 +113,7 @@
 
     /// loop stuff
     int click = 0;
-    uint32_t int_vector = 0;
+    uint64_t int_vector = 0;
     int good = true;
     while (good) {
         /* Get a request message. */
@@ -145,12 +145,12 @@
                     case KBC_IRQ:
                     if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) good = false;
                     case MOUSE_IRQ:
-                    if (counter_mouse_ih >= 3) {
-                        mouse_parse_packet(packet_mouse_ih, &pp);
+                    if (mouse_get_counter_mouse_ih() >= 3) {
+                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
                         update_mouse(&pp);
                         if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed;
                         last_lb = keys->lb_pressed;
-                        counter_mouse_ih = 0;
+                        mouse_set_counter_mouse_ih(0);
                     }
                     break;
                     case COM1_IRQ: nctp_ih(); break;
@@ -224,7 +224,7 @@
 
     /// loop stuff
     int click = 0;
-    uint32_t int_vector = 0;
+    uint64_t int_vector = 0;
     int good = true;
     while (good) {
         /* Get a request message. */
@@ -255,12 +255,12 @@
                     case KBC_IRQ:
                     if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) good = false;
                     case MOUSE_IRQ:
-                    if (counter_mouse_ih >= 3) {
-                        mouse_parse_packet(packet_mouse_ih, &pp);
+                    if (mouse_get_counter_mouse_ih() >= 3) {
+                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
                         update_mouse(&pp);
                         if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed;
                         last_lb = keys->lb_pressed;
-                        counter_mouse_ih = 0;
+                        mouse_set_counter_mouse_ih(0);
                     }
                     break;
                     case COM1_IRQ: nctp_ih(); break;
@@ -310,7 +310,7 @@
     struct packet pp;
     keys_t *keys = get_key_presses();
     /// loop stuff
-    uint32_t int_vector = 0;
+    uint64_t int_vector = 0;
     int good = true;
     int state = 0; // -1 for remote win, 0 for draw, 1 for host win
     list_node_t *p1, *p2; // player states
@@ -369,13 +369,13 @@
                     }
                     break;
                     case MOUSE_IRQ:
-                    if (counter_mouse_ih >= 3) {
-                        mouse_parse_packet(packet_mouse_ih, &pp);
+                    if (mouse_get_counter_mouse_ih() >= 3) {
+                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
                         update_mouse(&pp);
                         if (last_lb ^ keys->lb_pressed && keys->lb_pressed)
                         shoot_bullet(shooter1, bullet_list, bsp_bullet);
                         last_lb = keys->lb_pressed;
-                        counter_mouse_ih = 0;
+                        mouse_set_counter_mouse_ih(0);
                     }
                     break;
 
@@ -446,7 +446,7 @@
     keys_t *keys = get_key_presses();
 
     /// loop stuff
-    uint32_t int_vector = 0;
+    uint64_t int_vector = 0;
     int good = true;
     while (good) {
         if ((r = get_interrupts_vector(&int_vector))) return r;
@@ -510,8 +510,8 @@
                     }
                     break;
                     case MOUSE_IRQ:
-                    if (counter_mouse_ih >= 3) {
-                        mouse_parse_packet(packet_mouse_ih, &pp);
+                    if (mouse_get_counter_mouse_ih() >= 3) {
+                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
                         update_mouse(&pp);
                         if (last_lb ^ keys->lb_pressed && keys->lb_pressed) {
                             bullet_info->new_bullet = true;
@@ -518,7 +518,7 @@
                             hltp_send_bullet_info(bullet_info);
                         }
                         last_lb = keys->lb_pressed;
-                        counter_mouse_ih = 0;
+                        mouse_set_counter_mouse_ih(0);
                     }
                     break;
 
@@ -567,7 +567,7 @@
 
     /// loop stuff
     int click = 0;
-    uint32_t int_vector = 0;
+    uint64_t int_vector = 0;
     int good = true;
     while (good) {
         /* Get a request message. */
@@ -598,12 +598,12 @@
                     case KBC_IRQ:
                     if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) good = false;
                     case MOUSE_IRQ:
-                    if (counter_mouse_ih >= 3) {
-                        mouse_parse_packet(packet_mouse_ih, &pp);
+                    if (mouse_get_counter_mouse_ih() >= 3) {
+                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
                         update_mouse(&pp);
                         if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed;
                         last_lb = keys->lb_pressed;
-                        counter_mouse_ih = 0;
+                        mouse_set_counter_mouse_ih(0);
                     }
                     break;
                     case COM1_IRQ: nctp_ih(); break;
@@ -646,7 +646,7 @@
     keys_t *keys = get_key_presses();
 
     /// loop stuff
-    uint32_t int_vector = 0;
+    uint64_t int_vector = 0;
     int good = true;
     while (good) {
         /* Get a request message. */
@@ -689,13 +689,13 @@
                     }
                     break;
                     case MOUSE_IRQ:
-                    if (counter_mouse_ih >= 3) {
-                        mouse_parse_packet(packet_mouse_ih, &pp);
+                    if (mouse_get_counter_mouse_ih() >= 3) {
+                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
                         update_mouse(&pp);
                         if (last_lb ^ keys->lb_pressed && keys->lb_pressed)
                         shoot_bullet(shooter1, bullet_list, bsp_bullet);
                         last_lb = keys->lb_pressed;
-                        counter_mouse_ih = 0;
+                        mouse_set_counter_mouse_ih(0);
 
                     }
                     break;
@@ -750,7 +750,7 @@
     keys_t *keys = get_key_presses();
 
     /// loop stuff
-    uint32_t int_vector = 0;
+    uint64_t int_vector = 0;
     int good = true;
     int dead = false;
 
@@ -816,13 +816,13 @@
                     }
                     break;
                     case MOUSE_IRQ:
-                    if (counter_mouse_ih >= 3) {
-                        mouse_parse_packet(packet_mouse_ih, &pp);
+                    if (mouse_get_counter_mouse_ih() >= 3) {
+                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
                         update_mouse(&pp);
                         if (last_lb ^ keys->lb_pressed && keys->lb_pressed)
                         shoot_bullet(shooter1, bullet_list, bsp_bullet);
                         last_lb = keys->lb_pressed;
-                        counter_mouse_ih = 0;
+                        mouse_set_counter_mouse_ih(0);
 
                     }
                     break;
@@ -944,7 +944,7 @@
 }
 
 /// loop stuff
-uint32_t int_vector = 0;
+uint64_t int_vector = 0;
 int good = true;
 while (good) {
     /* Get a request message. */
@@ -999,10 +999,10 @@
                 sprintf(buffer2, "%d/%d", strlen(buffer), CHAT_MAX_SIZE);
                 text_set_string(t_size, buffer2);
                 case MOUSE_IRQ:
-                if (counter_mouse_ih >= 3) {
-                    mouse_parse_packet(packet_mouse_ih, &pp);
+                if (mouse_get_counter_mouse_ih() >= 3) {
+                    mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
                     update_mouse(&pp);
-                    counter_mouse_ih = 0;
+                    mouse_set_counter_mouse_ih(0);
                 }
                 break;
                 case COM1_IRQ: nctp_ih(); break;
Index: proj/src/proj_func.c
===================================================================
--- proj/src/proj_func.c	(revision 322)
+++ proj/src/proj_func.c	(revision 323)
@@ -297,11 +297,11 @@
 static int16_t mouse_x = 0, mouse_y = 0;
 
 void (update_mouse)(struct packet *p) {
-    mouse_x = max(0, mouse_x + p->delta_x);
-    mouse_x = min(mouse_x, graph_get_XRes() - 1);
+    mouse_x = max16(0, mouse_x + p->delta_x);
+    mouse_x = min16(mouse_x, graph_get_XRes() - 1);
 
-    mouse_y = max(0, mouse_y - p->delta_y);
-    mouse_y = min(mouse_y, graph_get_YRes() - 1);
+    mouse_y = max16(0, mouse_y - p->delta_y);
+    mouse_y = min16(mouse_y, graph_get_YRes() - 1);
 
     key_presses.lb_pressed = p->lb;
 }
Index: proj/Makefile
===================================================================
--- proj/Makefile	(revision 322)
+++ proj/Makefile	(revision 323)
@@ -9,10 +9,10 @@
 .PATH: ${.CURDIR}/libs/classes/src
 .PATH: ${.CURDIR}/libs/utils/src
 
-SRCS= proj.c list.c queue.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c proj_func.c fast_math.c rectangle.c font.c xpm_utils.c ent.c rtc.c uart.c hltp.c makecode_map.c menu.c
+SRCS= list.c queue.c graph.c kbc.c keyboard.c mouse.c utils.c timer.c interrupts_func.c fast_math.c xpm_utils.c ent.c rtc.c uart.c hltp.c makecode_map.c menu.c proj.c proj_func.c rectangle.c font.c
 IPATHS=-I./include -I./libs/graph/include -I./libs/kbc/include -I./libs/rtc/include -I./libs/timer/include -I./libs/uart/include -I./libs/classes/include -I./libs/utils/include -I./maps -I./media/xpm
 
-CPPFLAGS += -pedantic -Weverything ${IPATHS} -D LCOM_MACRO -D __LCOM_OPTIMIZED__
+CPPFLAGS += -pedantic ${IPATHS} -D LCOM_MACRO -D __LCOM_OPTIMIZED__ #-Weverything
 
 
 DPADD += ${LIBLCF}
