mirror of
https://github.com/ivanizag/izapple2.git
synced 2025-02-08 04:30:46 +00:00
Support double width high resolution
This commit is contained in:
parent
a8f22224a8
commit
4bf8531ae4
@ -12,6 +12,7 @@ Portable emulator of an Apple II+. Written in Go.
|
|||||||
- Apple //e enhanced with 128Kb of RAM
|
- Apple //e enhanced with 128Kb of RAM
|
||||||
- Base64A clone with 48Kb of base RAM and paginated ROM
|
- Base64A clone with 48Kb of base RAM and paginated ROM
|
||||||
- Sound
|
- Sound
|
||||||
|
- Storage
|
||||||
- 16 Sector diskettes in DSK format
|
- 16 Sector diskettes in DSK format
|
||||||
- ProDos hard disk
|
- ProDos hard disk
|
||||||
- Emulated extension cards:
|
- Emulated extension cards:
|
||||||
@ -27,6 +28,7 @@ Portable emulator of an Apple II+. Written in Go.
|
|||||||
- Low-Resolution graphics
|
- Low-Resolution graphics
|
||||||
- Double-Width Low-Resolution graphics (Apple //e only)
|
- Double-Width Low-Resolution graphics (Apple //e only)
|
||||||
- High-Resolution graphics
|
- High-Resolution graphics
|
||||||
|
- Double-Width High-Resolution graphics (Apple //e only)
|
||||||
- Mixed mode
|
- Mixed mode
|
||||||
- Displays:
|
- Displays:
|
||||||
- Green monochrome monitor with half width pixel support
|
- Green monochrome monitor with half width pixel support
|
||||||
|
13
screen.go
13
screen.go
@ -22,14 +22,9 @@ func Snapshot(a *Apple2) *image.RGBA {
|
|||||||
isHiResMode := a.io.isSoftSwitchActive(ioFlagHiRes)
|
isHiResMode := a.io.isSoftSwitchActive(ioFlagHiRes)
|
||||||
isMixMode := a.io.isSoftSwitchActive(ioFlagMixed)
|
isMixMode := a.io.isSoftSwitchActive(ioFlagMixed)
|
||||||
is80Columns := a.io.isSoftSwitchActive(ioFlag80Col)
|
is80Columns := a.io.isSoftSwitchActive(ioFlag80Col)
|
||||||
isDoubleResMode := !isTextMode && is80Columns && a.io.isSoftSwitchActive(ioFlagAnnunciator3)
|
isDoubleResMode := !isTextMode && is80Columns && !a.io.isSoftSwitchActive(ioFlagAnnunciator3)
|
||||||
isSecondPage := a.io.isSoftSwitchActive(ioFlagSecondPage) && !a.mmu.store80Active
|
isSecondPage := a.io.isSoftSwitchActive(ioFlagSecondPage) && !a.mmu.store80Active
|
||||||
|
|
||||||
pageIndex := 0
|
|
||||||
if isSecondPage {
|
|
||||||
pageIndex = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
var lightColor color.Color
|
var lightColor color.Color
|
||||||
if isColor {
|
if isColor {
|
||||||
lightColor = color.White
|
lightColor = color.White
|
||||||
@ -45,7 +40,11 @@ func Snapshot(a *Apple2) *image.RGBA {
|
|||||||
snap = snapshotTextMode(a, is80Columns, isSecondPage, false /*isMixMode*/, lightColor)
|
snap = snapshotTextMode(a, is80Columns, isSecondPage, false /*isMixMode*/, lightColor)
|
||||||
} else {
|
} else {
|
||||||
if isHiResMode {
|
if isHiResMode {
|
||||||
snap = snapshotHiResModeMonoShift(a, pageIndex, isMixMode, lightColor)
|
if isDoubleResMode {
|
||||||
|
snap = snapshotDoubleHiResModeMono(a, isSecondPage, isMixMode, lightColor)
|
||||||
|
} else {
|
||||||
|
snap = snapshotHiResModeMono(a, isSecondPage, isMixMode, lightColor)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
snap = snapshotLoResModeMono(a, isDoubleResMode, isSecondPage, isMixMode, lightColor)
|
snap = snapshotLoResModeMono(a, isDoubleResMode, isSecondPage, isMixMode, lightColor)
|
||||||
}
|
}
|
||||||
|
125
screenHiRes.go
125
screenHiRes.go
@ -7,6 +7,8 @@ import (
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
hiResWidth = 280
|
hiResWidth = 280
|
||||||
|
hiResLineBytes = hiResWidth / 7
|
||||||
|
doubleHiResWidth = 2 * hiResWidth
|
||||||
hiResHeight = 192
|
hiResHeight = 192
|
||||||
hiResHeightMixed = 160
|
hiResHeightMixed = 160
|
||||||
hiResPage1Address = uint16(0x2000)
|
hiResPage1Address = uint16(0x2000)
|
||||||
@ -23,17 +25,17 @@ func getHiResLineOffset(line int) uint16 {
|
|||||||
return uint16(section*40 + outerEigth*0x80 + innerEigth*0x400)
|
return uint16(section*40 + outerEigth*0x80 + innerEigth*0x400)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getHiResLine(a *Apple2, line int, page int) []uint8 {
|
func getHiResLine(a *Apple2, line int, isSecondPage bool, auxMem bool) []uint8 {
|
||||||
address := hiResPage1Address
|
address := hiResPage1Address
|
||||||
if page == 1 {
|
if isSecondPage {
|
||||||
address = hiResPage2Address
|
address = hiResPage2Address
|
||||||
}
|
}
|
||||||
|
|
||||||
address += getHiResLineOffset(line)
|
address += getHiResLineOffset(line)
|
||||||
return a.mmu.physicalMainRAM.subRange(address, address+40)
|
return a.mmu.getPhysicalMainRAM(auxMem).subRange(address, address+hiResLineBytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
func snapshotHiResModeMonoShift(a *Apple2, page int, mixedMode bool, light color.Color) *image.RGBA {
|
func snapshotHiResModeMono(a *Apple2, isSecondPage bool, mixedMode bool, light color.Color) *image.RGBA {
|
||||||
// As described in "Undertanding the Apple II", with half pixel shifts
|
// As described in "Undertanding the Apple II", with half pixel shifts
|
||||||
|
|
||||||
height := hiResHeight
|
height := hiResHeight
|
||||||
@ -45,7 +47,7 @@ func snapshotHiResModeMonoShift(a *Apple2, page int, mixedMode bool, light color
|
|||||||
img := image.NewRGBA(size)
|
img := image.NewRGBA(size)
|
||||||
|
|
||||||
for y := 0; y < height; y++ {
|
for y := 0; y < height; y++ {
|
||||||
bytes := getHiResLine(a, y, page)
|
bytes := getHiResLine(a, y, isSecondPage, false /*auxMem*/)
|
||||||
x := 0
|
x := 0
|
||||||
var previousColour color.Color = color.Black
|
var previousColour color.Color = color.Black
|
||||||
for _, b := range bytes {
|
for _, b := range bytes {
|
||||||
@ -71,116 +73,39 @@ func snapshotHiResModeMonoShift(a *Apple2, page int, mixedMode bool, light color
|
|||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
|
|
||||||
func snapshotHiResModeReferenceColor(a *Apple2, page int, mixedMode bool) *image.RGBA {
|
func snapshotDoubleHiResModeMono(a *Apple2, isSecondPage bool, mixedMode bool, light color.Color) *image.RGBA {
|
||||||
// As defined on "Apple II Reference Manual", page 19
|
// As described in "Inside the Apple IIe"
|
||||||
|
|
||||||
height := hiResHeight
|
height := hiResHeight
|
||||||
if mixedMode {
|
if mixedMode {
|
||||||
height = hiResHeightMixed
|
height = hiResHeightMixed
|
||||||
}
|
}
|
||||||
|
|
||||||
size := image.Rect(0, 0, hiResWidth, height)
|
size := image.Rect(0, 0, doubleHiResWidth, height)
|
||||||
img := image.NewRGBA(size)
|
img := image.NewRGBA(size)
|
||||||
|
|
||||||
// RGB values from https://mrob.com/pub/xapple2/colors.html
|
|
||||||
black := color.RGBA{0, 0, 0, 255}
|
|
||||||
violet := color.RGBA{255, 68, 253, 255}
|
|
||||||
red := color.RGBA{255, 106, 60, 255}
|
|
||||||
green := color.RGBA{20, 246, 60, 255}
|
|
||||||
blue := color.RGBA{20, 207, 253, 255}
|
|
||||||
white := color.RGBA{255, 255, 255, 255}
|
|
||||||
colorMap := [][][]color.Color{
|
|
||||||
{
|
|
||||||
/* 00 */ {black, black},
|
|
||||||
/* 01 */ {black, green},
|
|
||||||
/* 10 */ {violet, black},
|
|
||||||
/* 11 */ {white, white},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
/* 00 */ {black, black},
|
|
||||||
/* 01 */ {black, red},
|
|
||||||
/* 10 */ {blue, black},
|
|
||||||
/* 11 */ {white, white},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for y := 0; y < height; y++ {
|
for y := 0; y < height; y++ {
|
||||||
bytes := getHiResLine(a, y, page)
|
lineParts := [][]uint8{
|
||||||
|
getHiResLine(a, y, isSecondPage, true),
|
||||||
|
getHiResLine(a, y, isSecondPage, false),
|
||||||
|
}
|
||||||
x := 0
|
x := 0
|
||||||
previous := uint8(0)
|
// For the NTSC filter to work we have to insert an initial black pixel and skip the last one
|
||||||
for _, b := range bytes {
|
img.Set(x, y, color.Black)
|
||||||
shift := b >> 7
|
x++
|
||||||
|
for iByte := 0; iByte < hiResLineBytes-1; iByte++ {
|
||||||
|
for iPart := 0; iPart < 2; iPart++ {
|
||||||
|
b := lineParts[iPart][iByte]
|
||||||
for j := uint(0); j < 7; j++ {
|
for j := uint(0); j < 7; j++ {
|
||||||
bit := (b >> j) & 1
|
bit := (b >> j) & 1
|
||||||
even := x%2 == 0
|
colour := light
|
||||||
if even {
|
if bit == 0 {
|
||||||
previous = bit
|
colour = color.Black
|
||||||
} else {
|
|
||||||
pair := colorMap[shift][(previous<<1)+bit]
|
|
||||||
img.Set(x-1, y, pair[0])
|
|
||||||
img.Set(x, y, pair[1])
|
|
||||||
}
|
}
|
||||||
|
img.Set(x, y, colour)
|
||||||
x++
|
x++
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return img
|
|
||||||
}
|
|
||||||
|
|
||||||
func snapshotHiResModeReferenceColorSolid(a *Apple2, page int, mixedMode bool) *image.RGBA {
|
|
||||||
// As defined on "Apple II Reference Manual", page 19
|
|
||||||
// but with more solid colors and half the resolution
|
|
||||||
|
|
||||||
height := hiResHeight
|
|
||||||
if mixedMode {
|
|
||||||
height = hiResHeightMixed
|
|
||||||
}
|
|
||||||
|
|
||||||
size := image.Rect(0, 0, hiResWidth/2, height)
|
|
||||||
img := image.NewRGBA(size)
|
|
||||||
|
|
||||||
// RGB values from https://mrob.com/pub/xapple2/colors.html
|
|
||||||
black := color.RGBA{0, 0, 0, 255}
|
|
||||||
violet := color.RGBA{255, 68, 253, 255}
|
|
||||||
red := color.RGBA{255, 106, 60, 255}
|
|
||||||
green := color.RGBA{20, 246, 60, 255}
|
|
||||||
blue := color.RGBA{20, 207, 253, 255}
|
|
||||||
white := color.RGBA{255, 255, 255, 255}
|
|
||||||
colorMap := [][]color.Color{
|
|
||||||
{
|
|
||||||
/* 00 */ black,
|
|
||||||
/* 01 */ green,
|
|
||||||
/* 10 */ violet,
|
|
||||||
/* 11 */ white,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
/* 00 */ black,
|
|
||||||
/* 01 */ red,
|
|
||||||
/* 10 */ blue,
|
|
||||||
/* 11 */ white,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
for y := 0; y < height; y++ {
|
|
||||||
bytes := getHiResLine(a, y, page)
|
|
||||||
x := 0
|
|
||||||
previous := uint8(0)
|
|
||||||
for _, b := range bytes {
|
|
||||||
shift := b >> 7
|
|
||||||
for j := uint(0); j < 7; j++ {
|
|
||||||
bit := (b >> j) & 1
|
|
||||||
even := x%2 == 0
|
|
||||||
if even {
|
|
||||||
previous = bit
|
|
||||||
} else {
|
|
||||||
colour := colorMap[shift][(previous<<1)+bit]
|
|
||||||
img.Set(x/2, y, colour)
|
|
||||||
}
|
|
||||||
x++
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ func filterNTSCColor(blacker bool, in *image.RGBA) *image.RGBA {
|
|||||||
out := image.NewRGBA(size)
|
out := image.NewRGBA(size)
|
||||||
|
|
||||||
for y := b.Min.Y; y < b.Max.Y; y++ {
|
for y := b.Min.Y; y < b.Max.Y; y++ {
|
||||||
// We store the last four bits. We start will 0000
|
// We store the last four bits. We start with 0000
|
||||||
v := 0
|
v := 0
|
||||||
for x := b.Min.X; x < b.Dx(); x++ {
|
for x := b.Min.X; x < b.Dx(); x++ {
|
||||||
cIn := in.At(x, y)
|
cIn := in.At(x, y)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user