From 91cf87d297ccdc9f1aa14a902c8f5f517abb1903 Mon Sep 17 00:00:00 2001 From: Will Angenent Date: Mon, 14 May 2018 22:49:35 +0100 Subject: [PATCH] moved reset to a better place --- cmd/test-apple-iie-boot.go | 11 ++--------- cpu/cpu.go | 7 +++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cmd/test-apple-iie-boot.go b/cmd/test-apple-iie-boot.go index 3222dc9..49e9718 100644 --- a/cmd/test-apple-iie-boot.go +++ b/cmd/test-apple-iie-boot.go @@ -21,13 +21,6 @@ var resetKeysDown bool var fpsKeysDown bool var breakAddress *uint16 -func reset() { - bootVector := 0xfffc - lsb := mmu.PageTable[bootVector>>8][bootVector&0xff] // TODO move readMemory to mmu - msb := mmu.PageTable[(bootVector+1)>>8][(bootVector+1)&0xff] - cpu.State.PC = uint16(lsb) + uint16(msb)<<8 -} - // checkSpecialKeys checks // - ctrl-alt-R has been pressed. Releasing the R does a warm reset // - ctrl-alt-F has been pressed, toggling FPS display @@ -36,7 +29,7 @@ func checkSpecialKeys() { resetKeysDown = true } else if ebiten.IsKeyPressed(ebiten.KeyControl) && ebiten.IsKeyPressed(ebiten.KeyAlt) && !ebiten.IsKeyPressed(ebiten.KeyR) && resetKeysDown { resetKeysDown = false - reset() + cpu.Reset() } else { resetKeysDown = false @@ -97,7 +90,7 @@ func main() { audio.Mute = *mute system.Init() - reset() + 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 145439d..2e72dcb 100644 --- a/cpu/cpu.go +++ b/cpu/cpu.go @@ -852,3 +852,10 @@ func Run(showInstructions bool, breakAddress *uint16, disableFirmwareWait bool, } } } + +func Reset() { + bootVector := 0xfffc + lsb := mmu.PageTable[bootVector>>8][bootVector&0xff] // TODO move readMemory to mmu + msb := mmu.PageTable[(bootVector+1)>>8][(bootVector+1)&0xff] + State.PC = uint16(lsb) + uint16(msb)<<8 +}