diff --git a/apple2sdl/apple2sdl b/apple2sdl/apple2sdl deleted file mode 100755 index 4eaa0d3..0000000 Binary files a/apple2sdl/apple2sdl and /dev/null differ diff --git a/apple2sdl/sdlKeyboard.go b/apple2sdl/sdlKeyboard.go index 56e80d3..0591e3d 100644 --- a/apple2sdl/sdlKeyboard.go +++ b/apple2sdl/sdlKeyboard.go @@ -101,6 +101,8 @@ func (k *sdlKeyboard) putKey(keyEvent *sdl.KeyboardEvent) { k.a.SendCommand(apple2.CommandLoadState) case sdl.K_F9: k.a.SendCommand(apple2.CommandDumpDebugInfo) + case sdl.K_F12: + apple2.SaveSnapshot(k.a, "snapshot.png") } // Missing values 91 to 95. Usually control for [\]^_ diff --git a/screen.go b/screen.go index 2beac5d..2707082 100644 --- a/screen.go +++ b/screen.go @@ -95,13 +95,15 @@ func mixSnapshots(top, bottom *image.RGBA) *image.RGBA { return out } -func saveSnapshot(a *Apple2) { +// SaveSnapshot saves a snapshot of the screen to a png file +func SaveSnapshot(a *Apple2, filename string) { img := Snapshot(a) if img == nil { return } + img = squarishPixelsFilter(img) - f, err := os.Create("snapshot.png") + f, err := os.Create(filename) if err != nil { panic(err) } @@ -112,6 +114,23 @@ func saveSnapshot(a *Apple2) { png.Encode(f, img) } +func squarishPixelsFilter(in *image.RGBA) *image.RGBA { + b := in.Bounds() + factor := 1200 / b.Dx() + fmt.Println(factor) + size := image.Rect(0, 0, factor*b.Dx(), b.Dy()) + out := image.NewRGBA(size) + for x := b.Min.X; x < b.Max.X; x++ { + for y := b.Min.Y; y < b.Max.Y; y++ { + c := in.At(x, y) + for i := 0; i < factor; i++ { + out.Set(factor*x+i, y, c) + } + } + } + return out +} + func linesSeparatedFilter(in *image.RGBA) *image.RGBA { b := in.Bounds() size := image.Rect(0, 0, b.Dx(), 4*b.Dy())