Improved CRT sumulation. P1 phosphor green and vertical line separation.
This commit is contained in:
parent
fc3754159f
commit
9fcd499241
|
@ -19,7 +19,8 @@ func Snapshot(a *Apple2) *image.RGBA {
|
||||||
}
|
}
|
||||||
|
|
||||||
if isTextMode {
|
if isTextMode {
|
||||||
return snapshotTextMode(a, pageIndex)
|
//return snapshotTextMode(a, pageIndex)
|
||||||
|
return linesSeparatedFilter(snapshotTextMode(a, pageIndex))
|
||||||
} else {
|
} else {
|
||||||
if isHiResMode {
|
if isHiResMode {
|
||||||
//return snapshotHiResModeReferenceMono(a, pageIndex)
|
//return snapshotHiResModeReferenceMono(a, pageIndex)
|
||||||
|
@ -52,6 +53,22 @@ func saveSnapshot(a *Apple2) {
|
||||||
png.Encode(f, img)
|
png.Encode(f, img)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func linesSeparatedFilter(in *image.RGBA) *image.RGBA {
|
||||||
|
b := in.Bounds()
|
||||||
|
size := image.Rect(0, 0, b.Dx(), 4*b.Dy())
|
||||||
|
out := image.NewRGBA(size)
|
||||||
|
for y := b.Min.Y; y < b.Max.Y; y++ {
|
||||||
|
for x := b.Min.X; x < b.Max.X; x++ {
|
||||||
|
c := in.At(x, y)
|
||||||
|
out.Set(x, 4*y, c)
|
||||||
|
out.Set(x, 4*y+1, c)
|
||||||
|
out.Set(x, 4*y+2, c)
|
||||||
|
out.Set(x, 4*y+3, color.Black)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
charWidth = 7
|
charWidth = 7
|
||||||
charHeight = 8
|
charHeight = 8
|
||||||
|
@ -86,6 +103,10 @@ func getTextChar(a *Apple2, col int, line int, page int) uint8 {
|
||||||
func snapshotTextMode(a *Apple2, page int) *image.RGBA {
|
func snapshotTextMode(a *Apple2, page int) *image.RGBA {
|
||||||
// TODO: Missing inverse and flash modes
|
// 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}
|
||||||
|
|
||||||
width := textColumns * charWidth
|
width := textColumns * charWidth
|
||||||
height := textLines * charHeight
|
height := textLines * charHeight
|
||||||
size := image.Rect(0, 0, width, height)
|
size := image.Rect(0, 0, width, height)
|
||||||
|
@ -99,9 +120,11 @@ func snapshotTextMode(a *Apple2, page int) *image.RGBA {
|
||||||
colInChar := x % charWidth
|
colInChar := x % charWidth
|
||||||
char := getTextChar(a, col, line, page)
|
char := getTextChar(a, col, line, page)
|
||||||
pixel := a.cg.getPixel(char, rowInChar, colInChar)
|
pixel := a.cg.getPixel(char, rowInChar, colInChar)
|
||||||
colour := color.Black
|
var colour color.Color
|
||||||
if pixel {
|
if pixel {
|
||||||
colour = color.White
|
colour = p1GreenPhosphorColor
|
||||||
|
} else {
|
||||||
|
colour = color.Black
|
||||||
}
|
}
|
||||||
img.Set(x, y, colour)
|
img.Set(x, y, colour)
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,8 @@ func SDLRun(a *apple2.Apple2) {
|
||||||
|
|
||||||
img := apple2.Snapshot(a)
|
img := apple2.Snapshot(a)
|
||||||
if img != nil {
|
if img != nil {
|
||||||
surface, err := sdl.CreateRGBSurfaceFrom(unsafe.Pointer(&img.Pix[0]), 40*7, 24*8, 32, 40*7*4,
|
surface, err := sdl.CreateRGBSurfaceFrom(unsafe.Pointer(&img.Pix[0]),
|
||||||
|
int32(img.Bounds().Dx()), int32(img.Bounds().Dy()), 32, 40*7*4,
|
||||||
0x0000ff, 0x0000ff00, 0x00ff0000, 0xff000000)
|
0x0000ff, 0x0000ff00, 0x00ff0000, 0xff000000)
|
||||||
// Valid for little endian. Should we reverse for big endian?
|
// Valid for little endian. Should we reverse for big endian?
|
||||||
// 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff)
|
// 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff)
|
||||||
|
|
Loading…
Reference in New Issue