Revision 300
changed stuff
proj/src/proj.c | ||
---|---|---|
57 | 57 |
map_t *map1 = NULL; |
58 | 58 |
sprite_t *sp_crosshair = NULL; |
59 | 59 |
|
60 |
int (game)(void); |
|
61 |
int (chat)(void); |
|
62 |
|
|
60 |
static int (singleplayer)(void); |
|
61 |
static int (chat)(void); |
|
63 | 62 |
int(proj_main_loop)(int argc, char *argv[]) { |
64 | 63 |
|
65 | 64 |
int r; |
... | ... | |
132 | 131 |
graph_clear_screen(); |
133 | 132 |
switch(menu_update_state(main_menu, click)){ |
134 | 133 |
case -1: break; |
135 |
case 0: game(); break;
|
|
134 |
case 0: singleplayer(); break; //campaign(); break;
|
|
136 | 135 |
case 1: break; |
137 | 136 |
case 2: chat(); break; |
138 | 137 |
case 3: good = false; break; |
... | ... | |
194 | 193 |
return 0; |
195 | 194 |
} |
196 | 195 |
|
197 |
int (game)(void){
|
|
196 |
static int (campaign)(void);
|
|
198 | 197 |
|
198 |
static int (singleplayer)(void) { |
|
199 |
|
|
199 | 200 |
int r; |
200 | 201 |
|
202 |
menu_t *main_menu = menu_ctor(consolas); |
|
203 |
menu_add_item(main_menu, "Campaign"); |
|
204 |
menu_add_item(main_menu, "Zombies"); |
|
205 |
menu_add_item(main_menu, "Back"); |
|
206 |
|
|
207 |
//uint32_t refresh_count_value = sys_hz() / REFRESH_RATE; |
|
208 |
uint8_t last_lb = 0; |
|
209 |
struct packet pp; |
|
210 |
keys_t *keys = get_key_presses(); |
|
211 |
|
|
212 |
/// loop stuff |
|
213 |
int ipc_status; |
|
214 |
message msg; |
|
215 |
|
|
216 |
int click = 0; |
|
217 |
|
|
218 |
int good = true; |
|
219 |
|
|
220 |
while (good) { |
|
221 |
/* Get a request message. */ |
|
222 |
if ((r = driver_receive(ANY, &msg, &ipc_status)) != 0) { |
|
223 |
printf("driver_receive failed with %d", r); |
|
224 |
continue; |
|
225 |
} |
|
226 |
if (is_ipc_notify(ipc_status)) { /* received notification */ |
|
227 |
switch (_ENDPOINT_P(msg.m_source)) { |
|
228 |
case HARDWARE: /* hardware interrupt notification */ |
|
229 |
for (uint32_t i = 0, n = 1; i < 32; i++, n <<= 1) { |
|
230 |
if (msg.m_notify.interrupts & n) { |
|
231 |
interrupt_handler(i); |
|
232 |
switch (i) { |
|
233 |
case TIMER0_IRQ: |
|
234 |
|
|
235 |
graph_clear_screen(); |
|
236 |
switch(menu_update_state(main_menu, click)){ |
|
237 |
case -1: break; |
|
238 |
case 0: campaign(); break; |
|
239 |
case 1: break; |
|
240 |
case 2: good = false; break; |
|
241 |
} |
|
242 |
menu_draw(main_menu); |
|
243 |
|
|
244 |
click = 0; |
|
245 |
|
|
246 |
sprite_set_pos(sp_crosshair, *get_mouse_X(), *get_mouse_Y()); |
|
247 |
sprite_draw(sp_crosshair); |
|
248 |
graph_draw(); |
|
249 |
|
|
250 |
break; |
|
251 |
case KBC_IRQ: |
|
252 |
if ((scancode[0]) == ESC_BREAK_CODE) good = false; |
|
253 |
case MOUSE_IRQ: |
|
254 |
if (counter_mouse_ih >= 3) { |
|
255 |
mouse_parse_packet(packet_mouse_ih, &pp); |
|
256 |
update_mouse(&pp); |
|
257 |
if (!click) click = last_lb ^ keys->lb_pressed && keys->lb_pressed; |
|
258 |
last_lb = keys->lb_pressed; |
|
259 |
counter_mouse_ih = 0; |
|
260 |
} |
|
261 |
break; |
|
262 |
case COM1_IRQ: nctp_ih(); break; |
|
263 |
} |
|
264 |
} |
|
265 |
} |
|
266 |
|
|
267 |
break; |
|
268 |
default: |
|
269 |
break; /* no other notifications expected: do nothing */ |
|
270 |
} |
|
271 |
} else { /* received standart message, not a notification */ |
|
272 |
/* no standart message expected: do nothing */ |
|
273 |
} |
|
274 |
} |
|
275 |
|
|
276 |
return 0; |
|
277 |
} |
|
278 |
|
|
279 |
static int (campaign)(void){ |
|
280 |
|
|
281 |
int r; |
|
282 |
|
|
201 | 283 |
ent_set_scale(DEFAULT_SCALE); |
202 | 284 |
text_timer_t *in_game_timer = timer_ctor(consolas); |
203 | 285 |
|
... | ... | |
329 | 411 |
|
330 | 412 |
#define CHAT_MAX_SIZE 75 |
331 | 413 |
#define CHAT_MAX_NUM 19 |
332 |
|
|
333 | 414 |
text_t *t_text[CHAT_MAX_NUM] = {NULL}; |
334 | 415 |
rectangle_t *r_text = NULL; |
335 |
|
|
336 | 416 |
static void chat_process(const uint8_t *p, const size_t sz){ |
337 | 417 |
char buffer2[CHAT_MAX_NUM+3]; |
338 | 418 |
void *dest = NULL; |
... | ... | |
357 | 437 |
default: break; |
358 | 438 |
} |
359 | 439 |
} |
360 |
|
|
361 |
int (chat)(void){ |
|
440 |
static int (chat)(void){ |
|
362 | 441 |
int r; |
363 | 442 |
|
364 | 443 |
nctp_dump(); |
Also available in: Unified diff