dropping SDL for the cross-platform version almost done
[dosdemo] / src / demo.h
1 #ifndef DEMO_H_
2 #define DEMO_H_
3
4 #include "inttypes.h"
5 #include "gfx.h"
6 #include "cfgopt.h"
7
8 /*extern int fb_width, fb_height, fb_bpp;*/
9 #define FB_WIDTH        320
10 #define FB_HEIGHT       240
11 #define FB_ASPECT       ((float)FB_WIDTH / (float)FB_HEIGHT)
12 #define FB_BPP          16
13 extern uint16_t *fb_pixels;
14 extern uint16_t *vmem;
15
16 extern unsigned long time_msec;
17 extern int mouse_x, mouse_y;
18 extern unsigned int mouse_bmask;
19
20 enum {
21         MOUSE_BN_LEFT           = 1,
22         MOUSE_BN_RIGHT          = 2,
23         MOUSE_BN_MIDDLE         = 4
24 };
25
26 /* special keys */
27 enum {
28         KB_BACKSP = 8,
29         KB_ESC = 27,
30         KB_DEL = 127,
31
32         KB_NUM_0, KB_NUM_1, KB_NUM_2, KB_NUM_3, KB_NUM_4,
33         KB_NUM_5, KB_NUM_6, KB_NUM_7, KB_NUM_8, KB_NUM_9,
34         KB_NUM_DOT, KB_NUM_DIV, KB_NUM_MUL, KB_NUM_MINUS, KB_NUM_PLUS, KB_NUM_ENTER, KB_NUM_EQUALS,
35         KB_UP, KB_DOWN, KB_RIGHT, KB_LEFT,
36         KB_INSERT, KB_HOME, KB_END, KB_PGUP, KB_PGDN,
37         KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6,
38         KB_F7, KB_F8, KB_F9, KB_F10, KB_F11, KB_F12,
39         KB_F13, KB_F14, KB_F15,
40         KB_NUMLK, KB_CAPSLK, KB_SCRLK,
41         KB_RSHIFT, KB_LSHIFT, KB_RCTRL, KB_LCTRL, KB_RALT, KB_LALT,
42         KB_RMETA, KB_LMETA, KB_LSUPER, KB_RSUPER, KB_MODE, KB_COMPOSE,
43         KB_HELP, KB_PRINT, KB_SYSRQ, KB_BREAK
44 };
45
46 #ifndef KB_ANY
47 #define KB_ANY          (-1)
48 #define KB_ALT          (-2)
49 #define KB_CTRL         (-3)
50 #define KB_SHIFT        (-4)
51 #endif
52
53
54 extern float sball_matrix[16];
55
56 int demo_init(int argc, char **argv);
57 void demo_cleanup(void);
58
59 int demo_resizefb(int width, int height, int bpp);
60
61 void demo_draw(void);
62 void demo_post_draw(void *pixels);
63
64 void demo_keyboard(int key, int press);
65
66
67 /* defined in main_*.c */
68 void demo_quit(void);
69 unsigned long get_msec(void);
70 void set_palette(int idx, int r, int g, int b);
71
72 #define swap_buffers(pix)       blit_frame(pix ? pix : fb_pixels, opt.vsync)
73
74 void change_screen(int idx);
75
76 /* call each frame to get 3D viewing spherical coordinates */
77 void mouse_orbit_update(float *theta, float *phi, float *dist);
78
79 void draw_mouse_pointer(uint16_t *fb);
80
81 /* compiled sprites available */
82 typedef void (*cs_font_func)(void *, int, int, int);
83 void cs_dbgfont(void *fb, int x, int y, int idx);
84 void cs_confont(void *fb, int x, int y, int idx);
85
86 /* helper to print text with cs_font */
87 void cs_puts_font(cs_font_func csfont, int sz, void *fb, int x, int y, const char *str);
88
89 #define cs_dputs(fb, x, y, str) cs_puts_font(cs_dbgfont, 9, fb, x, y, str)
90 #define cs_cputs(fb, x, y, str) cs_puts_font(cs_confont, 6, fb, x, y, str)
91
92 #define cs_mouseptr(fb, x, y) cs_dbgfont(fb, x, y, 127 - ' ')
93
94 #endif  /* DEMO_H_ */