Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
ui.c
Go to the documentation of this file.
1 /* Minimalistic Enterprise-128 emulator with focus on "exotic" hardware
2  Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu
3  Copyright (C)2016-2021 LGB (Gábor Lénárt) <lgblgblgb@gmail.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 2 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, write to the Free Software
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
18 
19 
20 #include "xemu/emutools.h"
21 #include "xemu/emutools_gui.h"
22 #include "xemu/emutools_files.h"
23 #include "xemu/emutools_hid.h"
24 
25 #include "ui.h"
26 
27 #include "enterprise128.h"
28 #include "nick.h"
29 #include "cpu.h"
30 #include "exdos_wd.h"
31 #include "primoemu.h"
32 #include "emu_monitor.h"
33 #include "dave.h"
34 #include "configdb.h"
35 
36 
37 static void ui_hard_reset ( void )
38 {
39  if (primo_on)
41  ep_reset();
42  ep_clear_ram();
43 }
44 
45 
46 #ifdef CONFIG_EXDOS_SUPPORT
47 static void ui_attach_disk ( void )
48 {
49  char fnbuf[PATH_MAX + 1];
50  static char dir[PATH_MAX + 1] = "";
53  "Select floppy disk image to attach",
54  dir,
55  fnbuf,
56  sizeof fnbuf
57  )) {
58  wd_attach_disk_image(fnbuf);
59  } else
60  DEBUGPRINT("UI: file selection for floppy mount was cancelled." NL);
61 }
62 #endif
63 
64 
65 static void ui_cb_cpuclock ( const struct menu_st *m, int *query )
66 {
69 }
70 
71 
72 static void ui_cb_monitor ( const struct menu_st *m, int *query )
73 {
75  if (monitor_check())
76  monitor_stop();
77  else
78  monitor_start();
79 }
80 
81 
82 static void ui_cb_sound ( const struct menu_st *m, int *query )
83 {
86  audio_stop();
87  else {
88  audio_init(1); // function itself will check if there was an init already, so not worrying here ...
89  audio_start();
90  }
91 }
92 
93 
94 static void ui_cb_render_scale_quality ( const struct menu_st *m, int *query )
95 {
97  char req_str[] = { VOIDPTR_TO_INT(m->user_data) + '0', 0 };
98  SDL_SetHintWithPriority(SDL_HINT_RENDER_SCALE_QUALITY, req_str, SDL_HINT_OVERRIDE);
101 }
102 
103 /**** MENU SYSTEM ****/
104 
105 static const struct menu_st menu_render_scale_quality[] = {
106  { "Nearest pixel sampling", XEMUGUI_MENUID_CALLABLE |
107  XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_render_scale_quality, (void*)0 },
108  { "Linear filtering", XEMUGUI_MENUID_CALLABLE |
109  XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_render_scale_quality, (void*)1 },
110  { "Anisotropic (Direct3D only)",XEMUGUI_MENUID_CALLABLE |
111  XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_render_scale_quality, (void*)2 },
112  { NULL }
113 };
114 static const struct menu_st menu_display[] = {
115  { "Render scale quality", XEMUGUI_MENUID_SUBMENU, NULL, menu_render_scale_quality },
116  { "Fullscreen", XEMUGUI_MENUID_CALLABLE, xemugui_cb_windowsize, (void*)0 },
117  { "Window - 100%", XEMUGUI_MENUID_CALLABLE, xemugui_cb_windowsize, (void*)1 },
118  { "Window - 200%", XEMUGUI_MENUID_CALLABLE |
120  { "Enable mouse grab + emu", XEMUGUI_MENUID_CALLABLE |
122  { NULL }
123 };
124 static const struct menu_st menu_debug[] = {
125  { "OSD key debugger", XEMUGUI_MENUID_CALLABLE |
127  { "Monitor prompt", XEMUGUI_MENUID_CALLABLE |
128  XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_monitor, NULL },
129  { "Browse system folder", XEMUGUI_MENUID_CALLABLE, xemugui_cb_native_os_prefdir_browser, NULL },
130  { NULL }
131 };
132 static const struct menu_st menu_reset[] = {
134  { "Hard reset", XEMUGUI_MENUID_CALLABLE, xemugui_cb_call_user_data, ui_hard_reset },
135  { NULL }
136 };
137 static const struct menu_st menu_cpuclock[] = {
138  { "4.00 MHz", XEMUGUI_MENUID_CALLABLE |
139  XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_cpuclock, (void*)4000000 },
140  { "6.00 MHz", XEMUGUI_MENUID_CALLABLE |
141  XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_cpuclock, (void*)6000000 },
142  { "7.12 MHz", XEMUGUI_MENUID_CALLABLE |
143  XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_cpuclock, (void*)7120000 },
144  { "8.00 MHz", XEMUGUI_MENUID_CALLABLE |
145  XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_cpuclock, (void*)8000000 },
146  { "10.00 MHz", XEMUGUI_MENUID_CALLABLE |
147  XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_cpuclock, (void*)10000000 },
148  { NULL }
149 };
150 static const struct menu_st menu_main[] = {
151  { "Display", XEMUGUI_MENUID_SUBMENU, NULL, menu_display },
152  { "CPU clock", XEMUGUI_MENUID_SUBMENU, NULL, menu_cpuclock },
153  { "Reset", XEMUGUI_MENUID_SUBMENU, NULL, menu_reset },
154  { "Debug", XEMUGUI_MENUID_SUBMENU, NULL, menu_debug },
155 #ifdef CONFIG_EXDOS_SUPPORT
156  { "Attach floppy", XEMUGUI_MENUID_CALLABLE, xemugui_cb_call_user_data, ui_attach_disk },
157 #endif
158 #ifdef XEMU_FILES_SCREENSHOT_SUPPORT
160 #endif
161  { "Sound emulation", XEMUGUI_MENUID_CALLABLE |
162  XEMUGUI_MENUFLAG_QUERYBACK, ui_cb_sound, NULL },
163 #ifdef XEMU_ARCH_WIN
164  { "System console", XEMUGUI_MENUID_CALLABLE |
165  XEMUGUI_MENUFLAG_QUERYBACK, xemugui_cb_sysconsole, NULL },
166 #endif
167 #ifdef HAVE_XEMU_EXEC_API
168  { "Help (on-line)", XEMUGUI_MENUID_CALLABLE, xemugui_cb_web_help_main, NULL },
169 #endif
172  { NULL }
173 };
174 
175 
176 void ui_enter ( void )
177 {
178  DEBUGGUI("UI: handler has been called." NL);
179  if (xemugui_popup(menu_main)) {
180  DEBUGPRINT("UI: oops, POPUP does not worked :(" NL);
181  }
182 }
wd_attach_disk_image
int wd_attach_disk_image(const char *fn)
Definition: exdos_wd.c:126
ep_reset
void ep_reset(void)
Definition: cpu.c:621
menu_st
Definition: emutools_gui.h:65
ui.h
primoemu.h
emutools.h
emu_monitor.h
menu_st::user_data
const void * user_data
Definition: emutools_gui.h:69
xemugui_file_selector
int xemugui_file_selector(int dialog_mode, const char *dialog_title, char *default_dir, char *selected, int path_max_size)
Definition: emutools_gui.c:126
xemugui_popup
int xemugui_popup(const struct menu_st desc[])
Definition: emutools_gui.c:135
register_screenshot_request
int register_screenshot_request
Definition: enterprise128.c:54
monitor_stop
int monitor_stop(void)
Definition: emu_monitor.c:897
xemugui_cb_osd_key_debugger
void xemugui_cb_osd_key_debugger(const struct menu_st *m, int *query)
Definition: popular_user_funcs.c:169
primo_emulator_exit
void primo_emulator_exit(void)
Definition: primoemu.c:192
set_cpu_clock_with_osd
int set_cpu_clock_with_osd(int hz)
Definition: enterprise128.c:102
is_audio_emulation_active
int is_audio_emulation_active(void)
Definition: dave.c:117
XEMUGUI_MENUID_CALLABLE
#define XEMUGUI_MENUID_CALLABLE
Definition: emutools_gui.h:30
emutools_gui.h
xemugui_cb_set_mouse_grab
void xemugui_cb_set_mouse_grab(const struct menu_st *m, int *query)
Definition: popular_user_funcs.c:176
XEMUGUI_FSEL_FLAG_STORE_DIR
#define XEMUGUI_FSEL_FLAG_STORE_DIR
Definition: emutools_gui.h:28
configdb_st::sdlrenderquality
int sdlrenderquality
Definition: configdb.h:35
XEMUGUI_MENUFLAG_QUERYBACK
#define XEMUGUI_MENUFLAG_QUERYBACK
Definition: emutools_gui.h:40
emutools_files.h
DEBUGPRINT
#define DEBUGPRINT(...)
Definition: emutools_basicdefs.h:171
VOIDPTR_TO_INT
#define VOIDPTR_TO_INT(x)
Definition: emutools_basicdefs.h:270
monitor_check
int monitor_check(void)
Definition: emu_monitor.c:891
dir
DIR * dir
Definition: cpmfs.c:46
cpu.h
NL
#define NL
Definition: fat32.c:37
xemugui_cb_set_integer_to_one
void xemugui_cb_set_integer_to_one(const struct menu_st *m, int *query)
Definition: popular_user_funcs.c:187
configdb
struct configdb_st configdb
Definition: configdb.c:34
XEMUGUI_FSEL_OPEN
#define XEMUGUI_FSEL_OPEN
Definition: emutools_gui.h:26
configdb.h
audio_init
void audio_init(int enable)
Definition: dave.c:153
audio_start
void audio_start(void)
Definition: dave.c:123
dave.h
audio_stop
void audio_stop(void)
Definition: dave.c:133
CPU_CLOCK
#define CPU_CLOCK
Definition: tvc.h:30
XEMUGUI_MENUID_SUBMENU
#define XEMUGUI_MENUID_SUBMENU
Definition: emutools_gui.h:31
monitor_start
int monitor_start(void)
Definition: emu_monitor.c:873
XEMUGUI_RETURN_CHECKED_ON_QUERY
#define XEMUGUI_RETURN_CHECKED_ON_QUERY(query, status)
Definition: emutools_gui.h:55
exdos_wd.h
xemugui_cb_call_quit_if_sure
void xemugui_cb_call_quit_if_sure(const struct menu_st *m, int *query)
Definition: popular_user_funcs.c:79
xemugui_cb_call_user_data
void xemugui_cb_call_user_data(const struct menu_st *m, int *query)
Definition: popular_user_funcs.c:29
emutools_hid.h
xemugui_cb_windowsize
void xemugui_cb_windowsize(const struct menu_st *m, int *query)
Definition: popular_user_funcs.c:97
enterprise128.h
ep_clear_ram
void ep_clear_ram(void)
Definition: cpu.c:186
xemugui_cb_about_window
void xemugui_cb_about_window(const struct menu_st *m, int *query)
Definition: popular_user_funcs.c:53
register_new_texture_creation
int register_new_texture_creation
Definition: emutools.c:84
ui_enter
void ui_enter(void)
Definition: ui.c:326
primo_on
int primo_on
Definition: primoemu.c:30
DEBUGGUI
#define DEBUGGUI
Definition: emutools_gui.h:22
XEMUGUI_MENUFLAG_SEPARATOR
#define XEMUGUI_MENUFLAG_SEPARATOR
Definition: emutools_gui.h:38
nick.h