|
Xemu [doxygen]
hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
|
Go to the documentation of this file.
22 #ifndef XEMU_COMMON_EMUTOOLS_H_INCLUDED
23 #define XEMU_COMMON_EMUTOOLS_H_INCLUDED
28 #ifndef XEMU_NO_SDL_DIALOG_OVERRIDE
32 #define SDL_ShowSimpleMessageBox_custom SDL_ShowSimpleMessageBox
33 #define SDL_ShowMessageBox_custom SDL_ShowMessageBox
37 #include <emscripten.h>
38 #define EMSCRIPTEN_SDL_BASE_DIR "/files/"
39 #define MSG_POPUP_WINDOW(sdlflag, title, msg, win) \
40 do { if (1 || sdlflag == SDL_MESSAGEBOX_ERROR) { EM_ASM_INT({ window.alert(Pointer_stringify($0)); }, msg); } } while(0)
42 #define MSG_POPUP_WINDOW(sdlflag, title, msg, win) SDL_ShowSimpleMessageBox_custom(sdlflag, title, msg, win)
43 #define INSTALL_DIRECTORY_ENTRY_NAME "default-files"
47 extern int macos_gui_started;
50 #define APP_ORG "xemu-lgb"
51 #ifndef APP_DESC_APPEND
52 #define APP_DESC_APPEND " - Xemu"
56 #define XEMU_MAIN_LOOP(func,p1,p2) emscripten_set_main_loop(func,p1,p2)
58 #define XEMU_MAIN_LOOP(func,p1,p2) for (;;) func()
65 #define XEMU_CPU_STAT_INFO_BUFFER_SIZE 64
82 static XEMU_INLINE int CHECK_SNPRINTF(
int ret,
int limit )
84 if (ret < 0 || ret >= limit - 1) {
85 fprintf(stderr,
"SNPRINTF-ERROR: too long string or other error (ret=%d) ..." NL, ret);
91 #define _REPORT_WINDOW_(sdlflag, str, ...) do { \
92 char _buf_for_win_msg_[4096]; \
93 CHECK_SNPRINTF(snprintf(_buf_for_win_msg_, sizeof _buf_for_win_msg_, __VA_ARGS__), sizeof _buf_for_win_msg_); \
94 fprintf(stderr, str ": %s" NL, _buf_for_win_msg_); \
96 fprintf(debug_fp, str ": %s" NL, _buf_for_win_msg_); \
99 MSG_POPUP_WINDOW(sdlflag, sdl_window_title, _buf_for_win_msg_, sdl_win); \
100 clear_emu_events(); \
101 xemu_drop_events(); \
102 SDL_RaiseWindow(sdl_win); \
103 restore_mouse_grab(); \
104 xemu_timekeeping_start(); \
106 MSG_POPUP_WINDOW(sdlflag, sdl_window_title, _buf_for_win_msg_, sdl_win); \
109 #define INFO_WINDOW(...) _REPORT_WINDOW_(SDL_MESSAGEBOX_INFORMATION, "INFO", __VA_ARGS__)
110 #define WARNING_WINDOW(...) _REPORT_WINDOW_(SDL_MESSAGEBOX_WARNING, "WARNING", __VA_ARGS__)
111 #define ERROR_WINDOW(...) _REPORT_WINDOW_(SDL_MESSAGEBOX_ERROR, "ERROR", __VA_ARGS__)
113 #define FATAL(...) do { \
114 ERROR_WINDOW(__VA_ARGS__); \
119 #define QUESTION_WINDOW(items, msg) _sdl_emu_secured_modal_box_(items, msg)
124 #define ARE_YOU_SURE_OVERRIDE 1
125 #define ARE_YOU_SURE_DEFAULT_YES 2
126 #define ARE_YOU_SURE_DEFAULT_NO 4
146 #define XEMU_VIEWPORT_ADJUST_LOGICAL_SIZE 1
149 extern void xemu_set_viewport (
unsigned int x1,
unsigned int y1,
unsigned int x2,
unsigned int y2,
unsigned int flags );
150 extern void xemu_get_viewport (
unsigned int *x1,
unsigned int *y1,
unsigned int *x2,
unsigned int *y2 );
164 #if !defined(XEMU_ARCH_HTML) && !defined(XEMU_CPU_ARM)
165 #define HAVE_MM_MALLOC
168 #ifdef HAVE_MM_MALLOC
172 #define xemu_malloc_ALIGNED _xemu_malloc_ALIGNED_emulated
184 extern void xemu_pre_init (
const char *app_organization,
const char *app_name,
const char *slogan );
187 const char *window_title,
189 int texture_x_size,
int texture_y_size,
190 int logical_x_size,
int logical_y_size,
191 int win_x_size,
int win_y_size,
196 int render_scale_quality,
197 int locked_texture_update,
198 void (*shutdown_callback)(
void)
208 return p[0] | (p[1] << 8);
211 return p[0] | (p[1] << 8) | (p[2] << 16) | (p[3] << 24);
214 return (Uint64)p[0] | ((Uint64)p[1] << 8) | ((Uint64)p[2] << 16) | ((Uint64)p[3] << 24) | ((Uint64)p[4] << 32) | ((Uint64)p[5] << 40) | ((Uint64)p[6] << 48) | ((Uint64)p[7] << 56);
217 p[0] = (
data ) & 0xFF;
218 p[1] = (
data >> 8) & 0xFF;
221 p[0] = (
data ) & 0xFF;
222 p[1] = (
data >> 8) & 0xFF;
223 p[2] = (
data >> 16) & 0xFF;
224 p[3] = (
data >> 24) & 0xFF;
227 p[0] = (
data ) & 0xFF;
228 p[1] = (
data >> 8) & 0xFF;
229 p[2] = (
data >> 16) & 0xFF;
230 p[3] = (
data >> 24) & 0xFF;
231 p[4] = (
data >> 32) & 0xFF;
232 p[5] = (
data >> 40) & 0xFF;
233 p[6] = (
data >> 48) & 0xFF;
234 p[7] = (
data >> 56) & 0xFF;
244 #ifdef XEMU_OSD_SUPPORT
250 # include <sys/stat.h>
252 extern int xemu_winos_utf8_to_wchar (
wchar_t *restrict o,
const char *restrict i,
size_t size );
255 extern FILE *
xemu_os_fopen (
const char *restrict
fn,
const char *restrict mode );
263 # define xemu_os_open open
264 # define xemu_os_creat creat
265 # define xemu_os_fopen fopen
266 # define xemu_os_unlink unlink
267 # define xemu_os_mkdir mkdir
268 # define xemu_os_opendir opendir
269 # define xemu_os_closedir closedir
270 # define xemu_os_stat stat
272 #define xemu_os_close close