From 7d6493863018e6b957e102f3cf9c486f4f020588 Mon Sep 17 00:00:00 2001 From: Will Angenent Date: Wed, 9 May 2018 10:57:04 +0100 Subject: [PATCH] Added warm reset key combination using ctrl-alt-r --- cmd/test-apple-iie-boot.go | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/cmd/test-apple-iie-boot.go b/cmd/test-apple-iie-boot.go index bf35acb..bd1627f 100644 --- a/cmd/test-apple-iie-boot.go +++ b/cmd/test-apple-iie-boot.go @@ -27,8 +27,30 @@ var ( var cpuState cpu.State var showInstructions *bool var disableBell *bool +var resetKeysDown bool + +func reset() { + bootVector := 0xfffc + lsb := cpuState.PageTable[bootVector>>8][bootVector&0xff] // TODO move readMemory to mmu + msb := cpuState.PageTable[(bootVector+1)>>8][(bootVector+1)&0xff] + cpuState.PC = uint16(lsb) + uint16(msb)<<8 +} + +// checkResetKeys check ctrl-alt-R has been pressed. Releasing the R does a warm reset +func checkResetKeys() { + if ebiten.IsKeyPressed(ebiten.KeyControl) && ebiten.IsKeyPressed(ebiten.KeyAlt) && ebiten.IsKeyPressed(ebiten.KeyR) { + resetKeysDown = true + } else if ebiten.IsKeyPressed(ebiten.KeyControl) && ebiten.IsKeyPressed(ebiten.KeyAlt) && !ebiten.IsKeyPressed(ebiten.KeyR) && resetKeysDown { + resetKeysDown = false + reset() + } else { + resetKeysDown = false + } +} func update(screen *ebiten.Image) error { + checkResetKeys() + cpu.Run(&cpuState, *showInstructions, nil, *disableBell, 1024000/60) return vid.DrawTextScreen(cpuState.PageTable, screen, charMap) } @@ -45,11 +67,7 @@ func main() { cpuState.Memory = memory cpuState.PageTable = &memory.PageTable cpuState.Init() - - bootVector := 0xfffc - lsb := cpuState.PageTable[bootVector>>8][bootVector&0xff] // TODO move readMemory to mmu - msb := cpuState.PageTable[(bootVector+1)>>8][(bootVector+1)&0xff] - cpuState.PC = uint16(lsb) + uint16(msb)<<8 + reset() var err error charMap, _, err = ebitenutil.NewImageFromFile("./pr-latin1.png", ebiten.FilterNearest)