mirror of
https://github.com/ivanizag/izapple2.git
synced 2024-09-27 21:56:26 +00:00
Lores mode using NTCS signal, showing artifacts
This commit is contained in:
parent
ca38abd3d7
commit
9fa6b4d1c0
@ -44,12 +44,11 @@ func Snapshot(a *Apple2) *image.RGBA {
|
|||||||
if isHiResMode {
|
if isHiResMode {
|
||||||
snap = snapshotHiResModeMonoShift(a, pageIndex, isMixMode, lightColor)
|
snap = snapshotHiResModeMonoShift(a, pageIndex, isMixMode, lightColor)
|
||||||
} else {
|
} else {
|
||||||
snap = snapshotLoResModeReferenceColor(a, pageIndex, isMixMode)
|
snap = snapshotLoResModeMonoShift(a, pageIndex, isMixMode, lightColor)
|
||||||
isColor = false
|
|
||||||
isMixMode = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if isMixMode {
|
if isMixMode {
|
||||||
snapText := snapshotTextMode(a, pageIndex, isHiResMode, lightColor)
|
snapText := snapshotTextMode(a, pageIndex, isMixMode, lightColor)
|
||||||
snap = mixSnapshots(snap, snapText)
|
snap = mixSnapshots(snap, snapText)
|
||||||
}
|
}
|
||||||
if isColor {
|
if isColor {
|
||||||
|
@ -2,6 +2,7 @@ package apple2
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
|
"image/color"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -16,6 +17,17 @@ const (
|
|||||||
loResPage2Address = textPage2Address
|
loResPage2Address = textPage2Address
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func getLoResPixel(a *Apple2, x int, y int, page int) uint8 {
|
||||||
|
// Each text mode char encodes two pixels
|
||||||
|
char := getTextChar(a, x, y/2, page)
|
||||||
|
if y%2 == 0 {
|
||||||
|
// Top pixel in char
|
||||||
|
return char & 0xf
|
||||||
|
}
|
||||||
|
// Bottom pixel in char
|
||||||
|
return char >> 4
|
||||||
|
}
|
||||||
|
|
||||||
func snapshotLoResModeReferenceColor(a *Apple2, page int, mixedMode bool) *image.RGBA {
|
func snapshotLoResModeReferenceColor(a *Apple2, page int, mixedMode bool) *image.RGBA {
|
||||||
// As defined on "Apple II Reference Manual"
|
// As defined on "Apple II Reference Manual"
|
||||||
|
|
||||||
@ -31,44 +43,41 @@ func snapshotLoResModeReferenceColor(a *Apple2, page int, mixedMode bool) *image
|
|||||||
colorMap := getNTSCColorMap()
|
colorMap := getNTSCColorMap()
|
||||||
reversedNibble := []uint8{0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}
|
reversedNibble := []uint8{0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15}
|
||||||
|
|
||||||
for y := 0; y < height; y = y + 2 {
|
for x := 0; x < loResWidth; x++ {
|
||||||
for x := 0; x < loResWidth; x++ {
|
for y := 0; y < height; y++ {
|
||||||
// Each text mode char encodes two pixels
|
v := getLoResPixel(a, x, y, page)
|
||||||
char := getTextChar(a, x, y/2, page)
|
img.Set(x, y, colorMap[reversedNibble[v]])
|
||||||
bottom := char >> 4
|
|
||||||
top := char & 0xf
|
|
||||||
img.Set(x, y, colorMap[reversedNibble[top]])
|
|
||||||
img.Set(x, y+1, colorMap[reversedNibble[bottom]])
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
func getColorPatterns(light color.Color) [16][16]color.Color {
|
||||||
func getLoResLine(a *Apple2, line int, page int) []uint8 {
|
/*
|
||||||
address := loResPage1Address
|
For each lores pixel we have to fill 14 half mono pixels with
|
||||||
if page == 1 {
|
the 4 bits of the color repeated. We will need to shift by 2 bits
|
||||||
address = loResPage2Address
|
on the odd columns. Lets prepare 14+2 values for each color.
|
||||||
}
|
*/
|
||||||
|
|
||||||
// Every text line encodes two lores lines
|
var data [16][16]color.Color
|
||||||
address += getTextCharOffset(0, line/2)
|
|
||||||
data := make([]uint8, 0, textColumns)
|
for ci := 0; ci < 16; ci++ {
|
||||||
lower := (line % 2) == 1
|
for cb := uint8(0); cb < 4; cb++ {
|
||||||
for i := uint16(0); i < textColumns; i++ {
|
bit := (ci >> cb) & 1
|
||||||
// Two pixels are encoded on each text page char position
|
var colour color.Color
|
||||||
v := a.mmu.internalPeek(address + i)
|
if bit == 0 {
|
||||||
if lower {
|
colour = color.Black
|
||||||
// The four nost significant bits store the odd lines
|
} else {
|
||||||
v >>= 4
|
colour = light
|
||||||
} else {
|
}
|
||||||
// The four least significant bits store the even lines
|
for i := uint8(0); i < 4; i++ {
|
||||||
v &= 0xf
|
data[ci][cb+4*i] = colour
|
||||||
|
}
|
||||||
}
|
}
|
||||||
data = append(data)
|
|
||||||
}
|
}
|
||||||
return data
|
return data
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func snapshotLoResModeMonoShift(a *Apple2, page int, mixedMode bool, light color.Color) *image.RGBA {
|
func snapshotLoResModeMonoShift(a *Apple2, page int, mixedMode bool, light color.Color) *image.RGBA {
|
||||||
@ -82,38 +91,21 @@ func snapshotLoResModeMonoShift(a *Apple2, page int, mixedMode bool, light color
|
|||||||
size := image.Rect(0, 0, 2*loResWidth*loResPixelWidth, height*loResPixelHeight)
|
size := image.Rect(0, 0, 2*loResWidth*loResPixelWidth, height*loResPixelHeight)
|
||||||
img := image.NewRGBA(size)
|
img := image.NewRGBA(size)
|
||||||
|
|
||||||
for y := 0; y < height; y++ {
|
patterns := getColorPatterns(light)
|
||||||
bytes := getLoResLine(a, y, page)
|
|
||||||
x := 0
|
|
||||||
for i, v := range bytes {
|
|
||||||
// For each loRes 4bit pixel we have to complete 7*2 half mono pixels
|
|
||||||
for j := 0; j < 14; i++ {
|
|
||||||
|
|
||||||
}
|
for x := 0; x < loResWidth; x++ {
|
||||||
}
|
for y := 0; y < height; y++ {
|
||||||
|
offset := (x % 2) * 2 // 2 pixel offset for odd lores pixels, 0 for even pixels
|
||||||
x := 0
|
c := getLoResPixel(a, x, y, page)
|
||||||
var previousColour color.Color = color.Black
|
// Insert the 14 half pixels required
|
||||||
for _, b := range bytes {
|
for i := 0; i < loResPixelWidth*2; i++ {
|
||||||
shifted := b>>7 == 1
|
v := patterns[c][i+offset]
|
||||||
for j := uint(0); j < 7; j++ {
|
// Repeat the same color for 4 lines
|
||||||
bit := (b >> j) & 1
|
for r := 0; r < loResPixelHeight; r++ {
|
||||||
colour := light
|
img.Set(x*loResPixelWidth*2+i, y*4+r, v)
|
||||||
if bit == 0 {
|
|
||||||
colour = color.Black
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if shifted {
|
|
||||||
img.Set(x, y, previousColour)
|
|
||||||
} else {
|
|
||||||
img.Set(x, y, colour)
|
|
||||||
}
|
|
||||||
img.Set(x+1, y, colour)
|
|
||||||
previousColour = colour
|
|
||||||
x += 2
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
Loading…
Reference in New Issue
Block a user