mirror of
https://github.com/ivanizag/izapple2.git
synced 2024-06-03 20:29:30 +00:00
Fix mix mode 40 columns text
This commit is contained in:
parent
fddc9e2f6d
commit
442daca829
10
screen.go
10
screen.go
|
@ -194,17 +194,13 @@ func (a *Apple2) Snapshot() *image.RGBA {
|
||||||
}
|
}
|
||||||
|
|
||||||
func mixSnapshots(top, bottom *image.RGBA) *image.RGBA {
|
func mixSnapshots(top, bottom *image.RGBA) *image.RGBA {
|
||||||
topWidth := top.Bounds().Dx()
|
|
||||||
bottomWidth := bottom.Bounds().Dx()
|
bottomWidth := bottom.Bounds().Dx()
|
||||||
factor := (topWidth - 4) / (bottomWidth - 4)
|
|
||||||
|
|
||||||
// Copy bottom's bottom on top's bottom, applying the factor
|
// Copy bottom's bottom on top's bottom
|
||||||
for y := hiResHeightMixed; y < hiResHeight; y++ {
|
for y := hiResHeightMixed; y < hiResHeight; y++ {
|
||||||
for x := 0; x < topWidth; x++ {
|
for x := 0; x < bottomWidth; x++ {
|
||||||
c := bottom.At(x, y)
|
c := bottom.At(x, y)
|
||||||
for f := 0; f < factor; f++ {
|
top.Set(x, y, c)
|
||||||
top.Set(x*factor+f, y, c)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package izapple2
|
package izapple2
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
)
|
)
|
||||||
|
@ -65,6 +66,10 @@ func filterNTSCColor(in *image.RGBA, mask *image.Alpha) *image.RGBA {
|
||||||
size := image.Rect(0, 0, width+4, height)
|
size := image.Rect(0, 0, width+4, height)
|
||||||
out := image.NewRGBA(size)
|
out := image.NewRGBA(size)
|
||||||
|
|
||||||
|
if width < 2*hiResWidth {
|
||||||
|
panic(fmt.Sprintf("The image has width %v. We can't apply the NTSC filter.", width))
|
||||||
|
}
|
||||||
|
|
||||||
for y := 0; y < height; y++ {
|
for y := 0; y < height; y++ {
|
||||||
// We store the last four bits. We start with 0000
|
// We store the last four bits. We start with 0000
|
||||||
v := 0
|
v := 0
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
const (
|
const (
|
||||||
charWidth = 7
|
charWidth = 7
|
||||||
charHeight = 8
|
charHeight = 8
|
||||||
textColumns = 40
|
text40Columns = 40
|
||||||
textLines = 24
|
textLines = 24
|
||||||
|
|
||||||
textPage1Address = uint16(0x0400)
|
textPage1Address = uint16(0x0400)
|
||||||
|
@ -70,11 +70,11 @@ func getTextFromMemory(mem *memoryRange, isSecondPage bool) []uint8 {
|
||||||
addressEnd := addressStart + textPageSize
|
addressEnd := addressStart + textPageSize
|
||||||
data := mem.subRange(addressStart, addressEnd)
|
data := mem.subRange(addressStart, addressEnd)
|
||||||
|
|
||||||
text := make([]uint8, textLines*textColumns)
|
text := make([]uint8, textLines*text40Columns)
|
||||||
for l := 0; l < textLines; l++ {
|
for l := 0; l < textLines; l++ {
|
||||||
for c := 0; c < textColumns; c++ {
|
for c := 0; c < text40Columns; c++ {
|
||||||
char := data[getTextCharOffset(c, l)]
|
char := data[getTextCharOffset(c, l)]
|
||||||
text[textColumns*l+c] = char
|
text[text40Columns*l+c] = char
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return text
|
return text
|
||||||
|
@ -96,11 +96,12 @@ func renderTextMode(a *Apple2, text []uint8, colorMap []uint8, light color.Color
|
||||||
|
|
||||||
columns := len(text) / textLines
|
columns := len(text) / textLines
|
||||||
if text == nil {
|
if text == nil {
|
||||||
columns = textColumns
|
columns = text40Columns
|
||||||
}
|
}
|
||||||
width := columns * charWidth
|
width := columns * charWidth
|
||||||
height := textLines * charHeight
|
height := textLines * charHeight
|
||||||
size := image.Rect(0, 0, width, height)
|
|
||||||
|
size := image.Rect(0, 0, 2*hiResWidth, hiResHeight)
|
||||||
img := image.NewRGBA(size)
|
img := image.NewRGBA(size)
|
||||||
|
|
||||||
for x := 0; x < width; x++ {
|
for x := 0; x < width; x++ {
|
||||||
|
@ -147,9 +148,14 @@ func renderTextMode(a *Apple2, text []uint8, colorMap []uint8, light color.Color
|
||||||
colour = color.Black
|
colour = color.Black
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if columns == text40Columns {
|
||||||
|
img.Set(x*2, y, colour)
|
||||||
|
img.Set(x*2+1, y, colour)
|
||||||
|
} else {
|
||||||
img.Set(x, y, colour)
|
img.Set(x, y, colour)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user