more dos port
[retroray] / src / app.h
1 /*
2 RetroRay - integrated standalone vintage modeller/renderer
3 Copyright (C) 2023  John Tsiombikas <nuclear@mutantstargoat.com>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program.  If not, see <https://www.gnu.org/licenses/>.
17 */
18 #ifndef APP_H_
19 #define APP_H_
20
21 #include "sizeint.h"
22 #include "logger.h"
23 #include "scene.h"
24
25 enum {
26         KEY_BACKSP = 8,
27         KEY_ESC = 27,
28         KEY_DEL = 127,
29
30         KEY_NUM_0 = 256, KEY_NUM_1, KEY_NUM_2, KEY_NUM_3, KEY_NUM_4,
31         KEY_NUM_5, KEY_NUM_6, KEY_NUM_7, KEY_NUM_8, KEY_NUM_9,
32         KEY_NUM_DOT, KEY_NUM_DIV, KEY_NUM_MUL, KEY_NUM_MINUS, KEY_NUM_PLUS, KEY_NUM_ENTER, KEY_NUM_EQUALS,
33         KEY_UP, KEY_DOWN, KEY_RIGHT, KEY_LEFT,
34         KEY_INS, KEY_HOME, KEY_END, KEY_PGUP, KEY_PGDN,
35         KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6,
36         KEY_F7, KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12,
37         KEY_F13, KEY_F14, KEY_F15,
38         KEY_NUMLK, KEY_CAPSLK, KEY_SCRLK,
39         KEY_RSHIFT, KEY_LSHIFT, KEY_RCTRL, KEY_LCTRL, KEY_RALT, KEY_LALT,
40         KEY_RMETA, KEY_LMETA, KEY_LSUPER, KEY_RSUPER, KEY_MODE, KEY_COMPOSE,
41         KEY_HELP, KEY_PRINT, KEY_SYSRQ, KEY_BREAK
42 };
43
44 #ifndef KEY_ANY
45 #define KEY_ANY         (-1)
46 #define KEY_ALT         (-2)
47 #define KEY_CTRL        (-3)
48 #define KEY_SHIFT       (-4)
49 #endif
50
51 enum {
52         KEY_MOD_SHIFT   = 1,
53         KEY_MOD_CTRL    = 4,
54         KEY_MOD_ALT     = 8
55 };
56
57
58 struct app_screen {
59         const char *name;
60
61         int (*init)(void);
62         void (*destroy)(void);
63         int (*start)(void);
64         void (*stop)(void);
65         void (*display)(void);
66         void (*reshape)(int, int);
67         void (*keyboard)(int, int);
68         void (*mouse)(int, int, int, int);
69         void (*motion)(int, int);
70         void (*sball_motion)(int, int, int);
71         void (*sball_rotate)(int, int, int);
72         void (*sball_button)(int, int);
73 };
74
75 extern int mouse_x, mouse_y, mouse_state[3];
76 extern unsigned int modkeys;
77 extern int win_width, win_height;
78 extern float win_aspect;
79 extern int fullscr;
80
81 extern long time_msec;
82 extern struct app_screen *cur_scr;
83 extern struct app_screen scr_model, scr_rend;
84
85 struct font;
86 extern struct font *uifont;
87
88 extern uint32_t *framebuf;
89
90 extern struct scene *scn;
91
92
93 int app_init(void);
94 void app_shutdown(void);
95
96 void app_display(void);
97 void app_reshape(int x, int y);
98 void app_keyboard(int key, int press);
99 void app_mouse(int bn, int st, int x, int y);
100 void app_motion(int x, int y);
101 void app_sball_motion(int x, int y, int z);
102 void app_sball_rotate(int x, int y, int z);
103 void app_sball_button(int bn, int st);
104
105 void app_chscr(struct app_screen *scr);
106
107 /* defined in main.c */
108 long app_getmsec(void);
109 void app_redisplay(void);
110 void app_swap_buffers(void);
111 void app_quit(void);
112 void app_resize(int x, int y);
113 void app_fullscreen(int fs);
114 void app_vsync(int vsync);
115
116 #endif  /* APP_H_ */