From 81c77c77008c4c766ae7afad5f80a21b9efeba40 Mon Sep 17 00:00:00 2001 From: Ivan Izaguirre Date: Thu, 13 Aug 2020 20:34:37 +0200 Subject: [PATCH] CPU execution with bursts --- apple2.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/apple2.go b/apple2.go index 53b6c46..4b8e01a 100644 --- a/apple2.go +++ b/apple2.go @@ -33,7 +33,10 @@ const ( cpuClockEuroMhz = 14.238 / 14 ) -const maxWaitDuration = 100 * time.Millisecond +const ( + maxWaitDuration = 100 * time.Millisecond + cpuSpinLoops = 100 +) // Run starts the Apple2 emulation func (a *Apple2) Run() { @@ -47,8 +50,10 @@ func (a *Apple2) Run() { for { // Run a 6502 step if !a.paused { - a.cpu.ExecuteInstruction() - a.executionTrace() + for i := 0; i < cpuSpinLoops; i++ { + a.cpu.ExecuteInstruction() + a.executionTrace() + } } else { time.Sleep(200 * time.Millisecond) }