From 90250cdf3e0431eea4ea968ee1c7a7fc195735b6 Mon Sep 17 00:00:00 2001 From: Ivan Izaguirre Date: Wed, 1 May 2019 17:59:46 +0200 Subject: [PATCH] Support for inverse and flash in text mode --- apple2/screen.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/apple2/screen.go b/apple2/screen.go index e01c372..be4f297 100644 --- a/apple2/screen.go +++ b/apple2/screen.go @@ -6,6 +6,7 @@ import ( "image/color" "image/png" "os" + "time" ) // Snapshot the currently visible screen @@ -101,12 +102,13 @@ func getTextChar(a *Apple2, col int, line int, page int) uint8 { } func snapshotTextMode(a *Apple2, page int) *image.RGBA { - // TODO: Missing inverse and flash modes - // Color for typical Apple ][ period green phosphor monitors // See: https://superuser.com/questions/361297/what-colour-is-the-dark-green-on-old-fashioned-green-screen-computer-displays p1GreenPhosphorColor := color.RGBA{65, 255, 0, 255} + // Flash mode is 2Hz + isFlashedFrame := time.Now().Nanosecond() > (1 * 1000 * 1000 * 1000 / 2) + width := textColumns * charWidth height := textLines * charHeight size := image.Rect(0, 0, width, height) @@ -119,7 +121,12 @@ func snapshotTextMode(a *Apple2, page int) *image.RGBA { rowInChar := y % charHeight colInChar := x % charWidth char := getTextChar(a, col, line, page) + topBits := char >> 6 + isInverse := topBits == 0 + isFlash := topBits == 1 + pixel := a.cg.getPixel(char, rowInChar, colInChar) + pixel = pixel != (isInverse || (isFlash && isFlashedFrame)) var colour color.Color if pixel { colour = p1GreenPhosphorColor