removed clang-format and clang_complete files from the repo
[dosdemo] / src / demo.h
index 1b246ed..af4870f 100644 (file)
@@ -2,34 +2,96 @@
 #define DEMO_H_
 
 #include "inttypes.h"
+#include "gfx.h"
+#include "cfgopt.h"
 
-extern int fb_width, fb_height, fb_bpp;
-extern uint16_t *fb_pixels;    /* system-RAM pixel buffer: use swap_buffers(fb_pixels) */
-/* video memory pointers. might both point to the front buffer if there is not
- * enough memory for page flipping. use swap_buffers(0) to flip. */
-extern uint16_t *vmem_back, *vmem_front;
+/*extern int fb_width, fb_height, fb_bpp;*/
+#define FB_WIDTH       320
+#define FB_HEIGHT      240
+#define FB_ASPECT      ((float)FB_WIDTH / (float)FB_HEIGHT)
+#define FB_BPP         16
+extern uint16_t *fb_pixels;
+extern uint16_t *vmem;
 
 extern unsigned long time_msec;
 extern int mouse_x, mouse_y;
 extern unsigned int mouse_bmask;
 
+enum {
+       MOUSE_BN_LEFT           = 1,
+       MOUSE_BN_RIGHT          = 2,
+       MOUSE_BN_MIDDLE         = 4
+};
+
+/* special keys */
+enum {
+       KB_BACKSP = 8,
+       KB_ESC = 27,
+       KB_DEL = 127,
+
+       KB_NUM_0, KB_NUM_1, KB_NUM_2, KB_NUM_3, KB_NUM_4,
+       KB_NUM_5, KB_NUM_6, KB_NUM_7, KB_NUM_8, KB_NUM_9,
+       KB_NUM_DOT, KB_NUM_DIV, KB_NUM_MUL, KB_NUM_MINUS, KB_NUM_PLUS, KB_NUM_ENTER, KB_NUM_EQUALS,
+       KB_UP, KB_DOWN, KB_RIGHT, KB_LEFT,
+       KB_INSERT, KB_HOME, KB_END, KB_PGUP, KB_PGDN,
+       KB_F1, KB_F2, KB_F3, KB_F4, KB_F5, KB_F6,
+       KB_F7, KB_F8, KB_F9, KB_F10, KB_F11, KB_F12,
+       KB_F13, KB_F14, KB_F15,
+       KB_NUMLK, KB_CAPSLK, KB_SCRLK,
+       KB_RSHIFT, KB_LSHIFT, KB_RCTRL, KB_LCTRL, KB_RALT, KB_LALT,
+       KB_RMETA, KB_LMETA, KB_LSUPER, KB_RSUPER, KB_MODE, KB_COMPOSE,
+       KB_HELP, KB_PRINT, KB_SYSRQ, KB_BREAK
+};
+
+#ifndef KB_ANY
+#define KB_ANY         (-1)
+#define KB_ALT         (-2)
+#define KB_CTRL                (-3)
+#define KB_SHIFT       (-4)
+#endif
+
+
+extern float sball_matrix[16];
+
 int demo_init(int argc, char **argv);
+int demo_init1(int argc, char **argv);
+int demo_init2(void);
 void demo_cleanup(void);
 
+int demo_resizefb(int width, int height, int bpp);
+
 void demo_draw(void);
+void demo_post_draw(void *pixels);
 
-void demo_keyboard(int key, int state);
+void demo_keyboard(int key, int press);
 
 
 /* defined in main_*.c */
 void demo_quit(void);
+void demo_abort(void);
 unsigned long get_msec(void);
 void set_palette(int idx, int r, int g, int b);
 
-/* pass 0 to just swap vmem_back/vmem_front with page flipping
- * pass a pointer to a system-ram pixel buffer to copy it to vmem_front,
- * instead of flipping.
- */
-void swap_buffers(void *pixels);
+#define swap_buffers(pix)      blit_frame(pix ? pix : fb_pixels, opt.vsync)
+
+void change_screen(int idx);
+
+/* call each frame to get 3D viewing spherical coordinates */
+void mouse_orbit_update(float *theta, float *phi, float *dist);
+
+void draw_mouse_pointer(uint16_t *fb);
+
+/* compiled sprites available */
+typedef void (*cs_font_func)(void *, int, int, int);
+void cs_dbgfont(void *fb, int x, int y, int idx);
+void cs_confont(void *fb, int x, int y, int idx);
+
+/* helper to print text with cs_font */
+void cs_puts_font(cs_font_func csfont, int sz, void *fb, int x, int y, const char *str);
+
+#define cs_dputs(fb, x, y, str)        cs_puts_font(cs_dbgfont, 9, fb, x, y, str)
+#define cs_cputs(fb, x, y, str)        cs_puts_font(cs_confont, 6, fb, x, y, str)
+
+#define cs_mouseptr(fb, x, y) cs_dbgfont(fb, x, y, 127 - ' ')
 
 #endif /* DEMO_H_ */