fixed RLEsprite bug
[eradicate] / src / game.c
1 #include "game.h"
2 #include "screens.h"
3 #include "sprite.h"
4
5 int fb_width, fb_height;
6 long fb_size;
7 uint16_t *fb_pixels;
8
9 long time_msec;
10
11 void (*draw)(void);
12 void (*key_event)(int key, int pressed);
13
14 static struct sprites dbgfont;
15
16
17 int init(int argc, char **argv)
18 {
19         if(load_sprites(&dbgfont, "data/dbgfont.spr") == -1) {
20                 return -1;
21         }
22         if(intro_init() == -1) {
23                 return -1;
24         }
25         if(menu_init() == -1) {
26                 return -1;
27         }
28
29         intro_start();
30         return 0;
31 }
32
33 void cleanup(void)
34 {
35         intro_cleanup();
36         menu_cleanup();
37 }
38
39 void dbg_print(void *fb, int x, int y, const char *str)
40 {
41         uint16_t *dest = (uint16_t*)fb + y * fb_width + x;
42
43         while(*str) {
44                 int c = *str++;
45
46                 if(c > ' ' && c < 128) {
47                         draw_sprite(dest, fb_width * 2, &dbgfont, c - ' ');
48                 }
49                 dest += 8;
50         }
51 }
52