mirror of
https://github.com/irmen/ksim65.git
synced 2024-06-26 02:29:38 +00:00
c64 screen aspect ratio correction
This commit is contained in:
parent
67a3131ce5
commit
0a9e8b293d
|
@ -21,7 +21,8 @@ object ScreenDefs {
|
||||||
const val SCREEN_HEIGHT_CHARS = 25
|
const val SCREEN_HEIGHT_CHARS = 25
|
||||||
const val SCREEN_WIDTH = SCREEN_WIDTH_CHARS*8
|
const val SCREEN_WIDTH = SCREEN_WIDTH_CHARS*8
|
||||||
const val SCREEN_HEIGHT = SCREEN_HEIGHT_CHARS*8
|
const val SCREEN_HEIGHT = SCREEN_HEIGHT_CHARS*8
|
||||||
const val DISPLAY_PIXEL_SCALING: Double = 3.0
|
const val PIXEL_SCALING = 3.0
|
||||||
|
const val ASPECT_RATIO = 1.06 // c64 PAL pixels are slightly taller than wide
|
||||||
const val BORDER_SIZE = 24
|
const val BORDER_SIZE = 24
|
||||||
|
|
||||||
class Palette {
|
class Palette {
|
||||||
|
|
|
@ -28,8 +28,8 @@ internal class Screen(private val chargenData: ByteArray, val ram: MemoryCompone
|
||||||
ScreenDefs.SCREEN_HEIGHT+2*ScreenDefs.BORDER_SIZE, Transparency.OPAQUE)
|
ScreenDefs.SCREEN_HEIGHT+2*ScreenDefs.BORDER_SIZE, Transparency.OPAQUE)
|
||||||
fullscreenG2d = fullscreenImage.graphics as Graphics2D
|
fullscreenG2d = fullscreenImage.graphics as Graphics2D
|
||||||
|
|
||||||
val size = Dimension(fullscreenImage.width*ScreenDefs.DISPLAY_PIXEL_SCALING.toInt(),
|
val size = Dimension(fullscreenImage.width*ScreenDefs.PIXEL_SCALING.toInt(),
|
||||||
fullscreenImage.height*ScreenDefs.DISPLAY_PIXEL_SCALING.toInt())
|
(fullscreenImage.height*ScreenDefs.ASPECT_RATIO*ScreenDefs.PIXEL_SCALING).toInt())
|
||||||
minimumSize = size
|
minimumSize = size
|
||||||
maximumSize = size
|
maximumSize = size
|
||||||
preferredSize = size
|
preferredSize = size
|
||||||
|
@ -84,13 +84,13 @@ internal class Screen(private val chargenData: ByteArray, val ram: MemoryCompone
|
||||||
|
|
||||||
// scale and draw the image to the window, and simulate a slight scanline effect
|
// scale and draw the image to the window, and simulate a slight scanline effect
|
||||||
windowG2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
|
windowG2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
|
||||||
windowG2d.drawImage(fullscreenImage, 0, 0, (fullscreenImage.width*ScreenDefs.DISPLAY_PIXEL_SCALING).toInt(),
|
windowG2d.drawImage(fullscreenImage, 0, 0, (fullscreenImage.width*ScreenDefs.PIXEL_SCALING).toInt(),
|
||||||
(fullscreenImage.height*ScreenDefs.DISPLAY_PIXEL_SCALING).toInt(), null)
|
(fullscreenImage.height*ScreenDefs.ASPECT_RATIO*ScreenDefs.PIXEL_SCALING).toInt(), null)
|
||||||
windowG2d.color = Color(0, 0, 0, 40)
|
windowG2d.color = Color(0, 0, 0, 40)
|
||||||
windowG2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
|
windowG2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
|
||||||
val width = fullscreenImage.width*ScreenDefs.DISPLAY_PIXEL_SCALING.toInt()
|
val width = fullscreenImage.width*ScreenDefs.PIXEL_SCALING.toInt()
|
||||||
val height = fullscreenImage.height*ScreenDefs.DISPLAY_PIXEL_SCALING.toInt()
|
val height = (fullscreenImage.height*ScreenDefs.ASPECT_RATIO*ScreenDefs.PIXEL_SCALING).toInt()
|
||||||
for (y in 0 until height step ScreenDefs.DISPLAY_PIXEL_SCALING.toInt()) {
|
for (y in 0 until height step (ScreenDefs.ASPECT_RATIO*ScreenDefs.PIXEL_SCALING).toInt()) {
|
||||||
windowG2d.drawLine(0, y, width, y)
|
windowG2d.drawLine(0, y, width, y)
|
||||||
}
|
}
|
||||||
Toolkit.getDefaultToolkit().sync()
|
Toolkit.getDefaultToolkit().sync()
|
||||||
|
|
|
@ -19,7 +19,7 @@ object ScreenDefs {
|
||||||
const val SCREEN_HEIGHT_CHARS = 30
|
const val SCREEN_HEIGHT_CHARS = 30
|
||||||
const val SCREEN_WIDTH = SCREEN_WIDTH_CHARS*8
|
const val SCREEN_WIDTH = SCREEN_WIDTH_CHARS*8
|
||||||
const val SCREEN_HEIGHT = SCREEN_HEIGHT_CHARS*16
|
const val SCREEN_HEIGHT = SCREEN_HEIGHT_CHARS*16
|
||||||
const val DISPLAY_PIXEL_SCALING: Double = 1.5
|
const val PIXEL_SCALING = 1.5
|
||||||
const val BORDER_SIZE = 32
|
const val BORDER_SIZE = 32
|
||||||
|
|
||||||
val BG_COLOR = Color(0, 10, 20)
|
val BG_COLOR = Color(0, 10, 20)
|
||||||
|
@ -68,8 +68,8 @@ private class BitmapScreenPanel : JPanel() {
|
||||||
image = gd.createCompatibleImage(ScreenDefs.SCREEN_WIDTH, ScreenDefs.SCREEN_HEIGHT, Transparency.OPAQUE)
|
image = gd.createCompatibleImage(ScreenDefs.SCREEN_WIDTH, ScreenDefs.SCREEN_HEIGHT, Transparency.OPAQUE)
|
||||||
g2d = image.graphics as Graphics2D
|
g2d = image.graphics as Graphics2D
|
||||||
|
|
||||||
val size = Dimension((image.width*ScreenDefs.DISPLAY_PIXEL_SCALING).toInt(),
|
val size = Dimension((image.width*ScreenDefs.PIXEL_SCALING).toInt(),
|
||||||
(image.height*ScreenDefs.DISPLAY_PIXEL_SCALING).toInt())
|
(image.height*ScreenDefs.PIXEL_SCALING).toInt())
|
||||||
minimumSize = size
|
minimumSize = size
|
||||||
maximumSize = size
|
maximumSize = size
|
||||||
preferredSize = size
|
preferredSize = size
|
||||||
|
@ -82,13 +82,13 @@ private class BitmapScreenPanel : JPanel() {
|
||||||
override fun paint(graphics: Graphics) {
|
override fun paint(graphics: Graphics) {
|
||||||
val g2d = graphics as Graphics2D
|
val g2d = graphics as Graphics2D
|
||||||
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
|
g2d.setRenderingHint(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BILINEAR)
|
||||||
g2d.drawImage(image, 0, 0, (image.width*ScreenDefs.DISPLAY_PIXEL_SCALING).toInt(),
|
g2d.drawImage(image, 0, 0, (image.width*ScreenDefs.PIXEL_SCALING).toInt(),
|
||||||
(image.height*ScreenDefs.DISPLAY_PIXEL_SCALING).toInt(), null)
|
(image.height*ScreenDefs.PIXEL_SCALING).toInt(), null)
|
||||||
if (cursorState) {
|
if (cursorState) {
|
||||||
val scx = (cursorX*ScreenDefs.DISPLAY_PIXEL_SCALING*8).toInt()
|
val scx = (cursorX*ScreenDefs.PIXEL_SCALING*8).toInt()
|
||||||
val scy = (cursorY*ScreenDefs.DISPLAY_PIXEL_SCALING*16).toInt()
|
val scy = (cursorY*ScreenDefs.PIXEL_SCALING*16).toInt()
|
||||||
val scw = (8*ScreenDefs.DISPLAY_PIXEL_SCALING).toInt()
|
val scw = (8*ScreenDefs.PIXEL_SCALING).toInt()
|
||||||
val sch = (16*ScreenDefs.DISPLAY_PIXEL_SCALING).toInt()
|
val sch = (16*ScreenDefs.PIXEL_SCALING).toInt()
|
||||||
g2d.setXORMode(Color.CYAN)
|
g2d.setXORMode(Color.CYAN)
|
||||||
g2d.fillRect(scx, scy, scw, sch)
|
g2d.fillRect(scx, scy, scw, sch)
|
||||||
g2d.setPaintMode()
|
g2d.setPaintMode()
|
||||||
|
@ -123,7 +123,7 @@ private class BitmapScreenPanel : JPanel() {
|
||||||
|
|
||||||
fun mousePixelPosition(): Point? {
|
fun mousePixelPosition(): Point? {
|
||||||
val pos = mousePosition ?: return null
|
val pos = mousePosition ?: return null
|
||||||
return Point((pos.x/ScreenDefs.DISPLAY_PIXEL_SCALING).toInt(), (pos.y/ScreenDefs.DISPLAY_PIXEL_SCALING).toInt())
|
return Point((pos.x/ScreenDefs.PIXEL_SCALING).toInt(), (pos.y/ScreenDefs.PIXEL_SCALING).toInt())
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cursorPos(x: Int, y: Int) {
|
fun cursorPos(x: Int, y: Int) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user