mirror of
https://github.com/ivanizag/izapple2.git
synced 2024-12-21 18:29:45 +00:00
Initial NTSC emulation. Color as a filter on top of monochrome with half pixels
This commit is contained in:
parent
ba6faa0203
commit
362081ff6e
@ -32,7 +32,9 @@ func Snapshot(a *Apple2) *image.RGBA {
|
||||
} else {
|
||||
if isHiResMode {
|
||||
//return snapshotHiResModeReferenceMono(a, pageIndex)
|
||||
return linesSeparatedFilter(snapshotHiResModeMonoShift(a, pageIndex))
|
||||
//return linesSeparatedFilter(snapshotHiResModeMonoShift(a, pageIndex))
|
||||
return linesSeparatedFilter(filterNTSCColor(snapshotHiResModeMonoShift(a, pageIndex)))
|
||||
|
||||
//return snapshotHiResModeReferenceColor(a, pageIndex)
|
||||
//return snapshotHiResModeReferenceColorSolid(a, pageIndex)
|
||||
} else {
|
||||
@ -78,6 +80,74 @@ func linesSeparatedFilter(in *image.RGBA) *image.RGBA {
|
||||
return out
|
||||
}
|
||||
|
||||
func filterNTSCColor(in *image.RGBA) *image.RGBA {
|
||||
// RGB values from https://mrob.com/pub/xapple2/colors.html
|
||||
black := color.RGBA{0, 0, 0, 255} /*COLOR=0 */ /* 0 0 0*/
|
||||
|
||||
dkBlue := color.RGBA{96, 78, 189, 255} /*COLOR=2 */ /* 0 60 25*/
|
||||
red := color.RGBA{227, 30, 96, 255} /*COLOR=1 */ /* 90 60 25*/
|
||||
brown := color.RGBA{96, 114, 3, 255} /*COLOR=8 */ /*180 60 25*/
|
||||
dkGreen := color.RGBA{0, 163, 96, 255} /*COLOR=4 */ /*270 60 25*/
|
||||
|
||||
grey := color.RGBA{156, 156, 156, 255} /*COLOR=10*/ /* 0 0 50*/
|
||||
purple := color.RGBA{255, 68, 253, 255} /*HCOLOR=2*/ /* 45 100 50*/
|
||||
orange := color.RGBA{255, 106, 60, 255} /*HCOLOR=5*/ /*135 100 50*/
|
||||
green := color.RGBA{20, 245, 60, 255} /*HCOLOR=1*/ /*225 100 50*/
|
||||
blue := color.RGBA{20, 207, 253, 255} /*HCOLOR=6*/ /*315 100 50*/
|
||||
|
||||
//purple := color.RGBA{255, 68, 253, 255} /*COLOR=3 */ /* 45 100 50*/
|
||||
//orange := color.RGBA{255, 106, 60, 255} /*COLOR=9 */ /*135 100 50*/
|
||||
//green := color.RGBA{20, 245, 60, 255} /*COLOR=12*/ /*225 100 50*/
|
||||
//blue := color.RGBA{20, 207, 253, 255} /*COLOR=6 */ /*315 100 50*/
|
||||
|
||||
ltBlue := color.RGBA{208, 195, 255, 255} /*COLOR=7 */ /* 0 60 75*/
|
||||
pink := color.RGBA{255, 160, 208, 255} /*COLOR=11*/ /* 90 60 75*/
|
||||
yellow := color.RGBA{208, 221, 141, 255} /*COLOR=13*/ /*180 60 75*/
|
||||
aqua := color.RGBA{114, 255, 208, 255} /*COLOR=14*/ /*270 60 75*/
|
||||
|
||||
white := color.RGBA{255, 255, 255, 255} /*COLOR=15*/ /* 0 0 100*/
|
||||
|
||||
colorMap := []color.Color{
|
||||
/* 0000 */ black,
|
||||
/* 0001 */ brown,
|
||||
/* 0010 */ dkGreen,
|
||||
/* 0011 */ green,
|
||||
/* 0100 */ dkBlue,
|
||||
/* 0101 */ grey,
|
||||
/* 0110 */ blue,
|
||||
/* 0111 */ aqua,
|
||||
/* 1000 */ red,
|
||||
/* 1001 */ orange,
|
||||
/* 1010 */ grey,
|
||||
/* 1011 */ yellow,
|
||||
/* 1100 */ purple,
|
||||
/* 1101 */ pink,
|
||||
/* 1110 */ ltBlue,
|
||||
/* 1111 */ white,
|
||||
}
|
||||
|
||||
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 += 4 {
|
||||
v := 0
|
||||
for i := 0; i < 4; i++ {
|
||||
cIn := in.At(x+i, y)
|
||||
r, _, _, _ := cIn.RGBA()
|
||||
v = v << 1
|
||||
if r != 0 {
|
||||
v++
|
||||
}
|
||||
}
|
||||
cOut := colorMap[v]
|
||||
out.Set(x/4, y, cOut)
|
||||
}
|
||||
}
|
||||
return out
|
||||
|
||||
}
|
||||
|
||||
const (
|
||||
charWidth = 7
|
||||
charHeight = 8
|
||||
@ -206,7 +276,7 @@ func snapshotHiResModeMonoShift(a *Apple2, page int) *image.RGBA {
|
||||
x := 0
|
||||
previousColour := color.Black
|
||||
for _, b := range bytes {
|
||||
shifted := b>>7 != 1
|
||||
shifted := b>>7 == 1
|
||||
for j := uint(0); j < 7; j++ {
|
||||
bit := (b >> j) & 1
|
||||
colour := color.Black
|
||||
|
Loading…
Reference in New Issue
Block a user