Improved CRT sumulation. P1 phosphor green and vertical line separation.

This commit is contained in:
Ivan Izaguirre 2019-05-01 16:54:53 +02:00
parent fc3754159f
commit 9fcd499241
2 changed files with 28 additions and 4 deletions

View File

@ -19,7 +19,8 @@ func Snapshot(a *Apple2) *image.RGBA {
}
if isTextMode {
return snapshotTextMode(a, pageIndex)
//return snapshotTextMode(a, pageIndex)
return linesSeparatedFilter(snapshotTextMode(a, pageIndex))
} else {
if isHiResMode {
//return snapshotHiResModeReferenceMono(a, pageIndex)
@ -52,6 +53,22 @@ func saveSnapshot(a *Apple2) {
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 (
charWidth = 7
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 {
// 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
height := textLines * charHeight
size := image.Rect(0, 0, width, height)
@ -99,9 +120,11 @@ func snapshotTextMode(a *Apple2, page int) *image.RGBA {
colInChar := x % charWidth
char := getTextChar(a, col, line, page)
pixel := a.cg.getPixel(char, rowInChar, colInChar)
colour := color.Black
var colour color.Color
if pixel {
colour = color.White
colour = p1GreenPhosphorColor
} else {
colour = color.Black
}
img.Set(x, y, colour)
}

View File

@ -44,7 +44,8 @@ func SDLRun(a *apple2.Apple2) {
img := apple2.Snapshot(a)
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)
// Valid for little endian. Should we reverse for big endian?
// 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff)