From cee7042faa2b879d5ce127912c40d57442c9bc66 Mon Sep 17 00:00:00 2001 From: Zellyn Hunter Date: Sun, 18 Sep 2016 23:27:16 -0400 Subject: [PATCH] texty: add -quit flag to control exit after binary --- texty/texty.go | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/texty/texty.go b/texty/texty.go index 54503f1..f0a8234 100644 --- a/texty/texty.go +++ b/texty/texty.go @@ -85,7 +85,7 @@ func (p TextPlotter) OncePerFrame() { // add a PCAction to quit if address 0 is called, clear the screen, // call 0x6000, call 0, and dump the screen contents (minus trailing // whitespace). -func RunEmulator(file string) error { +func RunEmulator(file string, quit bool) error { var options []goapple2.Option if file != "" { ColorFG = termbox.ColorDefault @@ -97,7 +97,7 @@ func RunEmulator(file string) error { options = append(options, goapple2.WithRAM(0x6000, bytes)) } rom := util.ReadRomOrDie("../data/roms/apple2+.rom", 12288) - var charRom [2048]byte + charRom := util.ReadSmallCharacterRomOrDie("../data/roms/apple2-chars.rom") plotter := TextPlotter(0) a2 := goapple2.NewApple2(plotter, rom, charRom, options...) if err := termbox.Init(); err != nil { @@ -114,9 +114,14 @@ func RunEmulator(file string) error { } go func() { if file != "" { - for _, ch := range "HOME:CALL 24576:CALL 0" { + for _, ch := range "HOME:CALL 24576" { a2.Keypress(byte(ch)) } + if quit { + for _, ch := range ":CALL 0" { + a2.Keypress(byte(ch)) + } + } a2.Keypress(13) } for { @@ -154,10 +159,11 @@ func dumpscreen(a2 *goapple2.Apple2) { } var binfile = flag.String("binfile", "", "binary file to load at $6000 and CALL") +var quit = flag.Bool("quit", false, "quit after running binary") func main() { flag.Parse() - if err := RunEmulator(*binfile); err != nil { + if err := RunEmulator(*binfile, *quit); err != nil { fmt.Fprintln(os.Stderr, err) os.Exit(1) }