Project

General

Profile

Statistics
| Revision:

root / proj / src / singleplayer.c @ 348

History | View | Annotate | Download (2.31 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
#include "graph.h"
12
#include "hltp.h"
13
#include "errors.h"
14
#include "menu.h"
15

    
16
#include "campaign.h"
17
#include "zombies.h"
18

    
19
int (singleplayer)(void) {
20

    
21
    int r;
22

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

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

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

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

    
56
                    click = 0;
57

    
58
                    sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y());
59
                    sprite_draw(sp_crosshair);
60
                    graph_draw();
61

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

    
80
    return 0;
81
}