From c26b44c6867f343b01e0028dfe53851ed09e709a Mon Sep 17 00:00:00 2001 From: Will Angenent Date: Sat, 19 May 2018 10:55:41 +0100 Subject: [PATCH] Added optional click when drive head moves Very primitive but kind of entertaining. --- appleiie.go | 2 ++ audio/ebiten.go | 10 ++++++---- mmu/io.go | 3 +++ utils/utils.go | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/appleiie.go b/appleiie.go index cff9076..be0c76f 100644 --- a/appleiie.go +++ b/appleiie.go @@ -68,6 +68,7 @@ func main() { breakAddressString := flag.String("break", "", "Break on address") mute := flag.Bool("mute", false, "Mute sound") diskImage := flag.String("image", "", "Disk Image") + clickWhenDriveHeadMoves := flag.Bool("drive-head-click", false, "Click speaker when drive head moves") flag.Parse() breakAddress = utils.DecodeCmdLineAddress(breakAddressString) @@ -88,6 +89,7 @@ func main() { video.Init() audio.InitEbiten() audio.Mute = *mute + audio.ClickWhenDriveHeadMoves = *clickWhenDriveHeadMoves system.Init() cpu.Reset() diff --git a/audio/ebiten.go b/audio/ebiten.go index 9d4ea22..5c116e8 100644 --- a/audio/ebiten.go +++ b/audio/ebiten.go @@ -8,10 +8,11 @@ import ( ) var ( - audioContext *ebiten_audio.Context - player *ebiten_audio.Player - firstAudio bool - Mute bool + audioContext *ebiten_audio.Context + player *ebiten_audio.Player + firstAudio bool + Mute bool + ClickWhenDriveHeadMoves bool ) type stream struct{} @@ -62,6 +63,7 @@ func (s *stream) Close() error { func InitEbiten() { firstAudio = true Mute = false + ClickWhenDriveHeadMoves = false var err error audioContext, err = ebiten_audio.NewContext(system.AudioSampleRate) diff --git a/mmu/io.go b/mmu/io.go index 45b278f..1f3530c 100644 --- a/mmu/io.go +++ b/mmu/io.go @@ -185,6 +185,9 @@ func readWrite(address uint16, isRead bool) bool { DriveState.Phase = uint8(phase) MakeTrackData(DriveState.ArmPosition) + if audio.ClickWhenDriveHeadMoves { + audio.Click() + } } return true diff --git a/utils/utils.go b/utils/utils.go index 1f0988c..e8e7d70 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -52,6 +52,7 @@ func DecodeCmdLineAddress(s *string) (result *uint16) { func RunUntilBreakPoint(t *testing.T, breakAddress uint16, seconds int, showInstructions bool, message string) { fmt.Printf("Running until %#04x: %s \n", breakAddress, message) system.FrameCycles = 0 + system.LastAudioCycles = 0 exitAtBreak := false disableFirmwareWait := false cpu.Run(showInstructions, &breakAddress, exitAtBreak, disableFirmwareWait, uint64(system.CpuFrequency*seconds))