Index: proj/include/font.h
===================================================================
--- proj/include/font.h	(revision 249)
+++ proj/include/font.h	(revision 250)
@@ -22,6 +22,7 @@
 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);
Index: proj/include/mouse.h
===================================================================
--- proj/include/mouse.h	(revision 249)
+++ proj/include/mouse.h	(revision 250)
@@ -18,9 +18,9 @@
 /**
  * @brief   Parse 3 bytes and returns it as a parsed, struct packet.
  * @param   packet_bytes    array of bytes to parse
- * @return  parsed struct packet
+ * @param   pp              Pointer to packet to store the information.
  */
-struct packet (mouse_parse_packet)(const uint8_t *packet_bytes);
+void (mouse_parse_packet)(const uint8_t *packet_bytes, struct packet *pp);
 
 /**
  * @brief Polls mouse for data. Blocks execution until a valid mouse packet is obtained.
Index: proj/include/proj_func.h
===================================================================
--- proj/include/proj_func.h	(revision 249)
+++ proj/include/proj_func.h	(revision 250)
@@ -2,6 +2,7 @@
 #define PROJ_FUNC_H_INCLUDED
 
 #include "ent.h"
+#include "font.h"
 
 #include <stdint.h>
 
@@ -42,9 +43,9 @@
 
 void update_scale(void);
 
-int32_t get_mouse_X(void);
+int32_t* get_mouse_X(void);
 
-int32_t get_mouse_Y(void);
+int32_t* get_mouse_Y(void);
 
 /**
  * @brief
@@ -55,4 +56,16 @@
  */
 double get_mouse_angle(gunner_t *p);
 
+typedef struct timer {
+    int time;
+    text_t *text;
+    char *array;
+} text_timer_t;
+
+text_timer_t* (timer_ctor)(const font_t *fnt);
+
+void (timer_update)(text_timer_t *p);
+
+void (timer_dtor)(text_timer_t *p);
+
 #endif /* end of include guard: PROJ_FUNC_H_INCLUDED */
Index: proj/include/utils.h
===================================================================
--- proj/include/utils.h	(revision 249)
+++ proj/include/utils.h	(revision 250)
@@ -69,4 +69,7 @@
 double max_d(double a, double b);
 
 
+double abs_d(double a);
+
+
 #endif //UTILS_H_INCLUDED
Index: proj/src/ent.c
===================================================================
--- proj/src/ent.c	(revision 249)
+++ proj/src/ent.c	(revision 250)
@@ -145,7 +145,6 @@
 }
 
 void (bullet_update_movement_list)(list_t *bullet_list){
-    if (bullet_list == NULL) return;
     if (list_size(bullet_list) == 0) return;
 
     list_node_t *it = list_begin(bullet_list);
Index: proj/src/fast_math.c
===================================================================
--- proj/src/fast_math.c	(revision 249)
+++ proj/src/fast_math.c	(revision 250)
@@ -1,6 +1,7 @@
 #include <lcom/lcf.h>
 
 #include "fast_math.h"
+#include "utils.h"
 
 #include <math.h>
 
Index: proj/src/font.c
===================================================================
--- proj/src/font.c	(revision 249)
+++ proj/src/font.c	(revision 250)
@@ -128,6 +128,7 @@
     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  ; }
Index: proj/src/graph.c
===================================================================
--- proj/src/graph.c	(revision 249)
+++ proj/src/graph.c	(revision 250)
@@ -245,12 +245,13 @@
 
 /// PIXEL DRAWING
 int (graph_set_pixel)(uint16_t x, uint16_t y, uint32_t color) {
-    if (x < 0 || vbe_mem_info.XResolution <= x || y < 0 || vbe_mem_info.YResolution <= y) {
+    //pixels are certain to be inside can reduce lag
+    /*if (x < 0 || vbe_mem_info.XResolution <= x || y < 0 || vbe_mem_info.YResolution <= y) {
         //printf("%s: invalid pixel.\n", __func__);
         return OUT_OF_RANGE;
-    }
-    unsigned int pos = (x + y * vbe_mem_info.XResolution) * graph_get_bytes_pixel();
-    memcpy(video_buf + pos, &color, graph_get_bytes_pixel());
+    }*/
+    unsigned int pos = (x + y * vbe_mem_info.XResolution) * 3/*graph_get_bytes_pixel()*/;
+    memcpy(video_buf + pos, &color, 3/*graph_get_bytes_pixel()*/);
     return SUCCESS;
 }
 void (graph_set_pixel_pos)(unsigned pos, uint32_t color){
@@ -399,7 +400,7 @@
         ymin = max(ymin-(int16_t)p->scale-2, 0); ymax = min(ymax+(int16_t)p->scale+2, graph_get_YRes());
     }
     const uint8_t *map = basic_sprite_get_map(p->bsp);
-    const uint16_t bytes_pixel = graph_get_bytes_pixel();
+    const uint16_t bytes_pixel = 3/*graph_get_bytes_pixel()*/;
     for(int16_t u, v, y = ymin; y < ymax; ++y){
         uint8_t *place = video_buf + (xmin + y*graph_get_XRes())*bytes_pixel;
         for(int16_t x = xmin; x < xmax; ++x, place += bytes_pixel){
Index: proj/src/interrupts_func.c
===================================================================
--- proj/src/interrupts_func.c	(revision 249)
+++ proj/src/interrupts_func.c	(revision 250)
@@ -145,8 +145,16 @@
     return r;
 }
 
-void interrupt_handler(uint8_t handler) {
+void (interrupt_handler)(uint8_t handler) {
     if (handler >= 32)              return;
     if ((*ih[handler]) == NULL)     return;
     (*ih[handler])();
 }
+
+void (timer_manager)() {
+
+}
+
+void (mouse_manager)() {
+
+}
Index: proj/src/mouse.c
===================================================================
--- proj/src/mouse.c	(revision 249)
+++ proj/src/mouse.c	(revision 250)
@@ -43,19 +43,17 @@
     }
 }
 
-struct packet (mouse_parse_packet)(const uint8_t *packet_bytes){
-    struct packet pp;
-    pp.bytes[0] = packet_bytes[0];
-    pp.bytes[1] = packet_bytes[1];
-    pp.bytes[2] = packet_bytes[2];
-    pp.rb       = pp.bytes[0] & RIGHT_BUTTON;
-    pp.mb       = pp.bytes[0] & MIDDLE_BUTTON;
-    pp.lb       = pp.bytes[0] & LEFT_BUTTON;
-    pp.delta_x  = sign_extend_byte((packet_bytes[0] & MSB_X_DELTA) != 0, pp.bytes[1]);
-    pp.delta_y  = sign_extend_byte((packet_bytes[0] & MSB_Y_DELTA) != 0, pp.bytes[2]);
-    pp.x_ov     = pp.bytes[0] & X_OVERFLOW;
-    pp.y_ov     = pp.bytes[0] & Y_OVERFLOW;
-    return pp;
+void (mouse_parse_packet)(const uint8_t *packet_bytes, struct packet *pp){
+    pp->bytes[0] = packet_bytes[0];
+    pp->bytes[1] = packet_bytes[1];
+    pp->bytes[2] = packet_bytes[2];
+    pp->rb       = pp->bytes[0] & RIGHT_BUTTON;
+    pp->mb       = pp->bytes[0] & MIDDLE_BUTTON;
+    pp->lb       = pp->bytes[0] & LEFT_BUTTON;
+    pp->delta_x  = sign_extend_byte((packet_bytes[0] & MSB_X_DELTA) != 0, pp->bytes[1]);
+    pp->delta_y  = sign_extend_byte((packet_bytes[0] & MSB_Y_DELTA) != 0, pp->bytes[2]);
+    pp->x_ov     = pp->bytes[0] & X_OVERFLOW;
+    pp->y_ov     = pp->bytes[0] & Y_OVERFLOW;
 }
 
 int mouse_poll(struct packet *pp, uint16_t period){
@@ -68,7 +66,7 @@
         if((ret = mouse_poll_byte(&byte, period))) return ret;
         packet[i] = byte;
     }
-    *pp = mouse_parse_packet(packet);
+    mouse_parse_packet(packet, pp);
     return SUCCESS;
 }
 
Index: proj/src/proj.c
===================================================================
--- proj/src/proj.c	(revision 249)
+++ proj/src/proj.c	(revision 250)
@@ -171,6 +171,8 @@
     #ifndef DIOGO
         ent_set_scale(DEFAULT_SCALE);
 
+        text_timer_t *in_game_timer = timer_ctor(consolas);
+
         list_t *shooter_list = list_ctor();
 
         gunner_t *shooter1 = gunner_ctor(bsp_shooter, bsp_pistol); if(shooter1 == NULL) printf("Failed to get shooter1\n");
@@ -184,16 +186,17 @@
         list_insert(shooter_list, list_end(shooter_list), shooter1);
         list_insert(shooter_list, list_end(shooter_list), shooter2);
 
-        //bullet_t *bullet = bullet_ctor(get_bullet(), 400.0, 400.0, 2.0, -1.0);
-
         list_t *bullet_list  = list_ctor();
 
         ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
                        gunner_get_y(shooter1)-ent_get_YLength()/2.0);
 
-        uint32_t refresh_count_value = sys_hz() / REFRESH_RATE;
-
+        //uint32_t refresh_count_value = sys_hz() / REFRESH_RATE;
+        double angle; // mouse angle
+        int32_t *mouse_x = get_mouse_X(), *mouse_y = get_mouse_Y();
         uint8_t last_lb = 0;
+        struct packet pp;
+        keys_t *keys = get_key_presses();
 
         /// loop stuff
         int ipc_status;
@@ -214,14 +217,15 @@
                                 interrupt_handler(i);
                                 if ((scancode[0]) == ESC_BREAK_CODE) good = 0;
                                 if (i == 0) {
-                                    if (no_interrupts % refresh_count_value == 0) {
-                                            update_movement(map1, shooter1, get_key_presses(), shooter_list);
+                                    if (no_interrupts % 60 == 0) timer_update(in_game_timer);
+                                    //if (no_interrupts % refresh_count_value == 0) {
+                                            update_movement(map1, shooter1, keys, shooter_list);
 
                                             update_game_state(map1, shooter_list, bullet_list);
 
-                                            update_scale();
-                                            sprite_set_pos(sp_crosshair, get_mouse_X(), get_mouse_Y());
-                                            double angle = get_mouse_angle(shooter1);
+                                            //update_scale();
+                                            sprite_set_pos(sp_crosshair, *mouse_x, *mouse_y);
+                                            angle = get_mouse_angle(shooter1);
                                             gunner_set_angle(shooter1, angle - M_PI_2);
                                             graph_clear_screen();
 
@@ -232,20 +236,22 @@
                                             gunner_draw_list(shooter_list);
                                             bullet_draw_list(bullet_list);
 
+                                            text_draw(in_game_timer->text);
                                             sprite_draw(sp_crosshair);
                                             graph_draw();
-                                        }
+                                        //}
                                     }
-                                    if (i == 12) {
+                                    else if (i == 12) {
                                         if (counter_mouse_ih >= 3) {
-                                            struct packet pp = mouse_parse_packet(packet_mouse_ih);
+                                            mouse_parse_packet(packet_mouse_ih, &pp);
                                             update_mouse(&pp);
-                                            //printf("X: %d Y: %d\n", get_mouse_X(), get_mouse_Y());
-                                            counter_mouse_ih = 0;
-                                            if (last_lb ^ get_key_presses()->lb_pressed && get_key_presses()->lb_pressed) {
+
+                                            if (last_lb ^ keys->lb_pressed && keys->lb_pressed) {
                                                 shoot_bullet(shooter1, bullet_list, bsp_bullet);
                                             }
-                                            last_lb = get_key_presses()->lb_pressed;
+                                            last_lb = keys->lb_pressed;
+                                            counter_mouse_ih = 0;
+
                                         }
                                     }
                                 }
@@ -272,6 +278,8 @@
         if(list_dtor(shooter_list)) printf("COULD NOT DESTRUCT SHOOTER LIST\n");
         if(list_dtor(bullet_list)) printf("COULD NOT DESTRUCT BULLET LIST\n");
 
+        timer_dtor(in_game_timer); in_game_timer = NULL;
+
         basic_sprite_dtor      (bsp_crosshair); bsp_crosshair = NULL;
         basic_sprite_dtor      (bsp_shooter  ); bsp_shooter   = NULL;
         sprite_dtor            (sp_crosshair ); sp_crosshair  = NULL;
Index: proj/src/proj_func.c
===================================================================
--- proj/src/proj_func.c	(revision 249)
+++ proj/src/proj_func.c	(revision 250)
@@ -40,10 +40,10 @@
         case D_BREAK_CODE       : key_presses.d_pressed     = 0;        break;
         case CTRL_MAKE_CODE     : key_presses.ctrl_pressed  = 1;        break;
         case CTRL_BREAK_CODE    : key_presses.ctrl_pressed  = 0;        break;
-        case PLUS_MAKE_CODE     : key_presses.plus_pressed  = 1;        break;
-        case PLUS_BREAK_CODE    : key_presses.plus_pressed  = 0;        break;
-        case MINUS_MAKE_CODE    : key_presses.minus_pressed = 1;        break;
-        case MINUS_BREAK_CODE   : key_presses.minus_pressed = 0;        break;
+        case PLUS_MAKE_CODE     : key_presses.plus_pressed  = 1;    update_scale();        break;
+        case PLUS_BREAK_CODE    : key_presses.plus_pressed  = 0;    update_scale();        break;
+        case MINUS_MAKE_CODE    : key_presses.minus_pressed = 1;    update_scale();        break;
+        case MINUS_BREAK_CODE   : key_presses.minus_pressed = 0;    update_scale();        break;
         }
     }
 }
@@ -181,10 +181,35 @@
     return &key_presses;
 }
 
-int32_t get_mouse_X(void) { return mouse_x; }
+int32_t* get_mouse_X(void) { return &mouse_x; }
 
-int32_t get_mouse_Y(void) { return mouse_y; }
+int32_t* get_mouse_Y(void) { return &mouse_y; }
 
 double get_mouse_angle(gunner_t *p) {
     return atan2(gunner_get_y_screen(p) - mouse_y, mouse_x - gunner_get_x_screen(p));
 }
+
+text_timer_t* (timer_ctor)(const font_t *fnt){
+    if(fnt == NULL) return NULL;
+    text_timer_t *ret = malloc(sizeof(timer_t));
+    if (ret == NULL) return NULL;
+    ret->time = 0;
+    ret->text = text_ctor(fnt, "000s");
+    ret->array = text_get_string(ret->text);
+    text_set_color(ret->text, 0x888888);
+    return ret;
+}
+
+void (timer_update)(text_timer_t *p){
+    if (p->time >= 999) return;
+    p->time++;
+    p->array[2] = p->time % 10 + '0';
+    p->array[1] = (p->time/10) % 10 + '0';
+    p->array[0] = (p->time/100) % 10 + '0';
+}
+
+void (timer_dtor)(text_timer_t *p){
+    if (p == NULL) return;
+    text_dtor(p->text);
+    free(p);
+}
Index: proj/src/utils.c
===================================================================
--- proj/src/utils.c	(revision 249)
+++ proj/src/utils.c	(revision 250)
@@ -36,3 +36,4 @@
 
 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); }
