From 6a16c109af9a0012f8af980015075d9d7be3ce09 Mon Sep 17 00:00:00 2001 From: Sjoerd van der Berg Date: Sun, 17 Nov 2002 08:39:57 +0000 Subject: [PATCH] New variables for the timing code and some general clean up. Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@506 --- src/cpu/cpu.cpp | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/cpu/cpu.cpp b/src/cpu/cpu.cpp index 62704f92..18f2a313 100644 --- a/src/cpu/cpu.cpp +++ b/src/cpu/cpu.cpp @@ -30,21 +30,24 @@ Flag_Info flags; CPU_Regs cpu_regs; Segment Segs[6]; -Bitu cpu_cycles; + +Bits CPU_Cycles=0; +Bits CPU_CycleLeft=0; +Bits CPU_CycleMax=1500; CPU_Decoder * cpudecoder; static void CPU_CycleIncrease(void) { - Bitu old_cycles=cpu_cycles; - cpu_cycles=(Bitu)(cpu_cycles*1.2); - if (cpu_cycles==old_cycles) cpu_cycles++; - LOG_MSG("CPU:%d cycles",cpu_cycles); + Bitu old_cycles=CPU_CycleMax; + CPU_CycleMax=(Bitu)(CPU_CycleMax*1.2); + if (CPU_CycleMax==old_cycles) CPU_CycleMax++; + LOG_MSG("CPU:%d cycles",CPU_CycleMax); } static void CPU_CycleDecrease(void) { - cpu_cycles=(Bitu)(cpu_cycles/1.2); - if (!cpu_cycles) cpu_cycles=1; - LOG_MSG("CPU:%d cycles",cpu_cycles); + CPU_CycleMax=(Bitu)(CPU_CycleMax/1.2); + if (!CPU_CycleMax) CPU_CycleMax=1; + LOG_MSG("CPU:%d cycles",CPU_CycleMax); } Bit8u lastint; @@ -67,10 +70,10 @@ void Interrupt(Bit8u num) { case 0x11: case 0x12: case 0x13: - case 0x16: case 0x15: - case 0x1A: + case 0x16: case 0x17: + case 0x1A: case 0x1C: case 0x21: case 0x2a: @@ -167,13 +170,15 @@ void CPU_Init(Section* sec) { flags.io=0; SetCPU16bit(); - cpu_cycles=section->Get_int("cycles"); - if (!cpu_cycles) cpu_cycles=300; + KEYBOARD_AddEvent(KBD_f11,CTRL_PRESSED,CPU_CycleDecrease); KEYBOARD_AddEvent(KBD_f12,CTRL_PRESSED,CPU_CycleIncrease); - reg_al=0; - reg_ah=0; - MSG_Add("CPU_CONFIGFILE_HELP","The amount of cycles to execute each loop. Lowering this setting will slowdown dosbox\n"); + CPU_Cycles=0; + CPU_CycleMax=section->Get_int("cycles");; + if (!CPU_CycleMax) CPU_CycleMax=1500; + CPU_CycleLeft=0; + + MSG_Add("CPU_CONFIGFILE_HELP","The amount of cycles to execute each loop. Lowering this setting will slowdown dosbox\n"); }