diff --git a/apple2/apple2.go b/apple2/apple2.go index ec218b9..5e13093 100644 --- a/apple2/apple2.go +++ b/apple2/apple2.go @@ -49,17 +49,24 @@ func (a *Apple2) AddDisk2(diskRomFile string, diskImage string) { } } -// Run starts the Apple2 emulation -func (a *Apple2) Run(log bool, stdinKeyboard bool) { +// ConfigureStdConsole uses stdin and stdout to interface with the Apple2 +func (a *Apple2) ConfigureStdConsole(stdinKeyboard bool, stdoutScreen bool) { + if !stdinKeyboard && !stdoutScreen { + return + } + // Init frontend fe := newAnsiConsoleFrontend(a, stdinKeyboard) if stdinKeyboard { a.io.setKeyboardProvider(fe) } - if !log { + if stdoutScreen { go fe.textModeGoRoutine() } +} +// Run starts the Apple2 emulation +func (a *Apple2) Run(log bool) { // Start the processor a.cpu.Reset() for { diff --git a/apple2sdl/run.go b/apple2sdl/run.go index 7e821ee..d79ac1e 100644 --- a/apple2sdl/run.go +++ b/apple2sdl/run.go @@ -23,7 +23,7 @@ func SDLRun(a *apple2.Apple2) { kp := newSDLKeyBoard() a.SetKeyboardProvider(&kp) - go a.Run(false, false) + go a.Run(false) running := true for running { diff --git a/main.go b/main.go index 72bb0d6..b0360f5 100644 --- a/main.go +++ b/main.go @@ -27,10 +27,14 @@ func main() { "sdl", true, "use SDL") + stdoutScreen := flag.Bool( + "stdout", + false, + "show the text screen on the standard output") panicSS := flag.Bool( "panicss", false, - "panic if a not implemented softwtich is used") + "panic if a not implemented softswitch is used") dumpChars := flag.Bool( "dumpChars", false, @@ -56,8 +60,10 @@ func main() { a := apple2.NewApple2(*romFile, *charRomFile, *panicSS) a.AddDisk2(*disk2RomFile, *diskImage) if *useSdl { + a.ConfigureStdConsole(false, *stdoutScreen) apple2sdl.SDLRun(a) } else { - a.Run(log, true) + a.ConfigureStdConsole(true, true) + a.Run(log) } }