From a8f22224a8bc5993a8324ea49bba11854e64a0c9 Mon Sep 17 00:00:00 2001 From: Ivan Izaguirre Date: Sat, 9 Nov 2019 00:44:13 +0100 Subject: [PATCH] Support double width low resolution --- README.md | 1 + screen.go | 7 +------ screenLoRes.go | 23 +++++++++++++++-------- 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index a099e65..3f6a9f7 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,7 @@ Portable emulator of an Apple II+. Written in Go. - Text 40 columns - text 80 columns (Apple //e only) - Low-Resolution graphics + - Double-Width Low-Resolution graphics (Apple //e only) - High-Resolution graphics - Mixed mode - Displays: diff --git a/screen.go b/screen.go index 31acf6e..8b06c63 100644 --- a/screen.go +++ b/screen.go @@ -47,12 +47,7 @@ func Snapshot(a *Apple2) *image.RGBA { if isHiResMode { snap = snapshotHiResModeMonoShift(a, pageIndex, isMixMode, lightColor) } else { - if isDoubleResMode { - //snap = snapshotLoResDoubleModeMono(a, false /*isSecondPage*/, isMixMode, lightColor) - snap = snapshotLoResModeMono(a, isSecondPage, isMixMode, lightColor) - } else { - snap = snapshotLoResModeMono(a, isSecondPage, isMixMode, lightColor) - } + snap = snapshotLoResModeMono(a, isDoubleResMode, isSecondPage, isMixMode, lightColor) } if isMixMode { diff --git a/screenLoRes.go b/screenLoRes.go index 86ca64a..bacc420 100644 --- a/screenLoRes.go +++ b/screenLoRes.go @@ -6,8 +6,9 @@ import ( ) const ( - loResPixelWidth = charWidth * 2 - loResPixelHeight = charHeight / 2 + loResPixelWidth = charWidth * 2 + doubleLoResPixelWidth = charWidth + loResPixelHeight = charHeight / 2 ) func getColorPatterns(light color.Color) [16][16]color.Color { @@ -37,14 +38,18 @@ func getColorPatterns(light color.Color) [16][16]color.Color { } -func snapshotLoResModeMono(a *Apple2, isSecondPage bool, isMixMode bool, light color.Color) *image.RGBA { - text, columns, lines := getActiveText(a, false, isSecondPage, false) +func snapshotLoResModeMono(a *Apple2, isDoubleResMode bool, isSecondPage bool, isMixMode bool, light color.Color) *image.RGBA { + text, columns, lines := getActiveText(a, isDoubleResMode, isSecondPage, false) if isMixMode { lines -= textLinesMix } grLines := lines * 2 + pixelWidth := loResPixelWidth + if isDoubleResMode { + pixelWidth = doubleLoResPixelWidth + } - size := image.Rect(0, 0, columns*loResPixelWidth, grLines*loResPixelHeight) + size := image.Rect(0, 0, columns*pixelWidth, grLines*loResPixelHeight) img := image.NewRGBA(size) patterns := getColorPatterns(light) @@ -55,10 +60,12 @@ func snapshotLoResModeMono(a *Apple2, isSecondPage bool, isMixMode bool, light c if l%2 == 0 { grPixel = char & 0xf } - offset := (c % 2) * 2 // 2 pixel offset for odd lores pixels, 0 for even pixels + // We place pixelWidth mono pixels per graphic pixel. + // The groups of 4 mono pixels need to be alligned with an offset to get plain surfaces + offset := (c * pixelWidth) % 4 - // Insert the 14 half pixels required - for i := 0; i < loResPixelWidth; i++ { + // Insert the pixelWidth pixels required + for i := 0; i < pixelWidth; i++ { v := patterns[grPixel][i+offset] // Repeat the same color for 4 lines for r := 0; r < loResPixelHeight; r++ {