Cleaned up turbo handling.

This commit is contained in:
SarahW 2018-03-11 16:43:32 +00:00
commit b530bdafea
9 changed files with 54 additions and 32 deletions

View file

@ -7,6 +7,9 @@
#include "pci.h" #include "pci.h"
#include "codegen.h" #include "codegen.h"
static int cpu_turbo_speed, cpu_nonturbo_speed;
static int cpu_turbo = 1;
int isa_cycles; int isa_cycles;
int has_vlb; int has_vlb;
static uint8_t ccr0, ccr1, ccr2, ccr3, ccr4, ccr5, ccr6; static uint8_t ccr0, ccr1, ccr2, ccr3, ccr4, ccr5, ccr6;
@ -505,6 +508,14 @@ void cpu_set()
ccr0 = ccr1 = ccr2 = ccr3 = ccr4 = ccr5 = ccr6 = 0; ccr0 = ccr1 = ccr2 = ccr3 = ccr4 = ccr5 = ccr6 = 0;
has_vlb = (cpu_s->cpu_type >= CPU_i486SX) && (cpu_s->cpu_type <= CPU_Cx5x86); has_vlb = (cpu_s->cpu_type >= CPU_i486SX) && (cpu_s->cpu_type <= CPU_Cx5x86);
cpu_turbo_speed = cpu_s->rspeed;
if (cpu_s->cpu_type < CPU_286)
cpu_nonturbo_speed = 4772728;
else if (cpu_s->rspeed < 8000000)
cpu_nonturbo_speed = cpu_s->rspeed;
else
cpu_nonturbo_speed = 8000000;
cpu_update_waitstates(); cpu_update_waitstates();
isa_cycles = cpu_s->atclk_div; isa_cycles = cpu_s->atclk_div;
@ -1670,3 +1681,29 @@ void cpu_update_waitstates()
cpu_prefetch_cycles *= 4; cpu_prefetch_cycles *= 4;
cpu_mem_prefetch_cycles = cpu_prefetch_cycles; cpu_mem_prefetch_cycles = cpu_prefetch_cycles;
} }
void cpu_set_turbo(int turbo)
{
if (cpu_turbo != turbo)
{
cpu_turbo = turbo;
cpu_s = &models[model].cpu[cpu_manufacturer].cpus[cpu];
if (cpu_s->cpu_type >= CPU_286)
{
if (cpu_turbo)
setpitclock(cpu_turbo_speed);
else
setpitclock(cpu_nonturbo_speed);
}
else
setpitclock(14318184.0);
}
}
int cpu_get_speed()
{
if (cpu_turbo)
return cpu_turbo_speed;
return cpu_nonturbo_speed;
}

View file

@ -148,6 +148,8 @@ extern int isa_cycles;
void cpu_update_waitstates(); void cpu_update_waitstates();
void cpu_set(); void cpu_set();
void cpu_set_edx(); void cpu_set_edx();
void cpu_set_turbo(int turbo);
int cpu_get_speed();
extern int has_vlb; extern int has_vlb;

View file

@ -273,7 +273,6 @@ extern uint8_t opcode;
extern int insc; extern int insc;
extern int fpucount; extern int fpucount;
extern float mips,flops; extern float mips,flops;
extern int clockrate;
extern int cgate16; extern int cgate16;
extern int CPUID; extern int CPUID;

View file

@ -70,7 +70,6 @@ int cycles_lost = 0;
int config_override = 0; int config_override = 0;
int clockrate;
int insc=0; int insc=0;
float mips,flops; float mips,flops;
extern int mmuflush; extern int mmuflush;
@ -361,6 +360,7 @@ void resetpc()
{ {
cpu_set(); cpu_set();
pc_reset(); pc_reset();
cpu_set_turbo(1);
// cpuspeed2=(AT)?2:1; // cpuspeed2=(AT)?2:1;
// atfullspeed=0; // atfullspeed=0;
///* if (romset==ROM_AMI386 || romset==ROM_AMI486) */fullspeed(); ///* if (romset==ROM_AMI386 || romset==ROM_AMI486) */fullspeed();
@ -467,6 +467,7 @@ void resetpchard()
} }
sound_update_buf_length(); sound_update_buf_length();
cpu_set_turbo(1);
} }
char romsets[17][40]={"IBM PC","IBM XT","Generic Turbo XT","Euro PC","Tandy 1000","Amstrad PC1512","Sinclair PC200","Amstrad PC1640","IBM AT","AMI 286 clone","Dell System 200","Misc 286","IBM AT 386","Misc 386","386 clone","486 clone","486 clone 2"}; char romsets[17][40]={"IBM PC","IBM XT","Generic Turbo XT","Euro PC","Tandy 1000","Amstrad PC1512","Sinclair PC200","Amstrad PC1640","IBM AT","AMI 286 clone","Dell System 200","Misc 286","IBM AT 386","Misc 386","386 clone","486 clone","486 clone 2"};
@ -490,21 +491,21 @@ void runpc()
{ {
char s[200]; char s[200];
int done=0; int done=0;
int cycles_to_run = cpu_get_speed() / 100;
startblit(); startblit();
clockrate = models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed;
if (is386) if (is386)
{ {
if (cpu_use_dynarec) if (cpu_use_dynarec)
exec386_dynarec(models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed / 100); exec386_dynarec(cycles_to_run);
else else
exec386(models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed / 100); exec386(cycles_to_run);
} }
else if (AT) else if (AT)
exec386(models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed / 100); exec386(cycles_to_run);
else else
execx86(models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed / 100); execx86(cycles_to_run);
keyboard_poll_host(); keyboard_poll_host();
keyboard_process(); keyboard_process();

View file

@ -41,7 +41,7 @@ void setpitclock(float clock)
// pclog("PITCONST=%f CGACONST=%f\n", PITCONST, CGACONST); // pclog("PITCONST=%f CGACONST=%f\n", PITCONST, CGACONST);
// pclog("CPUMULTI=%g\n", ((14318184.0*(double)(1 << TIMER_SHIFT)) / (double)models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed)); // pclog("CPUMULTI=%g\n", ((14318184.0*(double)(1 << TIMER_SHIFT)) / (double)models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed));
xt_cpu_multi = (int)((14318184.0*(double)(1 << TIMER_SHIFT)) / (double)models[model].cpu[cpu_manufacturer].cpus[cpu].rspeed); xt_cpu_multi = (int)((14318184.0*(double)(1 << TIMER_SHIFT)) / (double)cpu_get_speed());
// pclog("egacycles %i egacycles2 %i temp %f clock %f\n",egacycles,egacycles2,temp,clock); // pclog("egacycles %i egacycles2 %i temp %f clock %f\n",egacycles,egacycles2,temp,clock);
/* if (video_recalctimings) /* if (video_recalctimings)
video_recalctimings();*/ video_recalctimings();*/

View file

@ -391,16 +391,9 @@ static void t1200_turbo_set(uint8_t value)
} }
t1000.turbo = value; t1000.turbo = value;
if (!value) if (!value)
{ cpu_set_turbo(0);
int c = cpu;
cpu = 0; /* 8088/4.77MHz */
cpu_set();
cpu = c;
}
else else
{ cpu_set_turbo(1);
cpu_set();
}
} }
static void write_t1000_ctl(uint16_t addr, uint8_t val, void *priv) static void write_t1000_ctl(uint16_t addr, uint8_t val, void *priv)

View file

@ -376,16 +376,9 @@ void t3100e_turbo_set(uint8_t value)
{ {
t3100e_ems.turbo = value; t3100e_ems.turbo = value;
if (!value) if (!value)
{ cpu_set_turbo(0);
int c = cpu;
cpu = 0; /* 286/6 */
cpu_set();
cpu = c;
}
else else
{ cpu_set_turbo(1);
cpu_set();
}
} }

View file

@ -145,7 +145,7 @@ int get_status(char* machine, char* device)
#endif*/ #endif*/
segareads, segareads,
segawrites, segawrites,
clockrate - scycles_lost, cpu_get_speed() - scycles_lost,
pit_timer0_freq(), pit_timer0_freq(),
((double)main_time * 100.0) / status_diff, ((double)main_time * 100.0) / status_diff,
((double)main_time * 100.0) / timer_freq, ((double)main_time * 100.0) / timer_freq,

View file

@ -29,15 +29,12 @@ void xi8088_turbo_set(uint8_t value)
if (!value) if (!value)
{ {
pclog("Xi8088 turbo off\n"); pclog("Xi8088 turbo off\n");
int c = cpu; cpu_set_turbo(0);
cpu = 0; /* 8088/4.77 */
cpu_set();
cpu = c;
} }
else else
{ {
pclog("Xi8088 turbo on\n"); pclog("Xi8088 turbo on\n");
cpu_set(); cpu_set_turbo(1);
} }
} }