X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=fbgfx;a=blobdiff_plain;f=src%2Fmain.c;h=8752567992db2f648b87b1f6ab4c78136976d0f8;hp=9d73367be921b9d44ab2591288557b4206777512;hb=4b522caf5387f8075b7bbb2a2b0475c012157456;hpb=7e9af893a6d14c0136a89648a2fdebab614a662f diff --git a/src/main.c b/src/main.c index 9d73367..8752567 100644 --- a/src/main.c +++ b/src/main.c @@ -1,19 +1,71 @@ #include -#include #include +#include #include "fbgfx.h" +#include "fbevents.h" +#include "tunnel.h" + +static void keyboard(int key, int pressed, void *cls); +static void mouse(int bn, int pressed, int x, int y, void *cls); +static void motion(int x, int y, void *cls); -static unsigned char *vmem; +static void *vmem; static int xsz, ysz, depth; +static int quit; + + int main(void) { - if(!(vmem = fbgfx_get_video_mode(&xsz, &ysz, &depth))) { + fbgfx_save_video_mode(); + if(!(vmem = fbgfx_set_video_mode(800, 600, 16))) { return 1; } - printf("current video mode: %dx%d %dbpp\n", xsz, ysz, depth); + fbgfx_get_video_mode(&xsz, &ysz, &depth); + if(depth != 16) { + goto end; + } + if(fbev_init() == -1) { + goto end; + } + fbev_keyboard(keyboard, 0); + fbev_mbutton(mouse, 0); + fbev_mmotion(motion, 0); + + if(init_tunnel(xsz, ysz) == -1) { + goto end; + } - /*memset(vmem, 0xff, xsz * ysz * depth / 8);*/ + for(;;) { + fbev_update(); + if(quit) break; + + draw_tunnel(vmem); + } +end: + destroy_tunnel(); + fbev_shutdown(); + fbgfx_restore_video_mode(); return 0; } + +static void keyboard(int key, int pressed, void *cls) +{ + if(!pressed) return; + + switch(key) { + case 27: + case 'q': + case 'Q': + exit(0); + } +} + +static void mouse(int bn, int pressed, int x, int y, void *cls) +{ +} + +static void motion(int x, int y, void *cls) +{ +}