1
0
Fork 0

Add cycles=number support. Based on patch of h-a-l-9000, but slightly better. Beautify the configfile a bit.(Beta2)

Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3304
This commit is contained in:
Peter Veenstra 2009-02-15 20:01:08 +00:00
parent e639014e95
commit 5d7701ef67
4 changed files with 32 additions and 7 deletions

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: setup.h,v 1.39 2009-02-01 14:11:45 qbix79 Exp $ */
/* $Id: setup.h,v 1.40 2009-02-15 20:01:08 qbix79 Exp $ */
#ifndef DOSBOX_SETUP_H
#define DOSBOX_SETUP_H
@ -191,6 +191,7 @@ public:
default_value = value = _value;
}
void SetValue(std::string const& in);
virtual bool CheckValue(Value const& in, bool warn);
~Prop_string(){ }
};
class Prop_path:public Prop_string{

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: cpu.cpp,v 1.114 2009-02-01 14:24:36 qbix79 Exp $ */
/* $Id: cpu.cpp,v 1.115 2009-02-15 20:01:08 qbix79 Exp $ */
#include <assert.h>
#include <sstream>
@ -2281,6 +2281,11 @@ public:
std::istringstream stream(str);
stream >> rmdval;
CPU_CycleMax=(Bit32s)rmdval;
} else {
std::istringstream stream(type);
int rmdval=0;
stream >> rmdval;
if(rmdval) CPU_CycleMax=(Bit32s)rmdval;
}
CPU_CycleAutoAdjust=false;
}

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dosbox.cpp,v 1.145 2009-02-03 19:20:30 harekiet Exp $ */
/* $Id: dosbox.cpp,v 1.146 2009-02-15 20:01:08 qbix79 Exp $ */
#include <stdlib.h>
#include <stdarg.h>
@ -411,7 +411,7 @@ void DOSBOX_Init(void) {
" (Example: fixed 4000)\n"
" 'max' will allocate as much cycles as your computer is able to handle\n");
const char* cyclest[] = { "auto","fixed","max",0 };
const char* cyclest[] = { "auto","fixed","max","%u",0 };
Pstring = Pmulti_remain->GetSection()->Add_string("type",Property::Changeable::Always,"auto");
Pmulti_remain->SetValue("auto");
Pstring->Set_values(cyclest);

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: setup.cpp,v 1.53 2009-02-01 15:52:25 qbix79 Exp $ */
/* $Id: setup.cpp,v 1.54 2009-02-15 20:01:08 qbix79 Exp $ */
#include "dosbox.h"
#include "cross.h"
@ -264,6 +264,22 @@ void Prop_string::SetValue(std::string const& input){
Value val(temp,Value::V_STRING);
SetVal(val,false,true);
}
bool Prop_string::CheckValue(Value const& in, bool warn){
if(suggested_values.empty()) return true;
for(iter it = suggested_values.begin();it != suggested_values.end();it++) {
if ( (*it) == in) { //Match!
return true;
}
if((*it).ToString() == "%u") {
Bitu value;
if(sscanf(in.ToString().c_str(),"%u",&value) == 1) {
return true;
}
}
}
if(warn) LOG_MSG("\"%s\" is not a valid value for variable: %s.\nIt might now be reset it to default value: %s",in.ToString().c_str(),propname.c_str(),default_value.ToString().c_str());
return false;
}
void Prop_path::SetValue(std::string const& input){
//Special version to merge realpath with it
@ -632,10 +648,13 @@ bool Config::PrintConfig(char const * const configfilename) const {
fprintf(outfile, "%s%s:", prefix, MSG_Get("CONFIG_SUGGESTED_VALUES"));
std::vector<Value>::iterator it = values.begin();
while (it != values.end()) {
if (it != values.begin()) fputs(",", outfile);
fprintf(outfile, " %s", (*it).ToString().c_str());
if((*it).ToString() != "%u") { //Hack hack hack. else we need to modify GetValues, but that one is const...
if (it != values.begin()) fputs(",", outfile);
fprintf(outfile, " %s", (*it).ToString().c_str());
}
++it;
}
fprintf(outfile,".");
}
fprintf(outfile, "\n");
}