mirror of
https://github.com/JetSetIlly/Gopher2600.git
synced 2024-06-02 20:18:20 -04:00
limit preview emulation to 1 second (in addition to the frame count limit)
This commit is contained in:
parent
91d26312a8
commit
40882a4c24
|
@ -17,8 +17,10 @@ package preview
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/jetsetilly/gopher2600/cartridgeloader"
|
||||
"github.com/jetsetilly/gopher2600/debugger/govern"
|
||||
"github.com/jetsetilly/gopher2600/environment"
|
||||
"github.com/jetsetilly/gopher2600/hardware"
|
||||
"github.com/jetsetilly/gopher2600/hardware/preferences"
|
||||
|
@ -57,8 +59,18 @@ func (em *Emulation) RunN(filename string, N int) error {
|
|||
return fmt.Errorf("preview: %w", err)
|
||||
}
|
||||
|
||||
// we don't want the preview emulation to run for too long
|
||||
timeout := time.After(1 * time.Second)
|
||||
|
||||
em.vcs.AttachCartridge(loader, true)
|
||||
err = em.vcs.RunForFrameCount(N, nil)
|
||||
err = em.vcs.RunForFrameCount(N, func(_ int) (govern.State, error) {
|
||||
select {
|
||||
case <-timeout:
|
||||
return govern.Ending, nil
|
||||
default:
|
||||
}
|
||||
return govern.Running, nil
|
||||
})
|
||||
if err != nil {
|
||||
return fmt.Errorf("preview: %w", err)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue