Index: proj/include/campaign.h
===================================================================
--- proj/include/campaign.h	(nonexistent)
+++ proj/include/campaign.h	(revision 347)
@@ -0,0 +1,6 @@
+#ifndef CAMPAIGN_H_INCLUDED
+#define CAMPAIGN_H_INCLUDED
+
+int (campaign)(void);
+
+#endif //CAMPAIGN_H_INCLUDED

Property changes on: proj/include/campaign.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/include/chat.h
===================================================================
--- proj/include/chat.h	(nonexistent)
+++ proj/include/chat.h	(revision 347)
@@ -0,0 +1,6 @@
+#ifndef CHAT_H_INCLUDED
+#define CHAT_H_INCLUDED
+
+int (chat)(void);
+
+#endif //CHAT_H_INCLUDED

Property changes on: proj/include/chat.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/include/singleplayer.h
===================================================================
--- proj/include/singleplayer.h	(nonexistent)
+++ proj/include/singleplayer.h	(revision 347)
@@ -0,0 +1,6 @@
+#ifndef SINGLEPLAYER_H_INCLUDED
+#define SINGLEPLAYER_H_INCLUDED
+
+int (singleplayer)(void);
+
+#endif //SINGLEPLAYER_H_INCLUDED

Property changes on: proj/include/singleplayer.h
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/src/campaign.c
===================================================================
--- proj/src/campaign.c	(nonexistent)
+++ proj/src/campaign.c	(revision 347)
@@ -0,0 +1,121 @@
+#include <lcom/lcf.h>
+
+#include "campaign.h"
+
+#include "proj.h"
+
+#include "proj_macros.h"
+#include "proj_func.h"
+#include "ent.h"
+#include "interrupts_func.h"
+#include "graph.h"
+#include "hltp.h"
+#include "errors.h"
+#include <math.h>
+
+int (campaign)(void){
+
+    int r;
+
+    ent_set_scale(DEFAULT_SCALE);
+    text_timer_t *in_game_timer = text_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, 75, 75);
+    gunner_set_pos(shooter1, 75, 75);
+
+    gunner_t *shooter2 = gunner_ctor(bsp_shooter, bsp_nothing, GUNNER_PLAYER, 2);
+    gunner_set_spawn(shooter2, 975, 75);
+    gunner_set_pos(shooter2, 775, 75);
+
+    list_insert(shooter_list, list_end(shooter_list), shooter1);
+    list_insert(shooter_list, list_end(shooter_list), shooter2);
+
+    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;
+    while (good) {
+        /* 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) break;
+            if (int_vector & n) {
+                interrupt_handler(i);
+                switch (i) {
+                    case TIMER0_IRQ:
+
+                    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);
+
+                    //update_scale();
+                    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);
+
+                    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");
+
+    text_timer_dtor(in_game_timer); in_game_timer = NULL;
+
+    return SUCCESS;
+}

Property changes on: proj/src/campaign.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/src/chat.c
===================================================================
--- proj/src/chat.c	(nonexistent)
+++ proj/src/chat.c	(revision 347)
@@ -0,0 +1,187 @@
+#include <lcom/lcf.h>
+
+#include "chat.h"
+
+#include "proj.h"
+
+#include "proj_macros.h"
+#include "proj_func.h"
+#include "ent.h"
+#include "interrupts_func.h"
+#include "graph.h"
+#include "rectangle.h"
+#include "hltp.h"
+#include "makecode_map.h"
+#include "errors.h"
+#include <math.h>
+
+#define CHAT_MAX_SIZE   75
+#define CHAT_MAX_NUM    19
+static text_t      *t_text[CHAT_MAX_NUM] = {NULL};
+static rectangle_t *r_text               =  NULL;
+
+static void chat_process(const uint8_t *p, const size_t sz){
+    char buffer2[CHAT_MAX_NUM+3];
+    void *dest = NULL;
+    hltp_type tp = hltp_interpret(p, sz, &dest);
+    switch(tp){
+        case hltp_type_string:
+        strcpy(buffer2, dest);
+        strncat(buffer2, " <", 2);
+        for(size_t i = CHAT_MAX_NUM-1; i; --i)
+        text_set_string(t_text[i], text_get_string(t_text[i-1]));
+        text_set_string(t_text[0], buffer2);
+        for(size_t i = 0; i < CHAT_MAX_NUM; ++i){
+            if(text_get_string(t_text[i])[0] == '>'){
+                text_set_pos(t_text[i], rectangle_get_x(r_text)+50, text_get_y(t_text[i]));
+                text_set_halign(t_text[i], text_halign_left);
+            }else{
+                text_set_pos(t_text[i], rectangle_get_x(r_text)+rectangle_get_w(r_text)-50, text_get_y(t_text[i]));
+                text_set_halign(t_text[i], text_halign_right);
+            }
+        }
+        break;
+        case hltp_type_invalid: break;
+        case hltp_type_bullet : break;
+        case hltp_type_host   : break;
+        case hltp_type_remote : break;
+    }
+}
+
+int (chat)(void){
+    int r;
+
+    nctp_dump();
+    nctp_set_processor(chat_process);
+
+    struct packet pp;
+
+    char buffer[CHAT_MAX_SIZE] = "";
+    rectangle_t *r_buffer = NULL; {
+        r_buffer = rectangle_ctor(0,0,900,70);
+        rectangle_set_pos(r_buffer, graph_get_XRes()/2  -rectangle_get_w(r_buffer)/2,
+        (int16_t)(graph_get_YRes()*0.87-rectangle_get_h(r_buffer)/2));
+        rectangle_set_fill_color   (r_buffer, GRAPH_BLACK);
+        rectangle_set_outline_width(r_buffer, 2);
+        rectangle_set_outline_color(r_buffer, GRAPH_WHITE);
+        rectangle_set_fill_trans(r_buffer, GRAPH_TRANSPARENT);
+    }
+    text_t      *t_buffer = NULL; {
+        t_buffer = text_ctor(font_get_default(), "");
+        text_set_pos(t_buffer, rectangle_get_x(r_buffer)+50,
+        rectangle_get_y(r_buffer)+rectangle_get_h(r_buffer)/2);
+        text_set_halign(t_buffer, text_halign_left);
+        text_set_valign(t_buffer, text_valign_center);
+        text_set_color (t_buffer, TEXT_COLOR);
+    }
+    text_t      *t_size   = NULL; {
+        t_size = text_ctor(font_get_default(), "");
+        text_set_pos(t_size, rectangle_get_x(r_buffer)+rectangle_get_w(r_buffer)-5,
+        rectangle_get_y(r_buffer)+rectangle_get_h(r_buffer)-5);
+        text_set_halign(t_size, text_halign_right);
+        text_set_valign(t_size, text_valign_bottom);
+        text_set_color (t_size, TEXT_COLOR);
+        text_set_size  (t_size, 18);
+        char buffer2[20];
+        sprintf(buffer2, "%d/%d", strlen(buffer), CHAT_MAX_SIZE);
+        text_set_string(t_size, buffer2);
+    }
+
+    /** r_text */ {
+    r_text = rectangle_ctor(0,0,900,550);
+    rectangle_set_pos(r_text, graph_get_XRes()/2  -rectangle_get_w(r_buffer)/2,
+    (int16_t)(graph_get_YRes()*0.09));
+    rectangle_set_fill_color   (r_text, GRAPH_BLACK);
+    rectangle_set_outline_width(r_text, 2);
+    rectangle_set_outline_color(r_text, GRAPH_WHITE);
+    rectangle_set_fill_trans(r_text, GRAPH_TRANSPARENT);
+    }
+    /** t_text */ {
+    for(uint16_t i = 0; i < CHAT_MAX_NUM; ++i){
+        t_text[i] = text_ctor(font_get_default(), " ");
+        text_set_pos(t_text[i], rectangle_get_x(r_text)+50,
+        rectangle_get_y(r_text)+rectangle_get_h(r_text)-30-25*i);
+        text_set_halign(t_text[i], text_halign_left);
+        text_set_valign(t_text[i], text_valign_bottom);
+        text_set_color (t_text[i], TEXT_COLOR);
+    }
+}
+
+/// loop stuff
+uint64_t int_vector = 0;
+int good = true;
+while (good) {
+    /* 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 (int_vector & n) {
+            interrupt_handler(i);
+            switch (i) {
+                case TIMER0_IRQ:
+                graph_clear_screen();
+                sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
+
+                rectangle_draw(r_buffer);
+                text_draw(t_buffer);
+                text_draw(t_size);
+
+                rectangle_draw(r_text);
+                for(size_t j = 0; j < CHAT_MAX_NUM; ++j) text_draw(t_text[j]);
+
+                sprite_draw(sp_crosshair);
+                graph_draw();
+                break;
+                case KBC_IRQ:
+                if      (keyboard_get_scancode()[0] == ESC_BREAK_CODE) good = false;
+                else if (keyboard_get_scancode()[0] == ENTER_MAKE_CODE) {
+                    hltp_send_string(buffer);
+                    char buffer2[CHAT_MAX_SIZE+3] = "> ";
+                    strncat(buffer2, buffer, strlen(buffer));
+                    for(size_t j = CHAT_MAX_NUM-1; j; --j) text_set_string(t_text[i], text_get_string(t_text[i-1]));
+                    text_set_string(t_text[0], buffer2);
+                    for(size_t j = 0; j < CHAT_MAX_NUM; ++j){
+                        if(text_get_string(t_text[j])[0] == '>'){
+                            text_set_pos(t_text[j], rectangle_get_x(r_text)+50, text_get_y(t_text[j]));
+                            text_set_halign(t_text[j], text_halign_left);
+                        }else{
+                            text_set_pos(t_text[j], rectangle_get_x(r_text)+rectangle_get_w(r_text)-50, text_get_y(t_text[j]));
+                            text_set_halign(t_text[j], text_halign_right);
+                        }
+                    }
+                    buffer[0] = '\0';
+                } else if(keyboard_get_scancode()[0] == BACKSPACE_MAKE_CODE){
+                    buffer[strlen(buffer)-1] = '\0';
+                } else {
+                    char c = map_makecode(keyboard_get_scancode()[0]);
+                    if (c == ERROR_CODE) break;
+                    if(strlen(buffer) < CHAT_MAX_SIZE) strncat(buffer, &c, 1);
+                    else                               printf("Char limit exceeded\n");
+                }
+                text_set_string(t_buffer, buffer);
+                char buffer2[20];
+                sprintf(buffer2, "%d/%d", strlen(buffer), CHAT_MAX_SIZE);
+                text_set_string(t_size, buffer2);
+                case MOUSE_IRQ:
+                if (mouse_get_counter_mouse_ih() >= 3) {
+                    mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
+                    update_mouse(&pp);
+                    mouse_set_counter_mouse_ih(0);
+                }
+                break;
+                case COM1_IRQ: nctp_ih(); break;
+            }
+        }
+    }
+}
+
+rectangle_dtor(r_buffer);
+text_dtor     (t_buffer);
+
+rectangle_dtor(r_text);
+for(size_t i = 0; i < CHAT_MAX_NUM; ++i) text_dtor(t_text[i]);
+
+nctp_set_processor(NULL);
+
+return SUCCESS;
+}

Property changes on: proj/src/chat.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: proj/src/singleplayer.c
===================================================================
--- proj/src/singleplayer.c	(nonexistent)
+++ proj/src/singleplayer.c	(revision 347)
@@ -0,0 +1,81 @@
+#include <lcom/lcf.h>
+
+#include "singleplayer.h"
+
+#include "proj.h"
+
+#include "proj_macros.h"
+#include "proj_func.h"
+#include "ent.h"
+#include "interrupts_func.h"
+#include "graph.h"
+#include "hltp.h"
+#include "errors.h"
+#include "menu.h"
+
+#include "campaign.h"
+#include "zombies.h"
+
+int (singleplayer)(void) {
+
+    int r;
+
+    menu_t *main_menu = menu_ctor(font_get_default());
+    menu_add_item(main_menu, "Campaign");
+    menu_add_item(main_menu, "Zombies");
+    menu_add_item(main_menu, "Back");
+
+    //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
+    int click = 0;
+    uint64_t int_vector = 0;
+    int good = true;
+    while (good) {
+        /* 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 (int_vector & n) {
+                interrupt_handler(i);
+                switch (i) {
+                    case TIMER0_IRQ:
+
+                    graph_clear_screen();
+                    switch(menu_update_state(main_menu, click)){
+                        case -1: break;
+                        case  0: campaign(); break;
+                        case  1: zombies(); break;
+                        case  2: good = false; break;
+                    }
+                    menu_draw(main_menu);
+
+                    click = 0;
+
+                    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;
+                    case MOUSE_IRQ:
+                    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;
+                        mouse_set_counter_mouse_ih(0);
+                    }
+                    break;
+                    case COM1_IRQ: nctp_ih(); break;
+                }
+            }
+        }
+    }
+
+    return 0;
+}

Property changes on: proj/src/singleplayer.c
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
