gba-x3dtest

view src/main.c @ 20:2e903e27e35a

fixed x3d_disable_texture added runtime teture checks in the rasterizer
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 01 Jul 2014 23:23:37 +0300
parents b0ed38f13261
children
line source
1 #include "config.h"
2 #include <math.h>
3 #include <stdint.h>
4 #include "gbasys.h"
5 #include "logger.h"
6 #include "sincos.h"
7 #include "game.h"
9 static void keyb_intr(void);
11 static unsigned short keystate;
13 #define EVQ_SIZE 8
14 volatile static unsigned short evhead, evtail;
15 static unsigned short events[EVQ_SIZE];
17 int main(void)
18 {
19 gba_init();
21 interrupt(INTR_KEY, keyb_intr);
23 set_video_mode(GFX_MODE, 1);
24 set_bg_scale(171, 206);
26 clear_buffer(front_buffer, 0);
27 set_text_writebg(1);
28 logmsg(LOG_ALL, "please wait...\n");
30 if(game_init() == -1) {
31 return 1;
32 }
34 for(;;) {
35 /* process events */
36 while(evhead != evtail) {
37 unsigned short ev = events[evhead];
38 evhead = (evhead + 1) % EVQ_SIZE;
39 game_keyb(ev, 1);
40 }
42 /* this is needed because there's no key release interrupt (!) */
43 keystate = get_key_state(KEY_ALL);
45 game_draw();
46 }
47 return 0;
48 }
50 static void keyb_intr(void)
51 {
52 int i;
53 unsigned short prev_keystate = keystate;
54 unsigned short diff;
55 keystate = get_key_state(KEY_ALL);
56 diff = keystate ^ prev_keystate;
58 for(i=0; i<32; i++) {
59 int key = 1 << i;
61 if(diff & key) {
62 events[evtail] = key;
63 evtail = (evtail + 1) % EVQ_SIZE;
64 }
65 }
66 }