Xemu [doxygen]  hyppo 0a42be3a057156924bc1b626a687bd6e27349c45 @ Sat 19 Mar 02:15:11 CET 2022
configdb.c
Go to the documentation of this file.
1 /* A work-in-progess MEGA65 (Commodore 65 clone origins) emulator
2  Part of the Xemu project, please visit: https://github.com/lgblgblgb/xemu
3  Copyright (C)2016-2022 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 /* Important WARNING:
21  * This is a trap! If you have something here with '#ifdef', it's quite possible that the macro is
22  * not defined here, but defined elsewhere, thus the emulator sees totally different structs for
23  * real but the problem is hidden! That is, be very careful at configdb_st (the type definition
24  * itself also at the usage!) that should be only dependent on macros defined in xemu-target.h,
25  * since that header file is always included by the build system, at command line level. */
26 
27 #include "xemu/emutools.h"
28 #include "xemu/emutools_config.h"
29 #include "configdb.h"
30 
31 #include "mega65.h"
32 #include "xemu/emutools_hid.h"
33 #include "audio65.h"
34 
36 
37 
38 static const struct xemutools_configdef_str_st str_options[] = {
39  { "8", NULL, "Path of EXTERNAL D81 disk image (not on/the SD-image) on drive 8", &configdb.disk8 },
40  { "9", NULL, "Path of ALWAYS EXTERNAL D81 disk image on drive 9", &configdb.disk9 },
41  { "fpga", NULL, "Comma separated list of FPGA-board switches turned ON", &configdb.fpga },
42  { "hickup", NULL, "Use external HICKUP", &configdb.hickup },
43  { "hickuprep", NULL, "Set path of hyper-debug REP file for external HICKUP", &configdb.hickuprep },
44  { "extbanner", NULL, "Use external initial memory content for banner", &configdb.extbanner },
45  { "extcramutils",NULL,"Use external initial content (32K) into the colour RAM (\"cram-utils\")", &configdb.extcramutils },
46  { "extinitrom", NULL, "Use external init-ROM. Beware: this is not the normal ROM you may think!", &configdb.extinitrom },
47  { "extchrwom", NULL, "Use external initial memory content for char-WOM (WriteOnlyMemory)", &configdb.extchrwom },
48  { "extflashutil",NULL,"Use external initial memory content for flashing utility", &configdb.extflashutil },
49  { "extonboard", NULL, "Use external initial memory content for the onboarding utility", &configdb.extonboard },
50  { "extfreezer", NULL, "Use external initial memory content for the Freezer", &configdb.extfreezer },
51  { "hdosdir", NULL, "Set directory with HyppoDOS redirections", &configdb.hdosdir },
52  { "rom", NULL, "Override Hyppo's loaded ROM during booting.", &configdb.rom },
53  { "prg", NULL, "Load a PRG file directly into the memory (/w C64/65 auto-detection on load address)", &configdb.prg },
54  { "sdimg", SDCARD_NAME, "Override path of SD-image to be used (also see the -virtsd option!)", &configdb.sdimg },
55  { "dumpmem", NULL, "Save memory content on exit", &configdb.dumpmem },
56 #ifdef XEMU_SNAPSHOT_SUPPORT
57  { "snapload", NULL, "Load a snapshot from the given file", &configdb.snapload },
58  { "snapsave", NULL, "Save a snapshot into the given file before Xemu would exit", &configdb.snapsave },
59 #endif
60 #ifdef HAS_UARTMON_SUPPORT
61  { "uartmon", NULL, "Sets the name for named unix-domain socket for uartmon, otherwise disabled", &configdb.uartmon },
62 #endif
63 #ifdef HAVE_XEMU_INSTALLER
64  { "installer", NULL, "Sets a download-specification descriptor file for auto-downloading data files", &configdb.installer },
65 #endif
66 #ifdef HAVE_ETHERTAP
67  { "ethertap", NULL, "Enable ethernet emulation, parameter is the already configured TAP device name", &configdb.ethertap },
68 #endif
69 #ifdef HID_KBD_MAP_CFG_SUPPORT
70  { "keymap", KEYMAP_USER_FILENAME, "Set keymap configuration file to be used", &configdb.keymap },
71 #endif
72  { "gui", NULL, "Select GUI type for usage. Specify some insane str to get a list", &configdb.selectedgui },
73  { NULL }
74 };
75 
76 static const struct xemutools_configdef_switch_st switch_options[] = {
77  { "cpusinglestep", "Force CPU emulation to do single step emulation (slower!)", &configdb.cpusinglestep },
78  { "hdosvirt", "Virtualize HDOS file access functions, but via only traps", &configdb.hdosvirt },
79  { "driveled", "Render drive LED at the top right corner of the screen", &configdb.show_drive_led },
80  { "allowmousegrab", "Allow auto mouse grab with left-click", &allow_mouse_grab },
81  { "allowfreezer", "Allow triggering freezer [NOT YET WORKING]", &configdb.allowfreezer },
82  { "fullscreen", "Start in fullscreen mode", &configdb.fullscreen_requested },
83  { "hyperdebug", "Crazy, VERY slow and 'spammy' hypervisor debug mode", &configdb.hyperdebug },
84  { "hyperdebugfrz", "Only start hyperdebug on entering the freezer", &configdb.hyperdebugfreezer },
85  { "hyperserialascii", "Convert PETSCII/ASCII hypervisor serial debug output to ASCII upper-case", &configdb.hyperserialascii },
86  { "usestubrom", "Use Xemu's internal stub-rom", &configdb.usestubrom },
87  { "useinitrom", "Use Xemu's internal init-rom", &configdb.useinitrom },
88  { "useutilmenu", "Try to tigger utility menu", &configdb.useutilmenu },
89  { "romfromsd", "Force ROM to be used from SD-card", &configdb.romfromsd },
90  { "defd81fromsd", "Force default D81 to be used from SD-card", &configdb.defd81fromsd },
91 #ifdef VIRTUAL_DISK_IMAGE_SUPPORT
92  { "virtsd", "Interpret -sdimg option as a DIRECTORY to be fed onto the FAT32FS and use virtual-in-memory disk storage.", &configdb.virtsd },
93 #endif
94 #ifdef FAKE_TYPING_SUPPORT
95  { "go64", "Go into C64 mode after start (with auto-typing, can be combined with -autoload)", &configdb.go64 },
96  { "autoload", "Load and start the first program from disk (with auto-typing, can be combined with -go64)", &configdb.autoload },
97 #endif
98  { "syscon", "Keep system console open (Windows-specific effect only)", &configdb.syscon },
99  { "besure", "Skip asking \"are you sure?\" on RESET or EXIT", &i_am_sure_override },
100  { "skipunhandledmem", "Do not even ask on unhandled memory access (hides problems!!)", &configdb.skip_unhandled_mem },
101  { "fullborders", "Show non-clipped display borders", &configdb.fullborders },
102  { "nosound", "Disables audio output generation", &configdb.nosound },
103  { "noopl3", "Disables OPL3 emulation", &configdb.noopl3 },
104  { NULL }
105 };
106 
107 static const struct xemutools_configdef_num_st num_options[] = {
108  { "dmarev", 2 + 0x100, "DMA revision (0/1/2=F018A/B/auto +256=autochange, +512=modulo, you always wants +256!)", &configdb.dmarev, 0, 1024 },
109  { "model", 0xFF, "Emulated MEGA65 model (255=custom/Xemu)", &configdb.mega65_model, 0, 0xFF },
110  { "hicked", 0x0, "Answer to HICKUP upgrade (128=ask user in a pop-up window)", &configdb.hicked, 0, 0xFF },
111  { "prgmode", 0, "Override auto-detect option for -prg (64 or 65 for C64/C65 modes, 0 = default, auto detect)", &configdb.prgmode, 0, 65 },
112  { "rtchofs", 0, "RTC (and CIA TOD) default hour offset to real-time -24 ... 24 (for testing!)", &configdb.rtc_hour_offset, -24, 24 },
113 #ifdef HAVE_XEMU_UMON
114  { "umon", 0, "TCP-based dual mode (http / text) monitor port number [NOT YET WORKING]", &configdb.umon, 0, 0xFFFF },
115 #endif
116  { "sdlrenderquality", RENDER_SCALE_QUALITY, "Setting SDL hint for scaling method/quality on rendering (0, 1, 2)", &configdb.sdlrenderquality, 0, 2 },
117  { "stereoseparation", AUDIO_DEFAULT_SEPARATION, "Audio stereo separation; 100(hard-stereo) ... 0(mono) ... -100(hard-reversed-stereo); default: " STRINGIFY(AUDIO_DEFAULT_SEPARATION), &configdb.stereoseparation, -100, 100 },
118  { "mastervolume", AUDIO_DEFAULT_VOLUME, "Audio emulation mixing final volume (100=unchanged ... 0=silence); default: " STRINGIFY(AUDIO_DEFAULT_VOLUME), &configdb.mastervolume, 0, 100 },
119  { "forcevideostd", -1, "Force video standard (0 = PAL, 1 = NTSC, -1 = default switchable by VIC-IV)", &configdb.force_videostd, -1, 1 },
120  // FIXME: as a workaround, I set this to "0" PAL, as newer MEGA65's default is this. HOWEVER this should be not handled this way but using a newer Hyppo!
121  { "initvideostd", 0, "Use given video standard as the startup one (0 = PAL, 1 = NTSC, -1 = Hyppo default)", &configdb.init_videostd, -1, 1 },
122  { "sidmask", 15, "Enabled SIDs of the four, in form of a bitmask", &configdb.sidmask, 0, 15 },
123  { "audiobuffersize", AUDIO_BUFFER_SAMPLES_DEFAULT, "Audio buffer size in BYTES", &configdb.audiobuffersize, AUDIO_BUFFER_SAMPLES_MIN, AUDIO_BUFFER_SAMPLES_MAX },
124  { NULL }
125 };
126 
127 static const struct xemutools_configdef_float_st float_options[] = {
128  { "fastclock", MEGA65_DEFAULT_FAST_CLOCK, "Clock of M65 fast mode (in MHz)", &configdb.fast_mhz, 4.0, 200.0 },
129  { NULL }
130 };
131 
132 
133 
135 {
136  if (size != sizeof(configdb))
137  FATAL("Xemu internal error: ConfigDB struct definition size mismatch");
138  xemucfg_define_str_option_multi(str_options);
139  xemucfg_define_switch_option_multi(switch_options);
140  xemucfg_define_num_option_multi(num_options);
141  xemucfg_define_float_option_multi(float_options);
142 }
configdb_st::hyperdebugfreezer
int hyperdebugfreezer
Definition: configdb.h:76
AUDIO_DEFAULT_VOLUME
#define AUDIO_DEFAULT_VOLUME
Definition: audio65.h:37
configdb_st::romfromsd
int romfromsd
Definition: configdb.h:47
configdb_st::audiobuffersize
int audiobuffersize
Definition: configdb.h:105
configdb_st::extinitrom
char * extinitrom
Definition: configdb.h:40
configdb_st::hickuprep
char * hickuprep
Definition: configdb.h:37
SDCARD_NAME
#define SDCARD_NAME
Definition: mega65.h:27
configdb.h
configdb_st::fullscreen_requested
int fullscreen_requested
Definition: configdb.h:35
emutools.h
configdb_st::prg
char * prg
Definition: configdb.h:33
configdb_st::useinitrom
int useinitrom
Definition: configdb.h:79
configdb_st::init_videostd
int init_videostd
Definition: configdb.h:70
configdb_st::extonboard
char * extonboard
Definition: configdb.h:43
configdb_st::fpga
char * fpga
Definition: configdb.h:35
configdb_st::extchrwom
char * extchrwom
Definition: configdb.h:41
configdb_st::rtc_hour_offset
int rtc_hour_offset
Definition: configdb.h:94
configdb_st::mastervolume
int mastervolume
Definition: configdb.h:100
configdb_st::extcramutils
char * extcramutils
Definition: configdb.h:39
configdb_st::extfreezer
char * extfreezer
Definition: configdb.h:44
configdb_st::skip_unhandled_mem
int skip_unhandled_mem
Definition: configdb.h:88
i_am_sure_override
int i_am_sure_override
Definition: emutools.c:74
configdb_st::usestubrom
int usestubrom
Definition: configdb.h:78
xemutools_configdef_str_st
Definition: emutools_config.h:85
AUDIO_DEFAULT_SEPARATION
#define AUDIO_DEFAULT_SEPARATION
Definition: audio65.h:36
xemucfg_define_str_option_multi
void xemucfg_define_str_option_multi(const struct xemutools_configdef_str_st p[])
configdb_st::go64
int go64
Definition: configdb.h:34
configdb_st::sidmask
int sidmask
Definition: configdb.h:104
configdb_st::rom
char * rom
Definition: configdb.h:32
configdb_st::hdosvirt
int hdosvirt
Definition: configdb.h:72
configdb_st::disk8
char * disk8
Definition: configdb.h:30
configdb_st::snapsave
char * snapsave
Definition: configdb.h:33
xemucfg_define_switch_option_multi
void xemucfg_define_switch_option_multi(const struct xemutools_configdef_switch_st p[])
configdb_st::keymap
char * keymap
Definition: configdb.h:32
mega65.h
configdb_st::fullborders
int fullborders
Definition: configdb.h:71
configdb_st::cpusinglestep
int cpusinglestep
Definition: configdb.h:32
configdb_st::sdlrenderquality
int sdlrenderquality
Definition: configdb.h:35
configdb_define_emulator_options
void configdb_define_emulator_options(void)
Definition: configdb.c:36
configdb_st::hickup
char * hickup
Definition: configdb.h:36
configdb_st::extbanner
char * extbanner
Definition: configdb.h:38
allow_mouse_grab
int allow_mouse_grab
Definition: emutools.c:118
xemucfg_define_num_option_multi
void xemucfg_define_num_option_multi(const struct xemutools_configdef_num_st p[])
configdb_st::hicked
int hicked
Definition: configdb.h:92
xemutools_configdef_switch_st
Definition: emutools_config.h:112
configdb_st::force_videostd
int force_videostd
Definition: configdb.h:69
configdb_st::autoload
int autoload
Definition: configdb.h:34
configdb_st::useutilmenu
int useutilmenu
Definition: configdb.h:80
emutools_config.h
configdb
struct configdb_st configdb
Definition: configdb.c:34
configdb_st::allowfreezer
int allowfreezer
Definition: configdb.h:74
xemutools_configdef_float_st
Definition: emutools_config.h:99
configdb_st::hdosdir
char * hdosdir
Definition: configdb.h:45
configdb_st::show_drive_led
int show_drive_led
Definition: configdb.h:73
AUDIO_BUFFER_SAMPLES_DEFAULT
#define AUDIO_BUFFER_SAMPLES_DEFAULT
Definition: audio65.h:26
xemucfg_define_float_option_multi
void xemucfg_define_float_option_multi(const struct xemutools_configdef_float_st p[])
configdb_st::selectedgui
char * selectedgui
Definition: configdb.h:68
STRINGIFY
#define STRINGIFY(x)
Definition: emutools_basicdefs.h:275
configdb_st::syscon
int syscon
Definition: configdb.h:34
size
int size
Definition: inject.c:37
configdb_st::hyperdebug
int hyperdebug
Definition: configdb.h:75
AUDIO_BUFFER_SAMPLES_MIN
#define AUDIO_BUFFER_SAMPLES_MIN
Definition: audio65.h:24
MEGA65_DEFAULT_FAST_CLOCK
#define MEGA65_DEFAULT_FAST_CLOCK
Definition: mega65.h:47
configdb_st::stereoseparation
int stereoseparation
Definition: configdb.h:99
xemutools_configdef_num_st
Definition: emutools_config.h:91
RENDER_SCALE_QUALITY
#define RENDER_SCALE_QUALITY
Definition: commodore_65.h:27
configdb_st::sdimg
char * sdimg
Definition: configdb.h:45
emutools_hid.h
configdb_st::mega65_model
int mega65_model
Definition: configdb.h:91
configdb_st::snapload
char * snapload
Definition: configdb.h:33
configdb_st::disk9
char * disk9
Definition: configdb.h:31
configdb_st::dmarev
int dmarev
Definition: configdb.h:35
configdb_st::prgmode
int prgmode
Definition: configdb.h:35
configdb_st::fast_mhz
double fast_mhz
Definition: configdb.h:101
configdb_st::noopl3
int noopl3
Definition: configdb.h:103
AUDIO_BUFFER_SAMPLES_MAX
#define AUDIO_BUFFER_SAMPLES_MAX
Definition: audio65.h:25
FATAL
#define FATAL(...)
Definition: xep128.h:117
configdb_st::defd81fromsd
int defd81fromsd
Definition: configdb.h:48
configdb_st::dumpmem
char * dumpmem
Definition: configdb.h:32
configdb_st::hyperserialascii
int hyperserialascii
Definition: configdb.h:77
configdb_st
Definition: configdb.h:29
audio65.h
configdb_st::nosound
int nosound
Definition: configdb.h:102
configdb_st::extflashutil
char * extflashutil
Definition: configdb.h:42