mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-12 15:44:05 +09:00
fix: incorrect MMIO addressing of FB3/4
This commit is contained in:
@@ -115,6 +115,10 @@ con.curs_set(0)
|
|||||||
graphics.setGraphicsMode(5) // 32-bit colour mode
|
graphics.setGraphicsMode(5) // 32-bit colour mode
|
||||||
graphics.clearPixels(0)
|
graphics.clearPixels(0)
|
||||||
graphics.clearPixels2(0)
|
graphics.clearPixels2(0)
|
||||||
|
graphics.clearPixels3(0)
|
||||||
|
graphics.clearPixels4(0)
|
||||||
|
|
||||||
|
const gpuGraphicsMode = graphics.getGraphicsMode()
|
||||||
|
|
||||||
// Initialize audio
|
// Initialize audio
|
||||||
audio.resetParams(0)
|
audio.resetParams(0)
|
||||||
@@ -396,10 +400,19 @@ let oldBgcol = [BIAS_LIGHTING_MIN, BIAS_LIGHTING_MIN, BIAS_LIGHTING_MIN]
|
|||||||
let notifHidden = false
|
let notifHidden = false
|
||||||
|
|
||||||
function getRGBfromScr(x, y) {
|
function getRGBfromScr(x, y) {
|
||||||
let offset = y * WIDTH + x
|
if (gpuGraphicsMode == 4) {
|
||||||
let rg = sys.peek(-1048577 - offset)
|
let offset = y * WIDTH + x
|
||||||
let ba = sys.peek(-1310721 - offset)
|
let rg = sys.peek(-1048577 - offset)
|
||||||
return [(rg >>> 4) / 15.0, (rg & 15) / 15.0, (ba >>> 4) / 15.0]
|
let ba = sys.peek(-1310721 - offset)
|
||||||
|
return [(rg >>> 4) / 15.0, (rg & 15) / 15.0, (ba >>> 4) / 15.0]
|
||||||
|
}
|
||||||
|
else if (gpuGraphicsMode == 5) {
|
||||||
|
let offset = y * WIDTH + x
|
||||||
|
let r = sys.peek(-1048577 - offset)
|
||||||
|
let g = sys.peek(-1310721 - offset)
|
||||||
|
let b = sys.peek(-1572865 - offset)
|
||||||
|
return [r / 255.0, g / 255.0, b / 255.0]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function setBiasLighting() {
|
function setBiasLighting() {
|
||||||
|
|||||||
@@ -268,8 +268,24 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
|
|
||||||
fun clearPixels2(col: Int) {
|
fun clearPixels2(col: Int) {
|
||||||
getFirstGPU()?.let {
|
getFirstGPU()?.let {
|
||||||
it.poke(250883L, 4)
|
|
||||||
it.poke(250884L, col.toByte())
|
it.poke(250884L, col.toByte())
|
||||||
|
it.poke(250883L, 4)
|
||||||
|
it.applyDelay()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearPixels3(col: Int) {
|
||||||
|
getFirstGPU()?.let {
|
||||||
|
it.poke(250884L, col.toByte())
|
||||||
|
it.poke(250883L, 6)
|
||||||
|
it.applyDelay()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun clearPixels4(col: Int) {
|
||||||
|
getFirstGPU()?.let {
|
||||||
|
it.poke(250884L, col.toByte())
|
||||||
|
it.poke(250883L, 8)
|
||||||
it.applyDelay()
|
it.applyDelay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,15 +230,15 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
|||||||
|
|
||||||
override fun peek(addr: Long): Byte? {
|
override fun peek(addr: Long): Byte? {
|
||||||
val adi = addr.toInt()
|
val adi = addr.toInt()
|
||||||
if (framebuffer4 != null && addr >= 524288) {
|
if (framebuffer4 != null && addr >= 786432) {
|
||||||
return when (addr - 524288) {
|
return when (addr - 786432) {
|
||||||
in 0 until 250880 -> framebuffer4[addr - 524288]
|
in 0 until 250880 -> framebuffer4[addr - 786432]
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (framebuffer3 != null && addr >= 393216) {
|
else if (framebuffer3 != null && addr >= 524288) {
|
||||||
return when (addr - 393216) {
|
return when (addr - 524288) {
|
||||||
in 0 until 250880 -> framebuffer3[addr - 393216]
|
in 0 until 250880 -> framebuffer3[addr - 524288]
|
||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,19 +291,19 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
|||||||
val adi = addr.toInt()
|
val adi = addr.toInt()
|
||||||
val bi = byte.toInt().and(255)
|
val bi = byte.toInt().and(255)
|
||||||
if (framebuffer4 != null) {
|
if (framebuffer4 != null) {
|
||||||
when (addr - 524288) {
|
when (addr - 786432) {
|
||||||
in 0 until 250880 -> {
|
in 0 until 250880 -> {
|
||||||
lastUsedColour = byte
|
lastUsedColour = byte
|
||||||
framebuffer4[addr - 524288] = byte
|
framebuffer4[addr - 786432] = byte
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (framebuffer3 != null) {
|
if (framebuffer3 != null) {
|
||||||
when (addr - 393216) {
|
when (addr - 524288) {
|
||||||
in 0 until 250880 -> {
|
in 0 until 250880 -> {
|
||||||
lastUsedColour = byte
|
lastUsedColour = byte
|
||||||
framebuffer3[addr - 393216] = byte
|
framebuffer3[addr - 524288] = byte
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -417,6 +417,8 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
|||||||
private fun runCommand(opcode: Byte) {
|
private fun runCommand(opcode: Byte) {
|
||||||
val arg1 = unusedArea[4].toInt().and(255)
|
val arg1 = unusedArea[4].toInt().and(255)
|
||||||
val arg2 = unusedArea[5].toInt().and(255)
|
val arg2 = unusedArea[5].toInt().and(255)
|
||||||
|
val arg3 = unusedArea[6].toInt().and(255)
|
||||||
|
val arg4 = unusedArea[7].toInt().and(255)
|
||||||
|
|
||||||
when (opcode.toInt()) {
|
when (opcode.toInt()) {
|
||||||
1 -> {
|
1 -> {
|
||||||
@@ -432,6 +434,12 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
|||||||
4 -> {
|
4 -> {
|
||||||
framebuffer2?.fillWith(arg1.toByte())
|
framebuffer2?.fillWith(arg1.toByte())
|
||||||
}
|
}
|
||||||
|
6 -> {
|
||||||
|
framebuffer3?.fillWith(arg1.toByte())
|
||||||
|
}
|
||||||
|
8 -> {
|
||||||
|
framebuffer4?.fillWith(arg1.toByte())
|
||||||
|
}
|
||||||
3 -> {
|
3 -> {
|
||||||
for (it in 0 until 1024) {
|
for (it in 0 until 1024) {
|
||||||
val rgba = DEFAULT_PALETTE[it / 4]
|
val rgba = DEFAULT_PALETTE[it / 4]
|
||||||
@@ -440,6 +448,8 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
|||||||
}
|
}
|
||||||
framebuffer.fillWith(arg1.toByte())
|
framebuffer.fillWith(arg1.toByte())
|
||||||
framebuffer2?.fillWith(arg2.toByte())
|
framebuffer2?.fillWith(arg2.toByte())
|
||||||
|
framebuffer3?.fillWith(arg3.toByte())
|
||||||
|
framebuffer4?.fillWith(arg4.toByte())
|
||||||
}
|
}
|
||||||
16, 17 -> readFontRom(opcode - 16)
|
16, 17 -> readFontRom(opcode - 16)
|
||||||
18, 19 -> writeFontRom(opcode - 18)
|
18, 19 -> writeFontRom(opcode - 18)
|
||||||
|
|||||||
Reference in New Issue
Block a user