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