Set minimum screen refresh time as 100ms

This commit is contained in:
Ivan Izaguirre 2019-02-18 00:00:39 +01:00
parent 09da9056f9
commit 3fca4ed170
2 changed files with 16 additions and 4 deletions

View File

@ -19,7 +19,7 @@ func Run(romFile string, log bool) {
// Start the processor
core6502.Reset(&s)
t.prepare()
for true {
for {
core6502.ExecuteInstruction(&s, log)
t.dumpIfDirty()
}

View File

@ -1,9 +1,13 @@
package apple2
import "fmt"
import (
"fmt"
"time"
)
type textPages struct {
pages [4]textPage
lastDump int64
pages [4]textPage
}
type textPage struct {
@ -35,7 +39,7 @@ func textMemoryByteToStringHex(value uint8) string {
}
func (tp *textPages) prepare() {
fmt.Printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
fmt.Printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n")
}
func (tp *textPages) dump() {
@ -63,10 +67,18 @@ func (tp *textPages) dump() {
}
fmt.Println("------------------------------------------")
tp.lastDump = time.Now().UnixNano()
}
const refreshDelayMs = 100
func (tp *textPages) dumpIfDirty() {
if time.Now().UnixNano()-tp.lastDump < refreshDelayMs*1000*1000 {
// Wait more the next refresh
return
}
dirty := false
for i := 0; i < 4; i++ {
if tp.pages[i].dirty {