izapple2/screenDoubleHiRes.go

67 lines
1.6 KiB
Go
Raw Normal View History

2019-11-11 21:58:42 +00:00
package apple2
import (
"image"
"image/color"
)
const (
doubleHiResWidth = 2 * hiResWidth
)
func snapshotDoubleHiResModeMono(a *Apple2, isSecondPage bool, mixedMode bool, getNTSCMask bool, light color.Color) (*image.RGBA, *image.Alpha) {
2019-11-11 21:58:42 +00:00
// As described in "Inside the Apple IIe"
height := hiResHeight
if mixedMode {
height = hiResHeightMixed
}
size := image.Rect(0, 0, doubleHiResWidth, height)
// To support RGB-mode14 we will have a mask to mark where we should not have the NTSC filter applied
// See: https://apple2online.com/web_documents/Video-7%20Manual%20KB.pdf
var ntscMask *image.Alpha
if getNTSCMask {
ntscMask = image.NewAlpha(size)
}
2019-11-11 21:58:42 +00:00
img := image.NewRGBA(size)
for y := 0; y < height; y++ {
lineParts := [][]uint8{
getHiResLine(a, y, isSecondPage, true),
getHiResLine(a, y, isSecondPage, false),
}
x := 0
// For the NTSC filter to work we have to insert an initial black pixel and skip the last one
img.Set(x, y, color.Black)
if getNTSCMask {
ntscMask.Set(x, y, color.Opaque)
}
2019-11-11 21:58:42 +00:00
x++
2019-11-22 22:25:37 +00:00
for iByte := 0; iByte < hiResLineBytes; iByte++ {
2019-11-11 21:58:42 +00:00
for iPart := 0; iPart < 2; iPart++ {
b := lineParts[iPart][iByte]
mask := color.Transparent // Apply the NTSC filter
if getNTSCMask && b&0x80 == 0 {
mask = color.Opaque // Do not apply the NTSC filter
}
2019-11-11 21:58:42 +00:00
for j := uint(0); j < 7; j++ {
// Set color
2019-11-11 21:58:42 +00:00
bit := (b >> j) & 1
colour := light
if bit == 0 {
colour = color.Black
}
img.Set(x, y, colour)
// Set mask if requested
if getNTSCMask {
ntscMask.Set(x, y, mask)
}
2019-11-11 21:58:42 +00:00
x++
}
}
}
}
return img, ntscMask
2019-11-11 21:58:42 +00:00
}