diff --git a/XT.cs b/XT.cs index 40a3a4b..757e220 100644 --- a/XT.cs +++ b/XT.cs @@ -109,6 +109,11 @@ public P8086(ref Bus b, string test, TMode t_mode, uint load_test_at, bool termi _flags |= 2; } + public int GetClock() + { + return _clock; + } + public string SegmentAddr(ushort seg, ushort a) { return $"{seg:X04}:{a:X04}"; diff --git a/main.cs b/main.cs index 4f4f908..f200ebb 100644 --- a/main.cs +++ b/main.cs @@ -22,8 +22,12 @@ string key_mda = "mda"; string key_cga = "cga"; +List ide = new(); + Dictionary > > consoles = new(); +bool throttle = false; + for(int i=0; i 0) devices.Add(new FloppyDisk(floppies)); - string [] drives = new string[] { "ide.img" }; - devices.Add(new XTIDE(drives)); + if (ide.Count() > 0) + devices.Add(new XTIDE(ide)); devices.Add(new MIDI()); @@ -405,8 +415,23 @@ { try { + long prev_time = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; + int prev_clock = 0; while(p.Tick()) { + if (!throttle) + continue; + + int now_clock = p.GetClock(); + if (now_clock - prev_clock >= 4770000 / 50) + { + long now_time = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; + long diff_time = now_time - prev_time; + if (diff_time < 20) + Thread.Sleep((int)(20 - diff_time)); + prev_time = now_time; + prev_clock = now_clock; + } } } catch(Exception e)