1 /*
2  * parameters.h - parameter init/load/save code - header file
3  *
4  * Copyright (c) 2001-2008 ARAnyM developer team (see AUTHORS)
5  *
6  * Authors:
7  *  MJ		Milan Jurik
8  *  Joy		Petr Stehlik
9  *
10  * This file is part of the ARAnyM project which builds a new and powerful
11  * TOS/FreeMiNT compatible virtual machine running on almost any hardware.
12  *
13  * ARAnyM is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * ARAnyM is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with ARAnyM; if not, write to the Free Software
25  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
26  */
27 
28 #ifndef PARAMETERS_H
29 #define PARAMETERS_H
30 
31 #include "sysdeps.h"
32 #include "SDL_compat.h"
33 
34 #ifndef ARANYMHOME
35 # define ARANYMHOME	".aranym"
36 #endif
37 #ifndef ARANYMCONFIG
38 # define ARANYMCONFIG	"config"
39 #endif
40 #ifndef ARANYMNVRAM
41 # define ARANYMNVRAM	"nvram"
42 #endif
43 #ifndef ARANYMKEYMAP
44 # define ARANYMKEYMAP	"keymap"
45 #endif
46 #ifndef DIRSEPARATOR
47 # define DIRSEPARATOR	"/"
48 #endif
49 
50 #define BX_MAX_ATA_CHANNEL 1
51 #define MAX_ETH		4
52 
53 enum geo_type {
54 	geoCylinders,
55 	geoHeads,
56 	geoSpt,
57 	geoByteswap
58 };
59 
60 extern int get_geometry(const char *, enum geo_type geo);
61 
62 // External filesystem type
63 #define HOSTFS_MAX_DRIVES 32
64 
65 typedef struct {
66 	bool halfSensitive;
67 	char rootPath[512];
68 	char configPath[520];
69 } bx_aranymfs_drive_t;
70 typedef struct {
71 	char symlinks[20];
72 	bx_aranymfs_drive_t drive[HOSTFS_MAX_DRIVES];
73 } bx_aranymfs_options_t;
74 
75 // Floppy device
76 typedef struct {
77   char path[512];
78 } bx_floppy_options_t;
79 
80 typedef enum {
81       IDE_NONE, IDE_DISK, IDE_CDROM
82 } device_type_t;
83 
84 // Generic ATA device
85 typedef struct {
86   bool present;		// is converted to device_type_t below
87   bool isCDROM;		// is converted to device_type_t below
88   device_type_t type;
89   char path[512];
90   unsigned int cylinders;
91   unsigned int heads;
92   unsigned int spt;
93   bool byteswap;
94   bool readonly;
95   bool status;		// inserted = true
96   char model[41];
97 } bx_atadevice_options_t;
98 
99 // SCSI device
100 typedef struct {
101   bool present;
102   bool byteswap;
103   bool readonly;
104   char path[512];
105   char partID[3+1];	// 3 chars + EOS ( = '\0')
106 } bx_scsidevice_options_t;
107 
108 // TOS options
109 typedef struct {
110   bool redirect_CON;
111   long cookie_mch;
112   long cookie_akp;
113   char			tos_path[512];
114   char			emutos_path[512];
115 } bx_tos_options_t;
116 
117 // Video output options
118 typedef struct {
119   bool fullscreen;		// boot in fullscreen
120   int8 boot_color_depth;		// boot color depth
121   uint8 refresh;
122   int8 monitor;				// VGA or TV
123   char window_pos[10];	// window position coordinates in the form "123,456"
124   bool single_blit_composing; // whether the screen is composed using a single BitBlit/rectangluar copy
125   bool single_blit_refresh;   // whether the composed screen is updated/sent to screen using a single BitBlit/rectangluar copy
126 } bx_video_options_t;
127 
128 // Startup options
129 typedef struct {
130   bool grabMouseAllowed;
131   bool debugger;
132 } bx_startup_options_t;
133 
134 // JIT compiler options
135 typedef struct {
136   bool jit;
137   bool jitfpu;
138   bool jitinline;
139   bool jitdebug;
140   uint32 jitcachesize;
141   uint32 jitlazyflush;
142   char jitblacklist[512];
143 } bx_jit_options_t;
144 
145 // OpenGL options
146 typedef struct {
147   bool enabled;
148   bool filtered;
149   char library[1024];
150 } bx_opengl_options_t;
151 
152 // Ethernet options
153 typedef struct {
154   char type[32];
155   char tunnel[16];
156   char ip_host[16];
157   char ip_atari[16];
158   char netmask[16];
159   char mac_addr[18];
160 } bx_ethernet_options_t;
161 
162 // Lilo options
163 typedef struct {
164 	char kernel[512];	/* /path/to/vmlinux[.gz] */
165 	char args[512];		/* command line arguments for kernel */
166 	char ramdisk[512];	/* /path/to/ramdisk[.gz] */
167 	bool load_to_fastram;	/* load kernel to Fast RAM */
168 } bx_lilo_options_t;
169 
170 // Midi options
171 typedef struct {
172 	char type[32];		/* MIDI output type */
173 	char file[512];	/* /path/to/output */
174 	char sequencer[256];	/* /dev/sequencer */
175 	bool enabled;
176 } bx_midi_options_t;
177 
178 // NfCdrom options
179 typedef struct {
180 	int32 physdevtohostdev;
181 } bx_nfcdrom_options_t;
182 
183 // Misc CPU emulation options
184 typedef struct {
185 	bool	eps_enabled;	/* Exception per second limiter enabled ? */
186 	int32	eps_max;		/* Maximum tolerated eps before shutdown */
187 } bx_cpu_options_t;
188 
189 // Autozoom options
190 typedef struct {
191   bool enabled;		// Autozoom enabled
192   bool integercoefs;	// Autozoom with integer coefficients
193   bool fixedsize;	// Keep host screen size constant ?
194   uint32 width;		// Wanted host screen size
195   uint32 height;
196 } bx_autozoom_options_t;
197 
198 // NfOSMesa options
199 typedef struct {
200 	uint32 channel_size;    /* If using libOSMesa[16|32], size of channel */
201 	char libgl[1024];		/* Pathname to libGL */
202 	char libosmesa[1024];	/* Pathname to libOSMesa */
203 } bx_nfosmesa_options_t;
204 
205 // NatFeats options
206 typedef struct {
207 	char cdrom_driver[256];	/* CD-ROM driver */
208 	char vdi_driver[256];	/* VDI driver */
209 	bool hostexec_enabled;
210 } bx_natfeat_options_t;
211 
212 // NFvdi options
213 typedef struct {
214 	bool use_host_mouse_cursor; /* Use host mouse cursor */
215 } bx_nfvdi_options_t;
216 
217 // Parallel port options
218 typedef struct {
219 	char type[256];
220 	char file[256];
221 	char parport[256];
222 	bool enabled;
223 } bx_parallel_options_t;
224 
225 // Serial port options
226 typedef struct {
227 	char serport[256];
228 	bool enabled;
229 } bx_serial_options_t;
230 
231 // Keyboard and mouse
232 typedef struct {
233   bool wheel_eiffel;	// eiffel compatible scancodes for mouse wheel
234   bool altgr;			// real AltGr like on Milan
235 } bx_ikbd_options_t;
236 
237 // Hotkeys
238 #define HOTKEYS_STRING_SIZE		60
239 typedef struct {
240 	SDL_Keycode sym;
241 	SDL_Keymod mod;
242 } bx_hotkey;
243 
244 typedef struct {
245 	bx_hotkey	setup;
246 	bx_hotkey	quit;
247 	bx_hotkey	warmreboot;
248 	bx_hotkey	coldreboot;
249 	bx_hotkey	debug;
250 	bx_hotkey	ungrab;
251 	bx_hotkey	fullscreen;
252 	bx_hotkey	screenshot;
253 	bx_hotkey	sound;
254 } bx_hotkeys_t;
255 
256 // Audio
257 typedef struct {
258 	uint32 freq;
259 	uint32 chans;
260 	uint32 bits;
261 	uint32 samples;
262 	bool enabled;
263 } bx_audio_options_t;
264 
265 // Joysticks
266 typedef struct {
267 	int32	ikbd0;
268 	int32	ikbd1;
269 	int32	joypada;
270 	char	joypada_mapping[256];
271 	int32	joypadb;
272 	char	joypadb_mapping[256];
273 } bx_joysticks_options_t;
274 
275 #define DISKS	8
276 
277 #define CD_MAX_DRIVES 32
278 
279 // Options
280 typedef struct {
281   bx_floppy_options_t	floppy;
282   bx_atadevice_options_t atadevice[BX_MAX_ATA_CHANNEL][2];
283   bx_scsidevice_options_t	disks[DISKS];
284   bx_aranymfs_options_t	aranymfs;
285   bx_video_options_t	video;
286   bx_tos_options_t	tos;
287   bx_startup_options_t	startup;
288   bx_jit_options_t	jit;
289   bx_opengl_options_t	opengl;
290   bx_ethernet_options_t ethernet[MAX_ETH];
291   bx_lilo_options_t		lilo;
292   bx_midi_options_t		midi;
293   bx_ikbd_options_t		ikbd;
294   bx_nfcdrom_options_t	nfcdroms[ CD_MAX_DRIVES ];
295   bx_cpu_options_t  cpu;
296   bx_autozoom_options_t	autozoom;
297   bx_nfosmesa_options_t	osmesa;
298   bx_parallel_options_t parallel;
299   bx_serial_options_t serial;
300   bx_natfeat_options_t natfeats;
301   bx_nfvdi_options_t	nfvdi;
302   bx_audio_options_t	audio;
303   bx_joysticks_options_t	joysticks;
304   char			bootstrap_path[512];
305   char			bootstrap_args[512];
306   char			bootdrive;
307   uint32		fastram;
308   unsigned long fixed_memory_offset; // FIXME: should be uintptr
309   bool			gmtime;
310   bx_hotkeys_t		hotkeys;
311   bool			newHardDriveSupport;
312   char			snapshot_dir[512];
313 } bx_options_t;
314 
315 extern bx_options_t bx_options;
316 
317 
318 extern uint32 FastRAMSize;	// Size of Fast-RAM
319 #if FIXED_ADDRESSING
320 extern uintptr fixed_memory_offset;	// Virtual address of atari memory
321 #endif
322 
323 extern char *program_name;
324 extern bool boot_emutos;
325 extern bool boot_lilo;
326 extern bool halt_on_reboot;
327 
328 extern bool decode_switches(int, char **);
329 extern char *getConfFilename(const char *file, char *buffer, unsigned int bufsize);
330 extern char *getDataFilename(const char *file, char *buffer, unsigned int bufsize);
331 char *addFilename(char *buffer, const char *file, unsigned int bufsize);
332 bool setConfigValue(const char *section_name, const char *key, const char *value);
333 void listConfigValues(bool type);
334 
335 char *keysymToString(char *buffer, const bx_hotkey *keysym);
336 bool stringToKeysym(bx_hotkey *keysym, const char *string);
337 char **split_pathlist(const char *pathlist);
338 
339 extern const char *getConfigFile();
340 void setConfigFile(const char *filename);
341 extern bool loadSettings(const char *);
342 extern bool saveSettings(const char *);
343 
344 extern const struct Config_Section *getConfigSections(void);
345 
346 #endif
347