Index: proj.c
===================================================================
--- proj.c	(revision 344)
+++ proj.c	(revision 345)
@@ -6,10 +6,6 @@
 #include "proj_macros.h"
 #include "proj_func.h"
 
-#include "kbc.h"
-#include "timer.h"
-#include "keyboard.h"
-#include "mouse.h"
 #include "graph.h"
 #include "menu.h"
 #include "rtc.h"
@@ -18,10 +14,9 @@
 #include "makecode_map.h"
 
 #include "graph.h"
-#include "sprite.h"
+
 #include "rectangle.h"
 #include "font.h"
-#include "ent.h"
 
 #include "crosshair.h"
 #include "shooter.h"
@@ -35,6 +30,8 @@
 
 #include "list.h"
 
+#include "proj.h"
+
 int main(int argc, char* argv[]) {
 
     lcf_set_language("EN-US");
@@ -50,15 +47,8 @@
     return 0;
 }
 
-static basic_sprite_t       *bsp_crosshair = NULL;
-static basic_sprite_t       *bsp_shooter   = NULL;
-static basic_sprite_t       *bsp_zombie    = NULL;
-static basic_sprite_t       *bsp_pistol    = NULL;
-static basic_sprite_t       *bsp_nothing   = NULL;
-static basic_sprite_t       *bsp_bullet    = NULL;
-static map_t                *map1          = NULL;
-static sprite_t             *sp_crosshair  = NULL;
 
+
 static int (singleplayer)(void);
 static int (multiplayer)(void);
 static int (chat)(void);
@@ -278,7 +268,7 @@
     nctp_set_processor(multiplayer_process);
 
     ent_set_scale(DEFAULT_SCALE);
-    text_timer_t *in_game_timer = timer_ctor(font_get_default());
+    text_timer_t *in_game_timer = text_timer_ctor(font_get_default());
 
     list_t *shooter_list = list_ctor();
 
@@ -323,7 +313,7 @@
                 interrupt_handler(i);
                 switch (i) {
                     case TIMER0_IRQ:
-                    if (timer_get_no_interrupts() % 60 == 0) timer_update(in_game_timer);
+                    if (timer_get_no_interrupts() % 60 == 0) text_timer_update(in_game_timer);
                     update_movement(map1, shooter1, keys, shooter_list);
                     update_movement(map1, shooter2, &(remote_info->remote_keys_pressed), shooter_list);
 
@@ -409,7 +399,7 @@
 
     nctp_set_processor(NULL);
 
-    timer_dtor(in_game_timer); in_game_timer = NULL;
+    text_timer_dtor(in_game_timer); in_game_timer = NULL;
 
     return 0;
 }
@@ -420,7 +410,7 @@
     nctp_set_processor(multiplayer_process);
 
     ent_set_scale(DEFAULT_SCALE);
-    text_timer_t *in_game_timer = timer_ctor(font_get_default());
+    text_timer_t *in_game_timer = text_timer_ctor(font_get_default());
 
     list_t *shooter_list = list_ctor();
 
@@ -458,7 +448,7 @@
                 interrupt_handler(i);
                 switch (i) {
                     case TIMER0_IRQ:
-                    if (timer_get_no_interrupts() % 60 == 0) timer_update(in_game_timer);
+                    if (timer_get_no_interrupts() % 60 == 0) text_timer_update(in_game_timer);
 
                     double angle = get_mouse_angle(shooter1) - M_PI_2;
 
@@ -552,13 +542,13 @@
 
     nctp_set_processor(NULL);
 
-    timer_dtor(in_game_timer); in_game_timer = NULL;
+    text_timer_dtor(in_game_timer); in_game_timer = NULL;
 
     return 0;
 }
 
 static int (campaign)(void);
-static int (zombies)(void);
+#include "zombies.h"
 static int (singleplayer)(void) {
 
     int r;
@@ -628,7 +618,7 @@
     int r;
 
     ent_set_scale(DEFAULT_SCALE);
-    text_timer_t *in_game_timer = timer_ctor(font_get_default());
+    text_timer_t *in_game_timer = text_timer_ctor(font_get_default());
 
     list_t *shooter_list = list_ctor();
 
@@ -667,7 +657,7 @@
                 switch (i) {
                     case TIMER0_IRQ:
 
-                    if (timer_get_no_interrupts() % 60 == 0) timer_update(in_game_timer);
+                    if (timer_get_no_interrupts() % 60 == 0) text_timer_update(in_game_timer);
                     update_movement(map1, shooter1, keys, shooter_list);
 
                     update_game_state(map1, shooter_list, bullet_list);
@@ -725,142 +715,13 @@
     }
     if(list_dtor(bullet_list)) printf("COULD NOT DESTRUCT BULLET LIST\n");
 
-    timer_dtor(in_game_timer); in_game_timer = NULL;
+    text_timer_dtor(in_game_timer); in_game_timer = NULL;
 
     return SUCCESS;
 }
 
-#define ZOMBIES_NUM             5
-#define ZOMBIE_HEALTH_FACTOR    1.1
-static int (zombies)(void){
 
-    int r;
 
-    ent_set_scale(DEFAULT_SCALE);
-    text_timer_t *in_game_timer = timer_ctor(font_get_default());
-
-    list_t *shooter_list = list_ctor();
-
-    gunner_t *shooter1 = gunner_ctor(bsp_shooter, bsp_pistol, GUNNER_PLAYER, 1); if(shooter1 == NULL) printf("Failed to get shooter1\n");
-    gunner_set_spawn(shooter1, 980, 790);
-    gunner_set_pos(shooter1, 980, 790);
-
-    list_insert(shooter_list, list_end(shooter_list), shooter1);
-
-    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;
-    uint8_t last_lb = 0;
-    struct packet pp;
-    keys_t *keys = get_key_presses();
-
-    /// loop stuff
-    uint64_t int_vector = 0;
-    int good = true;
-    int dead = false;
-
-    int health = 50;
-
-    map_make_dijkstra(map1, gunner_get_x(shooter1), gunner_get_y(shooter1));
-
-    while (good && !dead) {
-        /* Get a request message. */
-        if((r = get_interrupts_vector(&int_vector))) return r;
-        uint32_t n = 1;
-        for (uint8_t i = 0; i < 32; i++, n <<= 1) {
-            if(!good || dead) break;
-            if (int_vector & n) {
-                interrupt_handler(i);
-                switch (i) {
-                    case TIMER0_IRQ:
-                    if (timer_get_no_interrupts() % 60 == 0) timer_update(in_game_timer);
-                    if (timer_get_no_interrupts() %  6 == 0){
-                        map_make_dijkstra(map1, gunner_get_x(shooter1), gunner_get_y(shooter1));
-                    }
-
-                    update_movement(map1, shooter1, keys, shooter_list);
-
-                    update_game_state(map1, shooter_list, bullet_list);
-
-                    if(list_find(shooter_list, shooter1) == list_end(shooter_list)){
-                        good = false;
-                        dead = true;
-                        break;
-                    }
-
-                    double angle = get_mouse_angle(shooter1);
-                    gunner_set_angle(shooter1, angle - M_PI_2);
-
-                    ent_set_origin(gunner_get_x(shooter1)-ent_get_XLength()/2.0,
-                                   gunner_get_y(shooter1)-ent_get_YLength()/2.0);
-
-                    while(list_size(shooter_list) < ZOMBIES_NUM+1){
-                        gunner_t *zombie = gunner_ctor(bsp_zombie, bsp_nothing, GUNNER_MELEE | GUNNER_FOLLOW, 3);
-                        gunner_set_health(zombie, health);
-                        gunner_set_curr_health(zombie, health);
-                        health *= ZOMBIE_HEALTH_FACTOR;
-                        get_random_spawn(map1, zombie, shooter_list);
-                        list_push_back(shooter_list, zombie);
-                    }
-
-                    graph_clear_screen();
-                    map_draw   (map1);
-                    bullet_draw_list(bullet_list);
-                    gunner_draw_list(shooter_list);
-
-                    text_draw(in_game_timer->text);
-
-                    sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
-                    sprite_draw(sp_crosshair);
-                    graph_draw();
-
-                    break;
-                    case KBC_IRQ:
-                    if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) {
-                        good = false;
-                    }
-                    break;
-                    case MOUSE_IRQ:
-                    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;
-                        mouse_set_counter_mouse_ih(0);
-
-                    }
-                    break;
-                    case COM1_IRQ: nctp_ih(); break;
-                }
-            }
-        }
-    }
-
-    while(list_size(shooter_list) > 0){
-        gunner_t *p = list_erase(shooter_list, list_begin(shooter_list));
-        gunner_dtor(p);
-    }
-    if(list_dtor(shooter_list)) printf("COULD NOT DESTRUCT SHOOTER LIST\n");
-
-    while(list_size(bullet_list) > 0){
-        bullet_t *p = (bullet_t*)list_erase(bullet_list, list_begin(bullet_list));
-        bullet_dtor(p);
-    }
-    if(list_dtor(bullet_list)) printf("COULD NOT DESTRUCT BULLET LIST\n");
-
-    if(dead){
-        printf("YOU DIED\n");
-    }
-
-    timer_dtor(in_game_timer); in_game_timer = NULL;
-
-    return SUCCESS;
-}
-
 #define CHAT_MAX_SIZE   75
 #define CHAT_MAX_NUM    19
 static text_t      *t_text[CHAT_MAX_NUM] = {NULL};
