gba-x3dtest
diff src/main.c @ 5:850be43b3135
sdl version
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 16 Jun 2014 22:01:45 +0300 |
parents | 78d1664c2443 |
children | fb0a0d6a8b52 |
line diff
1.1 --- a/src/main.c Sat Jun 14 03:04:56 2014 +0300 1.2 +++ b/src/main.c Mon Jun 16 22:01:45 2014 +0300 1.3 @@ -1,15 +1,11 @@ 1.4 +#include "config.h" 1.5 #include <math.h> 1.6 #include <stdint.h> 1.7 #include "gbasys.h" 1.8 #include "logger.h" 1.9 #include "sincos.h" 1.10 +#include "game.h" 1.11 1.12 -#define GFX_MODE VMODE_LFB_160x128_16 1.13 -#define WIDTH 160 1.14 -#define HEIGHT 128 1.15 - 1.16 -static void draw(void); 1.17 -static void keyb(int key, int pressed); 1.18 static void keyb_intr(void); 1.19 1.20 static unsigned short keystate; 1.21 @@ -37,77 +33,17 @@ 1.22 while(evhead != evtail) { 1.23 unsigned short ev = events[evhead]; 1.24 evhead = (evhead + 1) % EVQ_SIZE; 1.25 - keyb(ev, 1); 1.26 + game_keyb(ev, 1); 1.27 } 1.28 1.29 /* this is needed because there's no key release interrupt (!) */ 1.30 keystate = get_key_state(KEY_ALL); 1.31 1.32 - draw(); 1.33 + game_draw(); 1.34 } 1.35 return 0; 1.36 } 1.37 1.38 -static int offset; 1.39 - 1.40 -#define X16INT(x) ((x) << 16) 1.41 - 1.42 -static void draw(void) 1.43 -{ 1.44 - int i, j; 1.45 - unsigned long msec = get_millisec(); 1.46 - uint16_t *pixels = back_buffer->pixels; 1.47 - 1.48 - clear_buffer(back_buffer, 0); 1.49 - 1.50 - for(i=0; i<WIDTH; i++) { 1.51 - float x = M_PI * 4.0 * (float)(i - offset) / (float)WIDTH;/*((M_PI_X16 * ((2 * (i - offset)) << 8)) << 8) / WIDTH;*/ 1.52 - float y = (HEIGHT / 4.0) * ((float)sin_x16(x * 65536.0) / 65536.0); 1.53 - 1.54 - int iy = HEIGHT - (y + HEIGHT / 2.0); 1.55 - 1.56 - pixels[iy * WIDTH + i] = RGB(255, 0, 0); 1.57 - 1.58 - if(i == offset) { 1.59 - for(j=0; j<HEIGHT; j++) { 1.60 - pixels[j * WIDTH + i] = RGB(255, 255, 0); 1.61 - } 1.62 - } 1.63 - } 1.64 - 1.65 - flip(); 1.66 -} 1.67 - 1.68 -static void keyb(int key, int pressed) 1.69 -{ 1.70 - switch(key) { 1.71 - case KEY_LEFT: 1.72 - --offset; 1.73 - break; 1.74 - 1.75 - case KEY_RIGHT: 1.76 - ++offset; 1.77 - break; 1.78 - 1.79 - default: 1.80 - break; 1.81 - } 1.82 - /*static const char *keyname[] = { 1.83 - "A", "B", "select", "start", "right", "left", "up", "down", "RT", "LT" 1.84 - }; 1.85 - int i; 1.86 - for(i=0; i<32; i++) { 1.87 - if(key & 1) { 1.88 - break; 1.89 - } 1.90 - key >>= 1; 1.91 - } 1.92 - if(i < sizeof keyname / sizeof *keyname) { 1.93 - logmsg(LOG_ALL, "key %s %s\n", keyname[i], pressed ? "pressed" : "released"); 1.94 - } 1.95 - */ 1.96 -} 1.97 - 1.98 static void keyb_intr(void) 1.99 { 1.100 int i;