From c2163c8197260f0826a4710fc271c9f8019f4fe0 Mon Sep 17 00:00:00 2001 From: Will Angenent Date: Sat, 19 May 2018 11:30:30 +0100 Subject: [PATCH] Fixed multiple DOS tests not working --- .gitignore | 2 +- appleiie.go | 1 + cpu/cpu.go | 6 ++++++ dos33_boot_test.go | 12 ++++++++++-- rwts_write_test.go | 6 +++++- 5 files changed, 23 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index d00c189..9e3347a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,4 @@ cpu.prof mem.prof mos6502go.test apple2e.rom -dos33_disk.dsk +dos33.dsk diff --git a/appleiie.go b/appleiie.go index be0c76f..e7c68a3 100644 --- a/appleiie.go +++ b/appleiie.go @@ -91,6 +91,7 @@ func main() { audio.Mute = *mute audio.ClickWhenDriveHeadMoves = *clickWhenDriveHeadMoves system.Init() + cpu.SetColdStartReset() cpu.Reset() ebiten.Run(update, 280*video.ScreenSizeFactor, 192*video.ScreenSizeFactor, 2, "Apple //e") diff --git a/cpu/cpu.go b/cpu/cpu.go index ba68dbf..081ae99 100644 --- a/cpu/cpu.go +++ b/cpu/cpu.go @@ -857,6 +857,12 @@ func Run(showInstructions bool, breakAddress *uint16, exitAtBreak bool, disableF } } +func SetColdStartReset() { + // Nuke the checkum byte for the reset vector. When this is called, the apple boot firmware will + // conclude that the reset vector is invalid and do a cold start. + mmu.WriteMemory(uint16(0x3f4), uint8(0)) +} + func Reset() { bootVector := 0xfffc lsb := mmu.PageTable[bootVector>>8][bootVector&0xff] // TODO move readMemory to mmu diff --git a/dos33_boot_test.go b/dos33_boot_test.go index f8f19e0..8e367cd 100644 --- a/dos33_boot_test.go +++ b/dos33_boot_test.go @@ -14,6 +14,14 @@ import ( const dosDiskImage = "dos33.dsk" +func runDos33Boot(t *testing.T) { + // Boot up DOS3.3 + utils.RunUntilBreakPoint(t, 0x0801, 2, false, "Boot0") + utils.RunUntilBreakPoint(t, 0xb700, 2, false, "Boot1") + utils.RunUntilBreakPoint(t, 0x9d84, 2, false, "Boot2") + utils.RunUntilBreakPoint(t, 0xd7d2, 5, false, "JMP to basic interpreter NEWSTT") +} + func TestDOS33Boot(t *testing.T) { cpu.InitInstructionDecoder() mmu.InitRAM() @@ -24,12 +32,12 @@ func TestDOS33Boot(t *testing.T) { keyboard.Init() video.Init() system.Init() + cpu.SetColdStartReset() cpu.Reset() t0 := time.Now() - // Run until BASIC would execute the program. - utils.RunUntilBreakPoint(t, 0xd7d2, 5, false, "BASIC NEWSTT") + runDos33Boot(t) elapsed := float64(time.Since(t0) / time.Millisecond) fmt.Printf("CPU Cycles: %d\n", system.FrameCycles) diff --git a/rwts_write_test.go b/rwts_write_test.go index afc1e52..bfbf2c9 100644 --- a/rwts_write_test.go +++ b/rwts_write_test.go @@ -19,7 +19,7 @@ func writeBytes(address int, data []uint8) { } } -func TestDos33RtsWriteRead(t *testing.T) { +func TestDos33RwtsWriteRead(t *testing.T) { // Test writing and reading a sector using DOS 3.3's RWTS cpu.InitInstructionDecoder() mmu.InitRAM() @@ -30,9 +30,13 @@ func TestDos33RtsWriteRead(t *testing.T) { keyboard.Init() video.Init() system.Init() + cpu.SetColdStartReset() cpu.Reset() // Boot up DOS3.3 + utils.RunUntilBreakPoint(t, 0x0801, 2, false, "JMP $0801 boot0 done") + utils.RunUntilBreakPoint(t, 0xb700, 2, false, "JMP $b700 boot1 done") + utils.RunUntilBreakPoint(t, 0x9d84, 2, false, "JMP $9d84 boot2 done") utils.RunUntilBreakPoint(t, 0xd7d2, 5, false, "BASIC NEWSTT") // Write a sector from 0x2000 to track 35, sector 14