1
0
Fork 0

add automatic core selection;

switch back to default cycles/core on program exit


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2663
This commit is contained in:
Sebastian Strohhäcker 2006-06-29 09:10:10 +00:00
parent 930207e209
commit 8dd057d52e
4 changed files with 58 additions and 19 deletions

View file

@ -29,12 +29,19 @@
#include "mem.h"
#endif
#define CPU_AUTODETERMINE_NONE 0x00
#define CPU_AUTODETERMINE_CORE 0x01
#define CPU_AUTODETERMINE_CYCLES 0x02
#define CPU_AUTODETERMINE_SHIFT 0x02
#define CPU_AUTODETERMINE_MASK 0x03
/* CPU Cycle Timing */
extern Bits CPU_Cycles;
extern Bits CPU_CycleLeft;
extern Bits CPU_CycleMax;
extern bool CPU_CycleAutoAdjust;
extern bool CPU_AutoDetermineMode;
extern Bitu CPU_AutoDetermineMode;
/* Some common Defines */
/* A CPU Handler */

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: cpu.cpp,v 1.82 2006-06-25 18:49:32 c2woody Exp $ */
/* $Id: cpu.cpp,v 1.83 2006-06-29 09:10:09 c2woody Exp $ */
#include <assert.h>
#include "dosbox.h"
@ -47,7 +47,7 @@ Bits CPU_CycleUp = 0;
Bits CPU_CycleDown = 0;
CPU_Decoder * cpudecoder;
bool CPU_CycleAutoAdjust;
bool CPU_AutoDetermineMode;
Bitu CPU_AutoDetermineMode;
void CPU_Core_Full_Init(void);
void CPU_Core_Normal_Init(void);
@ -1441,17 +1441,21 @@ void CPU_SET_CRX(Bitu cr,Bitu value) {
LOG(LOG_CPU,LOG_NORMAL)("Protected mode");
PAGING_Enable((value & CR0_PAGING)>0);
if (!CPU_AutoDetermineMode) break;
if (!(CPU_AutoDetermineMode&CPU_AUTODETERMINE_MASK)) break;
CPU_AutoDetermineMode=false;
CPU_CycleAutoAdjust=true;
CPU_CycleLeft=0;
CPU_Cycles=0;
CPU_CycleMax=0;
/* #if (C_DYNAMIC_X86)
CPU_Core_Dyn_X86_Cache_Init(true);
cpudecoder=&CPU_Core_Dyn_X86_Run;
#endif */
if (CPU_AutoDetermineMode&CPU_AUTODETERMINE_CYCLES) {
CPU_CycleAutoAdjust=true;
CPU_CycleLeft=0;
CPU_Cycles=0;
CPU_CycleMax=0;
}
#if (C_DYNAMIC_X86)
if (CPU_AutoDetermineMode&CPU_AUTODETERMINE_CORE) {
CPU_Core_Dyn_X86_Cache_Init(true);
cpudecoder=&CPU_Core_Dyn_X86_Run;
}
#endif
CPU_AutoDetermineMode<<=CPU_AUTODETERMINE_SHIFT;
GFX_SetTitle(-1,-1,false);
} else {
cpu.pmode=false;
@ -1989,16 +1993,20 @@ public:
}
bool Change_Config(Section* newconfig){
Section_prop * section=static_cast<Section_prop *>(newconfig);
CPU_AutoDetermineMode=CPU_AUTODETERMINE_NONE;
CPU_CycleLeft=0;//needed ?
CPU_Cycles=0;
const char *cyclesLine = section->Get_string("cycles");
CPU_AutoDetermineMode=false;
if (!strcasecmp(cyclesLine,"max")) {
CPU_CycleMax=0;
CPU_CycleAutoAdjust=true;
} else {
if (!strcasecmp(cyclesLine,"auto")) CPU_AutoDetermineMode=true;
CPU_CycleMax=atoi(cyclesLine);
if (!strcasecmp(cyclesLine,"auto")) {
CPU_AutoDetermineMode|=CPU_AUTODETERMINE_CYCLES;
CPU_CycleMax=3000;
} else {
CPU_CycleMax=atoi(cyclesLine);
}
CPU_CycleAutoAdjust=false;
}
CPU_CycleUp=section->Get_int("cycleup");
@ -2015,6 +2023,9 @@ public:
#if (C_DYNAMIC_X86)
else if (!strcasecmp(core,"dynamic")) {
cpudecoder=&CPU_Core_Dyn_X86_Run;
} else if (!strcasecmp(core,"auto")) {
cpudecoder=&CPU_Core_Normal_Run;
CPU_AutoDetermineMode|=CPU_AUTODETERMINE_CORE;
}
#endif
else {

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dos_execute.cpp,v 1.55 2006-04-08 11:25:41 qbix79 Exp $ */
/* $Id: dos_execute.cpp,v 1.56 2006-06-29 09:10:09 c2woody Exp $ */
#include <string.h>
#include <ctype.h>
@ -26,6 +26,7 @@
#include "regs.h"
#include "callback.h"
#include "debug.h"
#include "cpu.h"
const char * RunningProgram="DOSBOX";
@ -137,6 +138,25 @@ bool DOS_Terminate(bool tsr) {
// Free memory owned by process
if (!tsr) DOS_FreeProcessMemory(mempsp);
DOS_UpdatePSPName();
if ((!(CPU_AutoDetermineMode>>CPU_AUTODETERMINE_SHIFT)) || (cpu.pmode)) return true;
CPU_AutoDetermineMode>>=CPU_AUTODETERMINE_SHIFT;
if (CPU_AutoDetermineMode&CPU_AUTODETERMINE_CYCLES) {
CPU_CycleAutoAdjust=false;
CPU_CycleLeft=0;
CPU_Cycles=0;
CPU_CycleMax=3000;
}
#if (C_DYNAMIC_X86)
if (CPU_AutoDetermineMode&CPU_AUTODETERMINE_CORE) {
cpudecoder=&CPU_Core_Normal_Run;
CPU_CycleLeft=0;
CPU_Cycles=0;
}
#endif
GFX_SetTitle(-1,-1,false);
return true;
}

View file

@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* $Id: dosbox.cpp,v 1.100 2006-06-25 18:49:32 c2woody Exp $ */
/* $Id: dosbox.cpp,v 1.101 2006-06-29 09:10:10 c2woody Exp $ */
#include <stdlib.h>
#include <stdarg.h>
@ -282,7 +282,8 @@ void DOSBOX_Init(void) {
MSG_Add("CPU_CONFIGFILE_HELP",
"core -- CPU Core used in emulation: simple,normal,full"
#if (C_DYNAMIC_X86)
",dynamic"
",dynamic,auto.\n"
" auto switches from normal to dynamic if appropriate"
#endif
".\n"
"cycles -- Amount of instructions dosbox tries to emulate each millisecond.\n"