Project

General

Profile

Statistics
| Revision:

root / proj / project / src / singleplayer.c @ 356

History | View | Annotate | Download (2.25 KB)

1
#include <lcom/lcf.h>
2

    
3
#include "singleplayer.h"
4

    
5
#include "proj.h"
6

    
7
#include "proj_macros.h"
8
#include "proj_func.h"
9
#include "ent.h"
10
#include "interrupts_func.h"
11

    
12
#include "libs.h"
13

    
14
#include "campaign.h"
15
#include "zombies.h"
16

    
17
int (singleplayer)(void) {
18

    
19
    int r;
20

    
21
    menu_t *main_menu = menu_ctor(font_get_default());
22
    menu_add_item(main_menu, "Campaign");
23
    menu_add_item(main_menu, "Zombies");
24
    menu_add_item(main_menu, "Back");
25

    
26
    //uint32_t refresh_count_value = sys_hz() / REFRESH_RATE;
27
    uint8_t last_lb = 0;
28
    struct packet pp;
29
    keys_t *keys = get_key_presses();
30

    
31
    /// loop stuff
32
    int click = 0;
33
    uint64_t int_vector = 0;
34
    int good = true;
35
    while (good) {
36
        /* Get a request message. */
37
        if((r = get_interrupts_vector(&int_vector))) return r;
38
        uint32_t n = 1;
39
        for (uint8_t i = 0; i < 32; i++, n <<= 1) {
40
            if (int_vector & n) {
41
                interrupt_handler(i);
42
                switch (i) {
43
                    case TIMER0_IRQ:
44

    
45
                    graph_clear_screen();
46
                    switch(menu_update_state(main_menu, click)){
47
                        case -1: break;
48
                        case  0: campaign(); break;
49
                        case  1: zombies(); break;
50
                        case  2: good = false; break;
51
                    }
52
                    menu_draw(main_menu);
53

    
54
                    click = 0;
55

    
56
                    sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
57
                    sprite_draw(sp_crosshair);
58
                    graph_draw();
59

    
60
                    break;
61
                    case KBC_IRQ:
62
                    if (keyboard_get_scancode()[0] == ESC_BREAK_CODE) good = false;
63
                    case MOUSE_IRQ:
64
                    if (mouse_get_counter_mouse_ih() >= 3) {
65
                        mouse_parse_packet(mouse_get_packet_mouse_ih(), &pp);
66
                        update_mouse(&pp);
67
                        if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed;
68
                        last_lb = keys->lb_pressed;
69
                        mouse_set_counter_mouse_ih(0);
70
                    }
71
                    break;
72
                    case COM1_IRQ: nctp_ih(); break;
73
                }
74
            }
75
        }
76
    }
77

    
78
    return 0;
79
}