2020-10-03 21:38:26 +00:00
|
|
|
package izapple2
|
2019-11-11 21:58:42 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"image"
|
|
|
|
"image/color"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
doubleHiResWidth = 2 * hiResWidth
|
2020-08-09 14:42:16 +00:00
|
|
|
rgb160Width = 4 * 160
|
2019-11-11 21:58:42 +00:00
|
|
|
)
|
|
|
|
|
2020-08-08 11:44:45 +00:00
|
|
|
func snapshotDoubleHiResModeMono(a *Apple2, isSecondPage 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"
|
2020-08-08 11:44:45 +00:00
|
|
|
size := image.Rect(0, 0, doubleHiResWidth, hiResHeight)
|
|
|
|
img := image.NewRGBA(size)
|
2020-08-06 16:35:34 +00:00
|
|
|
|
2020-08-08 11:44:45 +00:00
|
|
|
// To support RGB-mode 14 we will have a mask to mark where we should not have the NTSC filter applied
|
2020-08-06 16:35:34 +00:00
|
|
|
// See: https://apple2online.com/web_documents/Video-7%20Manual%20KB.pdf
|
|
|
|
var ntscMask *image.Alpha
|
|
|
|
if getNTSCMask {
|
|
|
|
ntscMask = image.NewAlpha(size)
|
|
|
|
}
|
|
|
|
|
2020-08-08 11:44:45 +00:00
|
|
|
for y := 0; y < hiResHeight; y++ {
|
2019-11-11 21:58:42 +00:00
|
|
|
lineParts := [][]uint8{
|
2020-08-08 11:44:45 +00:00
|
|
|
getHiResLine(a, y, isSecondPage, true /*auxmem*/),
|
|
|
|
getHiResLine(a, y, isSecondPage, false /*auxmem*/),
|
2019-11-11 21:58:42 +00:00
|
|
|
}
|
|
|
|
x := 0
|
2020-08-08 11:44:45 +00:00
|
|
|
// For the NTSC filter to work we have to insert an initial black pixel and skip the last one ¿?
|
2019-11-11 21:58:42 +00:00
|
|
|
img.Set(x, y, color.Black)
|
2020-08-06 16:35:34 +00:00
|
|
|
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]
|
2020-08-08 11:44:45 +00:00
|
|
|
|
2020-08-06 16:35:34 +00:00
|
|
|
mask := color.Transparent // Apply the NTSC filter
|
|
|
|
if getNTSCMask && b&0x80 == 0 {
|
|
|
|
mask = color.Opaque // Do not apply the NTSC filter
|
|
|
|
}
|
2020-08-08 11:44:45 +00:00
|
|
|
|
2019-11-11 21:58:42 +00:00
|
|
|
for j := uint(0); j < 7; j++ {
|
2020-08-06 16:35:34 +00:00
|
|
|
// 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)
|
2020-08-06 16:35:34 +00:00
|
|
|
|
|
|
|
// Set mask if requested
|
|
|
|
if getNTSCMask {
|
|
|
|
ntscMask.Set(x, y, mask)
|
|
|
|
}
|
2019-11-11 21:58:42 +00:00
|
|
|
x++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-06 16:35:34 +00:00
|
|
|
return img, ntscMask
|
2019-11-11 21:58:42 +00:00
|
|
|
}
|
2020-08-09 14:42:16 +00:00
|
|
|
|
|
|
|
func snapshotDoubleHiRes160ModeMono(a *Apple2, isSecondPage bool, light color.Color) *image.RGBA {
|
|
|
|
size := image.Rect(0, 0, rgb160Width, hiResHeight)
|
|
|
|
img := image.NewRGBA(size)
|
|
|
|
|
|
|
|
for y := 0; y < hiResHeight; y++ {
|
|
|
|
lineParts := [][]uint8{
|
|
|
|
getHiResLine(a, y, isSecondPage, true /*auxmem*/),
|
|
|
|
getHiResLine(a, y, isSecondPage, false /*auxmem*/),
|
|
|
|
}
|
|
|
|
x := 0
|
|
|
|
for iByte := 0; iByte < hiResLineBytes; iByte++ {
|
|
|
|
for iPart := 0; iPart < 2; iPart++ {
|
|
|
|
b := lineParts[iPart][iByte]
|
|
|
|
for j := uint(0); j < 8; j++ {
|
|
|
|
// Set color
|
|
|
|
bit := (b >> j) & 1
|
|
|
|
colour := light
|
|
|
|
if bit == 0 {
|
|
|
|
colour = color.Black
|
|
|
|
}
|
|
|
|
img.Set(x, y, colour)
|
|
|
|
x++
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return img
|
|
|
|
}
|