aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2018-10-26 16:19:50 -0700
committerH. Peter Anvin <hpa@zytor.com>2018-10-26 16:19:50 -0700
commit04ec87e861b1463c4d4888200c48c901e99c1dd2 (patch)
tree87d8d85c5da58f07e49d193019e14f0535b45fc4
parentbbc7348b06d5ec333537b7b75da5be12906c6978 (diff)
downloadabc80sim-04ec87e861b1463c4d4888200c48c901e99c1dd2.tar.gz
abc80sim-04ec87e861b1463c4d4888200c48c901e99c1dd2.tar.xz
abc80sim-04ec87e861b1463c4d4888200c48c901e99c1dd2.zip
clock.c: justera polltiden beroende på vald frekvens
Ju högre simulerad frekvens, ju fler T-states innan vi gör en event poll. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
-rw-r--r--clock.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/clock.c b/clock.c
index 3e358ff..80defd0 100644
--- a/clock.c
+++ b/clock.c
@@ -41,10 +41,18 @@ static struct abctimer *create_timer(uint64_t period, void (*func)(void))
return t;
}
+static unsigned int poll_tstate_period;
+#define MAX_TSTATE_PERIOD 512
+
void timer_init(void)
{
nstime_init();
+ /* Limit polling to once every μs simulated time */
+ poll_tstate_period = 1000*ns_per_tstate;
+ if (!limit_speed || poll_tstate_period > MAX_TSTATE_PERIOD)
+ poll_tstate_period = MAX_TSTATE_PERIOD;
+
switch (model) {
case MODEL_ABC80:
/* 20 ms = 50 Hz */
@@ -123,7 +131,7 @@ void z80_poll_external(void)
if (likely(TSTATE < next_check_tstate))
return;
- next_check_tstate += CHECK_FREQUENCY;
+ next_check_tstate = TSTATE + poll_tstate_period;
now = nstime();