1 /*
2   Hatari - configuration.h
3 
4   This file is distributed under the GNU General Public License, version 2
5   or at your option any later version. Read the file gpl.txt for details.
6 */
7 
8 #ifndef HATARI_CONFIGURATION_H
9 #define HATARI_CONFIGURATION_H
10 
11 /* if header's struct contents depend on configuration options, header must include config.h */
12 #include "config.h"
13 
14 /* Logging and tracing */
15 typedef struct
16 {
17   char sLogFileName[FILENAME_MAX];
18   char sTraceFileName[FILENAME_MAX];
19   int nTextLogLevel;
20   int nAlertDlgLogLevel;
21   bool bConfirmQuit;
22   bool bNatFeats;
23   bool bConsoleWindow;	/* for now, used just for Windows */
24 } CNF_LOG;
25 
26 
27 /* debugger */
28 typedef struct
29 {
30   int nNumberBase;
31   int nSymbolLines;
32   int nMemdumpLines;
33   int nDisasmLines;
34   int nExceptionDebugMask;
35   int nDisasmOptions;
36   bool bDisasmUAE;
37   /* load symbols immediately on program start, and keep them after its termination */
38   bool bSymbolsResident;
39   /* whether to match all symbols or just types relevant for given command */
40   bool bMatchAllSymbols;
41 } CNF_DEBUGGER;
42 
43 
44 /* ROM (TOS + cartridge) configuration */
45 typedef struct
46 {
47   char szTosImageFileName[FILENAME_MAX];
48   bool bPatchTos;
49   char szCartridgeImageFileName[FILENAME_MAX];
50 } CNF_ROM;
51 
52 
53 /* Sound configuration */
54 typedef struct
55 {
56   bool bEnableMicrophone;
57   bool bEnableSound;
58   bool bEnableSoundSync;
59   int nPlaybackFreq;
60   int SdlAudioBufferSize;
61   char szYMCaptureFileName[FILENAME_MAX];
62   int YmVolumeMixing;
63 } CNF_SOUND;
64 
65 
66 
67 /* RS232 configuration */
68 typedef struct
69 {
70   bool bEnableRS232;
71   bool bEnableSccB;
72   char szOutFileName[FILENAME_MAX];
73   char szInFileName[FILENAME_MAX];
74   char sSccBInFileName[FILENAME_MAX];
75   char sSccBOutFileName[FILENAME_MAX];
76 } CNF_RS232;
77 
78 
79 /* Dialog Keyboard */
80 typedef enum
81 {
82   KEYMAP_SYMBOLIC,  /* Use keymapping with symbolic (ASCII) key codes */
83   KEYMAP_SCANCODE,  /* Use keymapping with PC keyboard scancodes */
84   KEYMAP_LOADED     /* Use keymapping with a map configuration file */
85 } KEYMAPTYPE;
86 
87 typedef struct
88 {
89   bool bDisableKeyRepeat;
90   KEYMAPTYPE nKeymapType;
91   char szMappingFileName[FILENAME_MAX];
92 } CNF_KEYBOARD;
93 
94 
95 typedef enum {
96   SHORTCUT_OPTIONS,
97   SHORTCUT_FULLSCREEN,
98   SHORTCUT_BORDERS,
99   SHORTCUT_MOUSEGRAB,
100   SHORTCUT_COLDRESET,
101   SHORTCUT_WARMRESET,
102   SHORTCUT_SCREENSHOT,
103   SHORTCUT_BOSSKEY,
104   SHORTCUT_CURSOREMU,
105   SHORTCUT_FASTFORWARD,
106   SHORTCUT_RECANIM,
107   SHORTCUT_RECSOUND,
108   SHORTCUT_SOUND,
109   SHORTCUT_DEBUG,
110   SHORTCUT_PAUSE,
111   SHORTCUT_QUIT,
112   SHORTCUT_LOADMEM,
113   SHORTCUT_SAVEMEM,
114   SHORTCUT_INSERTDISKA,
115   SHORTCUT_JOY_0,
116   SHORTCUT_JOY_1,
117   SHORTCUT_PAD_A,
118   SHORTCUT_PAD_B,
119   SHORTCUT_KEYS,  /* number of shortcuts */
120   SHORTCUT_NONE
121 } SHORTCUTKEYIDX;
122 
123 typedef struct
124 {
125   int withModifier[SHORTCUT_KEYS];
126   int withoutModifier[SHORTCUT_KEYS];
127 } CNF_SHORTCUT;
128 
129 
130 typedef struct
131 {
132   int STRamSize_KB;
133   int TTRamSize_KB;
134   bool bAutoSave;
135   char szMemoryCaptureFileName[FILENAME_MAX];
136   char szAutoSaveFileName[FILENAME_MAX];
137 } CNF_MEMORY;
138 
139 
140 /* Joystick configuration */
141 typedef enum
142 {
143   JOYSTICK_DISABLED,
144   JOYSTICK_REALSTICK,
145   JOYSTICK_KEYBOARD
146 } JOYSTICKMODE;
147 #define JOYSTICK_MODES 3
148 
149 typedef struct
150 {
151   JOYSTICKMODE nJoystickMode;
152   bool bEnableAutoFire;
153   bool bEnableJumpOnFire2;
154   int nJoyId;
155   int nKeyCodeUp, nKeyCodeDown, nKeyCodeLeft, nKeyCodeRight, nKeyCodeFire;
156 } JOYSTICK;
157 
158 enum
159 {
160 	JOYID_JOYSTICK0,
161 	JOYID_JOYSTICK1,
162 	JOYID_STEPADA,
163 	JOYID_STEPADB,
164 	JOYID_PARPORT1,
165 	JOYID_PARPORT2,
166 	JOYSTICK_COUNT
167 };
168 
169 typedef struct
170 {
171   JOYSTICK Joy[JOYSTICK_COUNT];
172 } CNF_JOYSTICKS;
173 
174 
175 /* Disk image configuration */
176 
177 typedef enum
178 {
179   WRITEPROT_OFF,
180   WRITEPROT_ON,
181   WRITEPROT_AUTO
182 } WRITEPROTECTION;
183 
184 #define MAX_FLOPPYDRIVES 2
185 
186 typedef struct
187 {
188   bool bAutoInsertDiskB;
189   bool FastFloppy;			/* true to speed up FDC emulation */
190   bool EnableDriveA;
191   bool EnableDriveB;
192   int  DriveA_NumberOfHeads;
193   int  DriveB_NumberOfHeads;
194   WRITEPROTECTION nWriteProtection;
195   char szDiskZipPath[MAX_FLOPPYDRIVES][FILENAME_MAX];
196   char szDiskFileName[MAX_FLOPPYDRIVES][FILENAME_MAX];
197   char szDiskImageDirectory[FILENAME_MAX];
198 } CNF_DISKIMAGE;
199 
200 
201 /* Hard drives configuration: C: - Z: */
202 #define MAX_HARDDRIVES  24
203 #define DRIVE_C 0
204 #define DRIVE_SKIP -1
205 
206 typedef enum
207 {
208   GEMDOS_NOP,
209   GEMDOS_UPPER,
210   GEMDOS_LOWER
211 } GEMDOS_CHR_CONV;
212 
213 typedef struct
214 {
215   int nGemdosDrive;
216   bool bUseHardDiskDirectories;
217   WRITEPROTECTION nWriteProtection;
218   GEMDOS_CHR_CONV nGemdosCase;
219   bool bFilenameConversion;
220   bool bGemdosHostTime;
221   bool bBootFromHardDisk;
222   char szHardDiskDirectories[MAX_HARDDRIVES][FILENAME_MAX];
223 } CNF_HARDDISK;
224 
225 /* SCSI/ACSI/IDE configuration */
226 #define MAX_ACSI_DEVS 8
227 #define MAX_SCSI_DEVS 8
228 #define MAX_IDE_DEVS 2
229 
230 typedef struct
231 {
232   bool bUseDevice;
233   char sDeviceFile[FILENAME_MAX];
234   int nBlockSize;
235 } CNF_SCSIDEV;
236 
237 typedef enum
238 {
239   BYTESWAP_OFF,
240   BYTESWAP_ON,
241   BYTESWAP_AUTO
242 } BYTESWAPPING;
243 
244 typedef struct
245 {
246   bool bUseDevice;
247   BYTESWAPPING nByteSwap;
248   char sDeviceFile[FILENAME_MAX];
249   int nBlockSize;
250   int nDeviceType;
251 } CNF_IDEDEV;
252 
253 /* Falcon register $FFFF8006 bits 6 & 7 (mirrored in $FFFF82C0 bits 0 & 1):
254  * 00 Monochrome
255  * 01 RGB - Colormonitor
256  * 10 VGA - Colormonitor
257  * 11 TV
258  */
259 #define FALCON_MONITOR_MONO 0x00  /* SM124 */
260 #define FALCON_MONITOR_RGB  0x40
261 #define FALCON_MONITOR_VGA  0x80
262 #define FALCON_MONITOR_TV   0xC0
263 
264 typedef enum
265 {
266   MONITOR_TYPE_MONO,
267   MONITOR_TYPE_RGB,
268   MONITOR_TYPE_VGA,
269   MONITOR_TYPE_TV
270 } MONITORTYPE;
271 
272 /* Screen configuration */
273 typedef struct
274 {
275   MONITORTYPE nMonitorType;
276   int nFrameSkips;
277   bool bFullScreen;
278   bool bKeepResolution;
279 #if WITH_SDL2
280   bool bResizable;
281 #else
282   bool bKeepResolutionST;
283 #endif
284   bool bAllowOverscan;
285   bool bAspectCorrect;
286   bool bUseExtVdiResolutions;
287   int nSpec512Threshold;
288   int nForceBpp;
289   int nVdiColors;
290   int nVdiWidth;
291   int nVdiHeight;
292   bool bMouseWarp;
293   bool bShowStatusbar;
294   bool bShowDriveLed;
295   bool bCrop;
296   bool bForceMax;
297   int nMaxWidth;
298   int nMaxHeight;
299 #if WITH_SDL2
300   bool bUseSdlRenderer;
301   int nRenderScaleQuality;
302   bool bUseVsync;
303 #endif
304   bool DisableVideo;
305 } CNF_SCREEN;
306 
307 
308 /* Printer configuration */
309 typedef struct
310 {
311   bool bEnablePrinting;
312   char szPrintToFileName[FILENAME_MAX];
313 } CNF_PRINTER;
314 
315 
316 /* Midi configuration */
317 typedef struct
318 {
319   bool bEnableMidi;
320   char sMidiInFileName[FILENAME_MAX];
321   char sMidiOutFileName[FILENAME_MAX];
322   char sMidiInPortName[FILENAME_MAX];
323   char sMidiOutPortName[FILENAME_MAX];
324 } CNF_MIDI;
325 
326 
327 /* Dialog System */
328 typedef enum
329 {
330   MACHINE_ST,
331   MACHINE_MEGA_ST,
332   MACHINE_STE,
333   MACHINE_MEGA_STE,
334   MACHINE_TT,
335   MACHINE_FALCON
336 } MACHINETYPE;
337 
338 typedef enum
339 {
340   DSP_TYPE_NONE,
341   DSP_TYPE_DUMMY,
342   DSP_TYPE_EMU
343 } DSPTYPE;
344 
345 #if ENABLE_WINUAE_CPU
346 typedef enum
347 {
348   FPU_NONE = 0,
349   FPU_68881 = 68881,
350   FPU_68882 = 68882,
351   FPU_CPU = 68040
352 } FPUTYPE;
353 #endif
354 
355 typedef enum
356 {
357   VIDEO_TIMING_MODE_RANDOM = 0,
358   VIDEO_TIMING_MODE_WS1,
359   VIDEO_TIMING_MODE_WS2,
360   VIDEO_TIMING_MODE_WS3,
361   VIDEO_TIMING_MODE_WS4,
362 } VIDEOTIMINGMODE;
363 
364 typedef struct
365 {
366   int nCpuLevel;
367   int nCpuFreq;
368   bool bCompatibleCpu;            /* Prefetch mode */
369   MACHINETYPE nMachineType;
370   bool bBlitter;                  /* TRUE if Blitter is enabled */
371   DSPTYPE nDSPType;               /* how to "emulate" DSP */
372   bool bPatchTimerD;
373   bool bFastBoot;                 /* Enable to patch TOS for fast boot */
374   bool bFastForward;
375   bool bAddressSpace24;           /* Always set to true with old UAE cpu */
376   VIDEOTIMINGMODE VideoTimingMode;
377 
378 #if ENABLE_WINUAE_CPU
379   bool bCycleExactCpu;
380   FPUTYPE n_FPUType;
381   bool bCompatibleFPU;            /* More compatible FPU */
382   bool bSoftFloatFPU;
383   bool bMMU;                      /* TRUE if MMU is enabled */
384 #endif
385 } CNF_SYSTEM;
386 
387 typedef struct
388 {
389   int AviRecordVcodec;
390   int AviRecordFps;
391   char AviRecordFile[FILENAME_MAX];
392 } CNF_VIDEO;
393 
394 /* State of system is stored in this structure */
395 /* On reset, variables are copied into system globals and used. */
396 typedef struct
397 {
398   /* Configure */
399   CNF_LOG Log;
400   CNF_DEBUGGER Debugger;
401   CNF_SCREEN Screen;
402   CNF_JOYSTICKS Joysticks;
403   CNF_KEYBOARD Keyboard;
404   CNF_SHORTCUT Shortcut;
405   CNF_SOUND Sound;
406   CNF_MEMORY Memory;
407   CNF_DISKIMAGE DiskImage;
408   CNF_HARDDISK HardDisk;
409   CNF_SCSIDEV Acsi[MAX_ACSI_DEVS];
410   CNF_SCSIDEV Scsi[MAX_SCSI_DEVS];
411   CNF_IDEDEV Ide[MAX_IDE_DEVS];
412   CNF_ROM Rom;
413   CNF_RS232 RS232;
414   CNF_PRINTER Printer;
415   CNF_MIDI Midi;
416   CNF_SYSTEM System;
417   CNF_VIDEO Video;
418 } CNF_PARAMS;
419 
420 
421 extern CNF_PARAMS ConfigureParams;
422 extern char sConfigFileName[FILENAME_MAX];
423 
Config_IsMachineST(void)424 static inline bool Config_IsMachineST(void)
425 {
426 	return ConfigureParams.System.nMachineType == MACHINE_ST ||
427 	       ConfigureParams.System.nMachineType == MACHINE_MEGA_ST;
428 }
429 
Config_IsMachineSTE(void)430 static inline bool Config_IsMachineSTE(void)
431 {
432 	return ConfigureParams.System.nMachineType == MACHINE_STE ||
433 	       ConfigureParams.System.nMachineType == MACHINE_MEGA_STE;
434 }
435 
Config_IsMachineTT(void)436 static inline bool Config_IsMachineTT(void)
437 {
438 	return ConfigureParams.System.nMachineType == MACHINE_TT;
439 }
440 
Config_IsMachineFalcon(void)441 static inline bool Config_IsMachineFalcon(void)
442 {
443 	return ConfigureParams.System.nMachineType == MACHINE_FALCON;
444 }
445 
446 extern void Configuration_SetDefault(void);
447 extern void Configuration_Apply(bool bReset);
448 extern void Configuration_Load(const char *psFileName);
449 extern void Configuration_Save(void);
450 extern void Configuration_MemorySnapShot_Capture(bool bSave);
451 extern void Configuration_ChangeCpuFreq ( int CpuFreq_new );
452 
453 #endif
454