mirror of
https://github.com/ivanizag/izapple2.git
synced 2024-06-15 08:29:28 +00:00
Show current speed in Mhz with Ctrl-F5
This commit is contained in:
parent
0c06a68559
commit
97efcc65c7
24
apple2.go
24
apple2.go
|
@ -27,11 +27,12 @@ type Apple2 struct {
|
|||
fastMode bool
|
||||
fastRequestsCounter int
|
||||
profile bool
|
||||
showSpeed bool
|
||||
}
|
||||
|
||||
const (
|
||||
// CpuClockMhz is the actual Apple II clock speed
|
||||
CpuClockMhz = 14.318 / 14
|
||||
// CPUClockMhz is the actual Apple II clock speed
|
||||
CPUClockMhz = 14.318 / 14
|
||||
cpuClockEuroMhz = 14.238 / 14
|
||||
)
|
||||
|
||||
|
@ -48,6 +49,8 @@ func (a *Apple2) Run() {
|
|||
// Start the processor
|
||||
a.cpu.Reset()
|
||||
referenceTime := time.Now()
|
||||
speedReferenceTime := referenceTime
|
||||
speedReferenceCycles := uint64(0)
|
||||
|
||||
for {
|
||||
// Run a 6502 step
|
||||
|
@ -81,6 +84,17 @@ func (a *Apple2) Run() {
|
|||
time.Sleep(waitDuration)
|
||||
}
|
||||
}
|
||||
|
||||
if a.showSpeed && a.cpu.GetCycles()-speedReferenceCycles > 1000000 {
|
||||
// Calculate speed in MHz every million cycles
|
||||
newTime := time.Now()
|
||||
newCycles := a.cpu.GetCycles()
|
||||
elapsedCycles := float64(newCycles - speedReferenceCycles)
|
||||
freq := 1000.0 * elapsedCycles / float64(newTime.Sub(speedReferenceTime).Nanoseconds())
|
||||
fmt.Printf("Freq: %f Mhz\n", freq)
|
||||
speedReferenceTime = newTime
|
||||
speedReferenceCycles = newCycles
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,6 +105,8 @@ func (a *Apple2) setProfile(value bool) {
|
|||
const (
|
||||
// CommandToggleSpeed toggles cpu speed between full speed and actual Apple II speed
|
||||
CommandToggleSpeed = iota + 1
|
||||
// CommandShowSpeed toggles printinf the current freq in Mhz
|
||||
CommandShowSpeed
|
||||
// CommandToggleColor toggles between NTSC color TV and Green phospor monitor
|
||||
CommandToggleColor
|
||||
// CommandSaveState stores the state to file
|
||||
|
@ -117,11 +133,13 @@ func (a *Apple2) executeCommand(command int) {
|
|||
case CommandToggleSpeed:
|
||||
if a.cycleDurationNs == 0 {
|
||||
fmt.Println("Slow")
|
||||
a.cycleDurationNs = 1000.0 / CpuClockMhz
|
||||
a.cycleDurationNs = 1000.0 / CPUClockMhz
|
||||
} else {
|
||||
fmt.Println("Fast")
|
||||
a.cycleDurationNs = 0
|
||||
}
|
||||
case CommandShowSpeed:
|
||||
a.showSpeed = !a.showSpeed
|
||||
case CommandToggleColor:
|
||||
a.isColor = !a.isColor
|
||||
case CommandSaveState:
|
||||
|
|
|
@ -23,7 +23,6 @@ func newApple2e() *Apple2 {
|
|||
a.Name = "Apple IIe"
|
||||
a.mmu = newMemoryManager(&a)
|
||||
a.cpu = core6502.NewNMOS6502(a.mmu)
|
||||
//a.cpu = core6502.NewCMOS65c02(a.mmu)
|
||||
a.io = newIoC0Page(&a)
|
||||
a.mmu.InitRAMalt()
|
||||
addApple2SoftSwitches(a.io)
|
||||
|
|
|
@ -35,7 +35,7 @@ func MainApple() *Apple2 {
|
|||
"slot for the hard drive if present. -1 for none.")
|
||||
cpuClock := flag.Float64(
|
||||
"mhz",
|
||||
CpuClockMhz,
|
||||
CPUClockMhz,
|
||||
"cpu speed in Mhz, use 0 for full speed. Use F5 to toggle.")
|
||||
charRomFile := flag.String(
|
||||
"charRom",
|
||||
|
|
|
@ -93,7 +93,11 @@ func (k *sdlKeyboard) putKey(keyEvent *sdl.KeyboardEvent) {
|
|||
|
||||
// Control of the emulator
|
||||
case sdl.K_F5:
|
||||
if ctrl {
|
||||
k.a.SendCommand(apple2.CommandShowSpeed)
|
||||
} else {
|
||||
k.a.SendCommand(apple2.CommandToggleSpeed)
|
||||
}
|
||||
case sdl.K_F6:
|
||||
k.a.SendCommand(apple2.CommandToggleColor)
|
||||
case sdl.K_F7:
|
||||
|
|
|
@ -18,7 +18,7 @@ const (
|
|||
samplingHz = 48000
|
||||
bufferSize = 10000
|
||||
// bufferSize/samplingHz will be the max delay of the sound
|
||||
sampleDurationCycles = 1000000 * apple2.CpuClockMhz / samplingHz
|
||||
sampleDurationCycles = 1000000 * apple2.CPUClockMhz / samplingHz
|
||||
// each sample on the sound stream is 21.31 cpu cycles approx
|
||||
maxOutOfSyncMs = 2000
|
||||
decayLevel = 128
|
||||
|
@ -83,7 +83,7 @@ func SpeakerCallback(userdata unsafe.Pointer, stream *C.Uint8, length C.int) {
|
|||
}
|
||||
|
||||
// Verify that we are not too long behind
|
||||
var maxOutOfSyncCyclesFloat = 1000 * apple2.CpuClockMhz * maxOutOfSyncMs
|
||||
var maxOutOfSyncCyclesFloat = 1000 * apple2.CPUClockMhz * maxOutOfSyncMs
|
||||
var maxOutOfSyncCycles = uint64(maxOutOfSyncCyclesFloat)
|
||||
for _, pc := range s.pendingClicks {
|
||||
if pc-s.lastCycle > maxOutOfSyncCycles {
|
||||
|
|
|
@ -40,8 +40,7 @@ func addApple2ESoftSwitches(io *ioC0Page) {
|
|||
}, "BSRREADRAM")
|
||||
|
||||
// TOOD:
|
||||
// AKD read on 0x10
|
||||
// VBL read on 0x19
|
||||
// VBL or VERTBLANK read on 0x19
|
||||
|
||||
//io.softSwitchesData[ioFlagAltChar] = ssOn // Not sure about this.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user