apple2-go/dos33_boot_test.go
2018-05-16 10:39:53 +01:00

49 lines
1.0 KiB
Go

package main
import (
"fmt"
"mos6502go/cpu"
"mos6502go/keyboard"
"mos6502go/mmu"
"mos6502go/system"
"mos6502go/video"
"testing"
"time"
)
const DiskImage = "dos33_disk.dsk"
func TestDOS33Boot(t *testing.T) {
cpu.InitInstructionDecoder()
mmu.InitRAM()
mmu.InitApple2eROM()
mmu.InitIO()
mmu.ReadDiskImage(DiskImage)
cpu.Init()
keyboard.Init()
video.Init()
system.Init()
cpu.Reset()
system.FrameCycles = 0
system.LastAudioCycles = 0
showInstructions := false
disableFirmwareWait := false
// Break at the BASIC interpreter to ensure DOS has started
breakAddress := uint16(0xa503)
exitAtBreak := false
t0 := time.Now()
cpu.Run(showInstructions, &breakAddress, exitAtBreak, disableFirmwareWait, system.CpuFrequency*7)
if cpu.State.PC != 0xa503 {
t.Fatal("Did not reach BASIC entrypoint")
}
elapsed := float64(time.Since(t0) / time.Millisecond)
fmt.Printf("CPU Cycles: %d\n", system.FrameCycles)
fmt.Printf("Time elapsed: %0.2f ms\n", elapsed)
fmt.Printf("Speed: %0.2f cycles/ms\n", float64(system.FrameCycles)/elapsed)
}