From 5d7701ef6764336b9fa28bde1779c783e0f79238 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sun, 15 Feb 2009 20:01:08 +0000 Subject: [PATCH] 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 --- include/setup.h | 3 ++- src/cpu/cpu.cpp | 7 ++++++- src/dosbox.cpp | 4 ++-- src/misc/setup.cpp | 25 ++++++++++++++++++++++--- 4 files changed, 32 insertions(+), 7 deletions(-) diff --git a/include/setup.h b/include/setup.h index 1a048d60..ab392b84 100644 --- a/include/setup.h +++ b/include/setup.h @@ -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{ diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp index d26a8843..871d06ea 100644 --- a/src/cpu/cpu.cpp +++ b/src/cpu/cpu.cpp @@ -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 #include @@ -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; } diff --git a/src/dosbox.cpp b/src/dosbox.cpp index 2a007b51..d872a426 100644 --- a/src/dosbox.cpp +++ b/src/dosbox.cpp @@ -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 #include @@ -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); diff --git a/src/misc/setup.cpp b/src/misc/setup.cpp index cf6c252c..2fb54478 100644 --- a/src/misc/setup.cpp +++ b/src/misc/setup.cpp @@ -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::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"); }