Skip to content

Commit 63f7f33

Browse files
author
h-a-l-9000
committed
Add new features to the config command for control of the config file:
- manipulate the autoexec section - display information on sections and values - show the used config files and startup command line parameters - restart capability - save config files either in the config or program directory git-svn-id: https://dosbox.svn.sf.net/svnroot/dosbox/dosbox/trunk@3651 67dff46e-583c-4055-8ee1-d6b00ecfda6c
1 parent 606e0c2 commit 63f7f33

15 files changed

+833
-234
lines changed

README

+85-4
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,19 @@ VER set major_version [minor_version]
622622

623623

624624
CONFIG -writeconf filelocation
625+
CONFIG -writeconf
626+
CONFIG -wcp filelocation
627+
CONFIG -wcd
625628
CONFIG -writelang filelocation
629+
CONFIG -axadd
630+
CONFIG -axclear
631+
CONFIG -axtype
632+
CONFIG -r [parameters]
633+
CONFIG -l
634+
CONFIG -help
635+
CONFIG -help sections
636+
CONFIG -help section
637+
CONFIG -help section property
626638
CONFIG -securemode
627639
CONFIG -set "section property=value"
628640
CONFIG -get "section property"
@@ -633,20 +645,74 @@ CONFIG -get "section property"
633645
be found in Section 13: "The configuration (options) file".
634646

635647
-writeconf filelocation
636-
Write the current configuration settings to a file in a specified location.
637-
"filelocation" is located on the local drive, not a mounted drive in DOSBox.
648+
(or -wc filelocation)
649+
Write the current configuration settings to a file in a specified location
650+
relative to the DOSBox config directory. Relative and absolute paths are
651+
possible. "filelocation" is located on the local drive, not a mounted
652+
drive in DOSBox.
653+
638654
The configuration file controls various settings of DOSBox:
639655
the amount of emulated memory, the emulated sound cards and many more
640656
things. It allows access to AUTOEXEC.BAT as well.
641657
See Section 13: "The configuration (options) file" for more information.
642658

659+
-writeconf
660+
(or -wc)
661+
Write the configuration to the primary loaded config file.
662+
663+
-wcp filelocation
664+
Write the current configuration settings to the specified file in or
665+
relative to the DOSBox program start directory. Realtive and absolute
666+
paths are possible. This is located on a drive on the host, not a mounted
667+
drive in DOSBox. It is useful if you keep DOSBox on a removable media.
668+
If file is omitted, the configuration will be written to dosbox.conf.
669+
670+
-wcd
671+
Write the current configuration to the default config file.
672+
673+
643674
-writelang filelocation
675+
(or -wl filelocation)
644676
Write the current language settings to a file in a specified location.
645677
"filelocation" is located on the local drive, not a mounted drive
646678
in DOSBox. The language file controls all visible output of the internal
647679
commands and the internal DOS.
648680
See Section 14: "The Language File" for more information.
649681

682+
-axadd "line1" "line2" ...
683+
Adds a command line to the autoexec section.
684+
685+
-axclear
686+
Clears the autoexec section.
687+
688+
-axtype
689+
Prints the content of the autoexec section.
690+
691+
-r [parameters]
692+
Restart DOSBox, either with the parameters that were used to start the
693+
current instance or any that are appended.
694+
695+
-l
696+
lists DOSBox parameters:
697+
- the configuration directory
698+
- the config files that were used when starting this session
699+
- the command line parameters DOSBox was started with
700+
701+
-h, -help, -?
702+
Displays an overvie of the config commands.
703+
704+
-h, -help, -? sections
705+
Displays the list of sections in the config file.
706+
707+
-h, -help, -? section
708+
Displays the list of properties contained in the specified section.
709+
710+
-h, -help, -? section property
711+
Shows information about the specified property in the specified section:
712+
- purpose of the property
713+
- possible values, current value, default value
714+
- wether it can definitely not be changed at runtime
715+
650716
-securemode
651717
Switches DOSBox to a more secure mode. In this mode the internal
652718
commands MOUNT, IMGMOUNT and BOOT won't work. It's not possible either
@@ -655,7 +721,6 @@ CONFIG -get "section property"
655721

656722
-set "section property=value"
657723
CONFIG will attempt to set the property to new value.
658-
Currently CONFIG can not report whether the command succeeded or not.
659724

660725
-get "section property"
661726
The current value of the property is reported and stored in the
@@ -675,7 +740,22 @@ CONFIG -get "section property"
675740
config -set "dos ems=false"
676741
4. To check which cpu core is being used.
677742
config -get "cpu core"
678-
743+
5. To view the list of possible cpu cores:
744+
config -help cpu core
745+
6. To change the machine type and restart:
746+
config -set "machine cga"
747+
config -wc -r
748+
7. To configure the autoexec section to auto-mount a directory at start:
749+
config -axadd "mount c c:\dosgames" "c:"
750+
config -wc
751+
8. To create a specific config file in the config directory:
752+
config -set "dos ems=false"
753+
config -set "cpu cycles=10000"
754+
config -set "core dynamic"
755+
config -axadd "mount c c:\dosgames" "c:" "cd my_game" "my_game"
756+
config -wc my_config.conf
757+
9. To restart DOSBox from a specific config file in the config directory:
758+
config -r -conf my_config.conf
679759

680760
LOADFIX [-size] [program] [program-parameters]
681761
LOADFIX -f
@@ -985,6 +1065,7 @@ CTRL-F10 Capture/Release the mouse.
9851065
CTRL-F11 Slow down emulation (Decrease DOSBox Cycles).
9861066
CTRL-F12 Speed up emulation (Increase DOSBox Cycles)*.
9871067
ALT-F12 Unlock speed (turbo button/fast forward)**.
1068+
CTRL-ALT-HOME Restart DOSBox.
9881069
F11, ALT-F11 (machine=cga) change tint in NTSC output modes***
9891070
F11 (machine=hercules) cycle through amber, green, white colouring***
9901071

include/control.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,14 @@ class Config{
6363
void (* _start_function)(void);
6464
bool secure_mode; //Sandbox mode
6565
public:
66-
Config(CommandLine * cmd):cmdline(cmd),secure_mode(false){}
66+
bool initialised;
67+
std::vector<std::string> startup_params;
68+
std::vector<std::string> configfiles;
69+
Config(CommandLine * cmd):cmdline(cmd),secure_mode(false) {
70+
startup_params.push_back(cmdline->GetFileName());
71+
cmdline->FillVector(startup_params);
72+
initialised=false;
73+
}
6774
~Config();
6875

6976
Section_line * AddSection_line(char const * const _name,void (*_initfunction)(Section*));

include/cross.h

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class Cross {
7474
static void CreatePlatformConfigDir(std::string& in);
7575
static void ResolveHomedir(std::string & temp_line);
7676
static void CreateDir(std::string const& temp);
77+
static bool Cross::IsPathAbsolute(std::string const& in);
7778
};
7879

7980

include/mapper.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
enum MapKeys {
2323
MK_f1,MK_f2,MK_f3,MK_f4,MK_f5,MK_f6,MK_f7,MK_f8,MK_f9,MK_f10,MK_f11,MK_f12,
24-
MK_return,MK_kpminus,MK_scrolllock,MK_printscreen,MK_pause
24+
MK_return,MK_kpminus,MK_scrolllock,MK_printscreen,MK_pause,MK_home
2525

2626
};
2727

include/programs.h

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ class CommandLine {
5252
bool FindStringBegin(char const * const begin,std::string & value, bool remove=false);
5353
bool FindStringRemain(char const * const name,std::string & value);
5454
bool GetStringRemain(std::string & value);
55+
int GetParameterFromList(const char* const params[], std::vector<std::string> & output);
56+
void FillVector(std::vector<std::string> & vector);
5557
unsigned int GetCount(void);
5658
void Shift(unsigned int amount=1);
5759
Bit16u Get_arglength();

include/setup.h

+22-18
Original file line numberDiff line numberDiff line change
@@ -104,18 +104,18 @@ class Value {
104104
operator int () const throw(WrongType);
105105
operator double () const throw(WrongType);
106106
operator char const* () const throw(WrongType);
107-
void SetValue(std::string const& in,Etype _type = V_CURRENT) throw(WrongType);
107+
bool SetValue(std::string const& in,Etype _type = V_CURRENT) throw(WrongType);
108108
std::string ToString() const;
109109

110110
private:
111111
void destroy() throw();
112112
Value& copy(Value const& in) throw(WrongType);
113113
void plaincopy(Value const& in) throw();
114-
void set_hex(std::string const& in);
115-
void set_int(std::string const&in);
116-
void set_bool(std::string const& in);
114+
bool set_hex(std::string const& in);
115+
bool set_int(std::string const&in);
116+
bool set_bool(std::string const& in);
117117
void set_string(std::string const& in);
118-
void set_double(std::string const& in);
118+
bool set_double(std::string const& in);
119119
};
120120

121121
class Property {
@@ -127,18 +127,20 @@ class Property {
127127
void Set_values(const char * const * in);
128128
void Set_help(std::string const& str);
129129
char const* Get_help();
130-
virtual void SetValue(std::string const& str)=0;
130+
virtual bool SetValue(std::string const& str)=0;
131131
Value const& GetValue() const { return value;}
132132
Value const& Get_Default_Value() const { return default_value; }
133133
//CheckValue returns true if value is in suggested_values;
134134
//Type specific properties are encouraged to override this and check for type
135135
//specific features.
136136
virtual bool CheckValue(Value const& in, bool warn);
137137
//Set interval value to in or default if in is invalid. force always sets the value.
138-
void SetVal(Value const& in, bool forced,bool warn=true) {if(forced || CheckValue(in,warn)) value = in; else value = default_value;}
138+
bool SetVal(Value const& in, bool forced,bool warn=true) {
139+
if(forced || CheckValue(in,warn)) {value = in; return true;} else { value = default_value; return false;}}
139140
virtual ~Property(){ }
140141
virtual const std::vector<Value>& GetValues() const;
141142
Value::Etype Get_type(){return default_value.type;}
143+
Changeable::Value getChange() {return change;}
142144

143145
protected:
144146
Value value;
@@ -161,8 +163,10 @@ class Prop_int:public Property {
161163
min = _min;
162164
max = _max;
163165
}
166+
int getMin() { return min;}
167+
int getMax() { return max;}
164168
void SetMinMax(Value const& min,Value const& max) {this->min = min; this->max=max;}
165-
void SetValue(std::string const& in);
169+
bool SetValue(std::string const& in);
166170
~Prop_int(){ }
167171
virtual bool CheckValue(Value const& in, bool warn);
168172
private:
@@ -175,7 +179,7 @@ class Prop_double:public Property {
175179
:Property(_propname,when){
176180
default_value = value = _value;
177181
}
178-
void SetValue(std::string const& input);
182+
bool SetValue(std::string const& input);
179183
~Prop_double(){ }
180184
};
181185

@@ -185,7 +189,7 @@ class Prop_bool:public Property {
185189
:Property(_propname,when) {
186190
default_value = value = _value;
187191
}
188-
void SetValue(std::string const& in);
192+
bool SetValue(std::string const& in);
189193
~Prop_bool(){ }
190194
};
191195

@@ -195,7 +199,7 @@ class Prop_string:public Property{
195199
:Property(_propname,when) {
196200
default_value = value = _value;
197201
}
198-
void SetValue(std::string const& in);
202+
bool SetValue(std::string const& in);
199203
virtual bool CheckValue(Value const& in, bool warn);
200204
~Prop_string(){ }
201205
};
@@ -207,7 +211,7 @@ class Prop_path:public Prop_string{
207211
default_value = value = _value;
208212
realpath = _value;
209213
}
210-
void SetValue(std::string const& in);
214+
bool SetValue(std::string const& in);
211215
~Prop_path(){ }
212216
};
213217

@@ -217,7 +221,7 @@ class Prop_hex:public Property {
217221
:Property(_propname,when) {
218222
default_value = value = _value;
219223
}
220-
void SetValue(std::string const& in);
224+
bool SetValue(std::string const& in);
221225
~Prop_hex(){ }
222226
};
223227

@@ -248,7 +252,7 @@ class Section {
248252
const char* GetName() const {return sectionname.c_str();}
249253

250254
virtual std::string GetPropValue(std::string const& _property) const =0;
251-
virtual void HandleInputline(std::string const& _line)=0;
255+
virtual bool HandleInputline(std::string const& _line)=0;
252256
virtual void PrintData(FILE* outfile) const =0;
253257
virtual ~Section() { /*Children must call executedestroy ! */}
254258
};
@@ -281,7 +285,7 @@ class Section_prop:public Section {
281285
Prop_path* Get_path(std::string const& _propname) const;
282286
Prop_multival* Get_multival(std::string const& _propname) const;
283287
Prop_multival_remain* Get_multivalremain(std::string const& _propname) const;
284-
void HandleInputline(std::string const& gegevens);
288+
bool HandleInputline(std::string const& gegevens);
285289
void PrintData(FILE* outfile) const;
286290
virtual std::string GetPropValue(std::string const& _property) const;
287291
//ExecuteDestroy should be here else the destroy functions use destroyed properties
@@ -299,7 +303,7 @@ class Prop_multival:public Property{
299303
}
300304
Section_prop *GetSection() { return section; }
301305
const Section_prop *GetSection() const { return section; }
302-
virtual void SetValue(std::string const& input);
306+
virtual bool SetValue(std::string const& input);
303307
virtual const std::vector<Value>& GetValues() const;
304308
~Prop_multival() { delete section; }
305309
}; //value bevat totale string. setvalue zet elk van de sub properties en checked die.
@@ -308,15 +312,15 @@ class Prop_multival_remain:public Prop_multival{
308312
public:
309313
Prop_multival_remain(std::string const& _propname, Changeable::Value when,std::string const& sep):Prop_multival(_propname,when,sep){ }
310314

311-
virtual void SetValue(std::string const& input);
315+
virtual bool SetValue(std::string const& input);
312316
};
313317

314318

315319
class Section_line: public Section{
316320
public:
317321
Section_line(std::string const& _sectionname):Section(_sectionname){}
318322
~Section_line(){ExecuteDestroy(true);}
319-
void HandleInputline(std::string const& gegevens);
323+
bool HandleInputline(std::string const& gegevens);
320324
void PrintData(FILE* outfile) const;
321325
virtual std::string GetPropValue(std::string const& _property) const;
322326
std::string data;

src/debug/debug.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,7 @@ void DEBUG_SetupConsole(void) {
21132113
DBGUI_StartUp();
21142114
}
21152115

2116-
static void DEBUG_ShutDown(Section * /*sec*/) {
2116+
void DEBUG_ShutDown(Section * /*sec*/) {
21172117
CBreakpoint::DeleteAll();
21182118
CDebugVar::DeleteAll();
21192119
curs_set(old_cursor_state);

src/dosbox.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ void DOSBOX_Init(void) {
340340

341341
Pstring = secprop->Add_string("machine",Property::Changeable::OnlyAtStart,"svga_s3");
342342
Pstring->Set_values(machines);
343-
Pstring->Set_help("The type of machine tries to emulate.");
343+
Pstring->Set_help("The type of machine DOSBox tries to emulate.");
344344

345345
Pstring = secprop->Add_path("captures",Property::Changeable::Always,"capture");
346346
Pstring->Set_help("Directory where things like wave, midi, screenshot get captured.");
@@ -376,8 +376,8 @@ void DOSBOX_Init(void) {
376376

377377
Pmulti = secprop->Add_multi("scaler",Property::Changeable::Always," ");
378378
Pmulti->SetValue("normal2x");
379-
Pmulti->Set_help("Scaler used to enlarge/enhance low resolution modes.\n"
380-
" If 'forced' is appended, then the scaler will be used even if the result might not be desired.");
379+
Pmulti->Set_help("Scaler used to enlarge/enhance low resolution modes. If 'forced' is appended,\n"
380+
"then the scaler will be used even if the result might not be desired.");
381381
Pstring = Pmulti->GetSection()->Add_string("type",Property::Changeable::Always,"normal2x");
382382

383383
const char *scalers[] = {
@@ -403,7 +403,8 @@ void DOSBOX_Init(void) {
403403
"normal", "simple",0 };
404404
Pstring = secprop->Add_string("core",Property::Changeable::WhenIdle,"auto");
405405
Pstring->Set_values(cores);
406-
Pstring->Set_help("CPU Core used in emulation. auto will switch to dynamic if available and appropriate.");
406+
Pstring->Set_help("CPU Core used in emulation. auto will switch to dynamic if available and\n"
407+
"appropriate.");
407408

408409
const char* cputype_values[] = { "auto", "386", "386_slow", "486_slow", "pentium_slow", "386_prefetch", 0};
409410
Pstring = secprop->Add_string("cputype",Property::Changeable::Always,"auto");
@@ -418,9 +419,10 @@ void DOSBOX_Init(void) {
418419
"Cycles can be set in 3 ways:\n"
419420
" 'auto' tries to guess what a game needs.\n"
420421
" It usually works, but can fail for certain games.\n"
421-
" 'fixed #number' will set a fixed amount of cycles. This is what you usually need if 'auto' fails.\n"
422-
" (Example: fixed 4000).\n"
423-
" 'max' will allocate as much cycles as your computer is able to handle.\n");
422+
" 'fixed #number' will set a fixed amount of cycles. This is what you usually\n"
423+
" need if 'auto' fails (Example: fixed 4000).\n"
424+
" 'max' will allocate as much cycles as your computer is able to\n"
425+
" handle.");
424426

425427
const char* cyclest[] = { "auto","fixed","max","%u",0 };
426428
Pstring = Pmulti_remain->GetSection()->Add_string("type",Property::Changeable::Always,"auto");
@@ -431,7 +433,7 @@ void DOSBOX_Init(void) {
431433

432434
Pint = secprop->Add_int("cycleup",Property::Changeable::Always,10);
433435
Pint->SetMinMax(1,1000000);
434-
Pint->Set_help("Amount of cycles to decrease/increase with keycombo.(CTRL-F11/CTRL-F12)");
436+
Pint->Set_help("Amount of cycles to decrease/increase with keycombos.(CTRL-F11/CTRL-F12)");
435437

436438
Pint = secprop->Add_int("cycledown",Property::Changeable::Always,20);
437439
Pint->SetMinMax(1,1000000);

src/gui/sdl_gui.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
extern Bit8u int10_font_14[256 * 14];
4242
extern Program * first_shell;
43-
extern void MSG_Write(const char *);
43+
extern bool MSG_Write(const char *);
4444
extern void GFX_SetTitle(Bit32s cycles, Bits frameskip, bool paused);
4545

4646
static int cursor, saved_bpp;

0 commit comments

Comments
 (0)