mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-09 22:54:03 +09:00
adding transmission delays as they should be (ipfs are now faster than rgb)
This commit is contained in:
@@ -19,11 +19,17 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getVramSize() {
|
fun getVramSize() {
|
||||||
getFirstGPU()?.mmio_read(11)
|
getFirstGPU()?.let {
|
||||||
|
it.mmio_read(11)
|
||||||
|
it.applyDelay()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun resetPalette() {
|
fun resetPalette() {
|
||||||
getFirstGPU()?.poke(250883L, 1)
|
getFirstGPU()?.let {
|
||||||
|
it.poke(250883L, 1)
|
||||||
|
it.applyDelay()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -36,6 +42,7 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
it.paletteOfFloats[index * 4 + 1] = (g and 15) / 15f
|
it.paletteOfFloats[index * 4 + 1] = (g and 15) / 15f
|
||||||
it.paletteOfFloats[index * 4 + 2] = (b and 15) / 15f
|
it.paletteOfFloats[index * 4 + 2] = (b and 15) / 15f
|
||||||
it.paletteOfFloats[index * 4 + 3] = (a and 15) / 15f
|
it.paletteOfFloats[index * 4 + 3] = (a and 15) / 15f
|
||||||
|
it.applyDelay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -62,6 +69,7 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
getFirstGPU()?.let {
|
getFirstGPU()?.let {
|
||||||
if (x in 0 until it.config.width && y in 0 until it.config.height) {
|
if (x in 0 until it.config.width && y in 0 until it.config.height) {
|
||||||
it.poke(y.toLong() * it.config.width + x, color.toByte())
|
it.poke(y.toLong() * it.config.width + x, color.toByte())
|
||||||
|
it.applyDelay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,6 +78,7 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
getFirstGPU()?.let {
|
getFirstGPU()?.let {
|
||||||
if (x in 0 until it.config.width && y in 0 until it.config.height) {
|
if (x in 0 until it.config.width && y in 0 until it.config.height) {
|
||||||
it.poke(262144 + y.toLong() * it.config.width + x, color.toByte())
|
it.poke(262144 + y.toLong() * it.config.width + x, color.toByte())
|
||||||
|
it.applyDelay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -81,11 +90,15 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
getFirstGPU()?.let {
|
getFirstGPU()?.let {
|
||||||
it.framebufferScrollX = x
|
it.framebufferScrollX = x
|
||||||
it.framebufferScrollY = y
|
it.framebufferScrollY = y
|
||||||
|
it.applyDelay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getFramebufferScroll(): IntArray {
|
fun getFramebufferScroll(): IntArray {
|
||||||
getFirstGPU()?.let { return intArrayOf(it.framebufferScrollX, it.framebufferScrollY) }
|
getFirstGPU()?.let {
|
||||||
|
it.applyDelay()
|
||||||
|
return intArrayOf(it.framebufferScrollX, it.framebufferScrollY)
|
||||||
|
}
|
||||||
return intArrayOf(0, 0)
|
return intArrayOf(0, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +106,7 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
getFirstGPU()?.let {
|
getFirstGPU()?.let {
|
||||||
it.framebufferScrollX = (it.framebufferScrollX + xdelta) fmod it.WIDTH
|
it.framebufferScrollX = (it.framebufferScrollX + xdelta) fmod it.WIDTH
|
||||||
it.framebufferScrollY = (it.framebufferScrollY + ydelta) fmod it.HEIGHT
|
it.framebufferScrollY = (it.framebufferScrollY + ydelta) fmod it.HEIGHT
|
||||||
|
it.applyDelay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +114,7 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
getFirstGPU()?.let {
|
getFirstGPU()?.let {
|
||||||
it.scanlineOffsets[2L * line] = offset.toByte()
|
it.scanlineOffsets[2L * line] = offset.toByte()
|
||||||
it.scanlineOffsets[2L * line + 1] = offset.shr(8).toByte() // absolutely not USHR
|
it.scanlineOffsets[2L * line + 1] = offset.shr(8).toByte() // absolutely not USHR
|
||||||
|
it.applyDelay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,37 +122,54 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
getFirstGPU()?.let {
|
getFirstGPU()?.let {
|
||||||
var xoff = it.scanlineOffsets[2L * line].toUint() or it.scanlineOffsets[2L * line + 1].toUint().shl(8)
|
var xoff = it.scanlineOffsets[2L * line].toUint() or it.scanlineOffsets[2L * line + 1].toUint().shl(8)
|
||||||
if (xoff.and(0x8000) != 0) xoff = xoff or 0xFFFF0000.toInt()
|
if (xoff.and(0x8000) != 0) xoff = xoff or 0xFFFF0000.toInt()
|
||||||
|
it.applyDelay()
|
||||||
return xoff
|
return xoff
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setGraphicsMode(mode: Int) {
|
fun setGraphicsMode(mode: Int) {
|
||||||
getFirstGPU()?.mmio_write(12L, mode.toByte())
|
getFirstGPU()?.let {
|
||||||
|
it.mmio_write(12L, mode.toByte())
|
||||||
|
it.applyDelay()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getGraphicsMode() = getFirstGPU()?.mmio_read(12L)?.toUint() ?: 0
|
fun getGraphicsMode() = getFirstGPU()?.let {
|
||||||
|
it.applyDelay()
|
||||||
|
it.mmio_read(12L)?.toUint() ?: 0
|
||||||
|
}
|
||||||
|
|
||||||
fun getPixelDimension(): IntArray {
|
fun getPixelDimension(): IntArray {
|
||||||
getFirstGPU()?.let { return intArrayOf(it.WIDTH, it.HEIGHT) }
|
getFirstGPU()?.let {
|
||||||
|
it.applyDelay()
|
||||||
|
return intArrayOf(it.WIDTH, it.HEIGHT)
|
||||||
|
}
|
||||||
return intArrayOf(-1, -1)
|
return intArrayOf(-1, -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTermDimension(): IntArray {
|
fun getTermDimension(): IntArray {
|
||||||
getFirstGPU()?.let { return intArrayOf(it.TEXT_ROWS, it.TEXT_COLS) }
|
getFirstGPU()?.let {
|
||||||
|
it.applyDelay()
|
||||||
|
return intArrayOf(it.TEXT_ROWS, it.TEXT_COLS)
|
||||||
|
}
|
||||||
return intArrayOf(-1, -1)
|
return intArrayOf(-1, -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getCursorYX(): IntArray {
|
fun getCursorYX(): IntArray {
|
||||||
getFirstGPU()?.let {
|
getFirstGPU()?.let {
|
||||||
val (cx, cy) = it.getCursorPos()
|
val (cx, cy) = it.getCursorPos()
|
||||||
|
it.applyDelay()
|
||||||
return intArrayOf(cy + 1, cx + 1)
|
return intArrayOf(cy + 1, cx + 1)
|
||||||
}
|
}
|
||||||
return intArrayOf(-1, -1)
|
return intArrayOf(-1, -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setCursorYX(cy: Int, cx: Int) {
|
fun setCursorYX(cy: Int, cx: Int) {
|
||||||
getFirstGPU()?.setCursorPos(cx - 1, cy - 1)
|
getFirstGPU()?.let {
|
||||||
|
it.setCursorPos(cx - 1, cy - 1)
|
||||||
|
it.applyDelay()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -146,21 +178,31 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
it.poke(250880, r.toByte())
|
it.poke(250880, r.toByte())
|
||||||
it.poke(250881, g.toByte())
|
it.poke(250881, g.toByte())
|
||||||
it.poke(250882, b.toByte())
|
it.poke(250882, b.toByte())
|
||||||
|
it.applyDelay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearText() {
|
fun clearText() {
|
||||||
getFirstGPU()?.eraseInDisp(2)
|
getFirstGPU()?.let {
|
||||||
|
it.eraseInDisp(2)
|
||||||
|
it.applyDelay()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearPixels(col: Int) {
|
fun clearPixels(col: Int) {
|
||||||
getFirstGPU()?.poke(250884L, col.toByte())
|
getFirstGPU()?.let {
|
||||||
getFirstGPU()?.poke(250883L, 2)
|
it.poke(250884L, col.toByte())
|
||||||
|
it.poke(250883L, 2)
|
||||||
|
it.applyDelay()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun clearPixels2(col: Int) {
|
fun clearPixels2(col: Int) {
|
||||||
getFirstGPU()?.poke(250884L, col.toByte())
|
getFirstGPU()?.let {
|
||||||
getFirstGPU()?.poke(250883L, 4)
|
it.poke(250883L, 4)
|
||||||
|
it.poke(250884L, col.toByte())
|
||||||
|
it.applyDelay()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -172,11 +214,16 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
|
|
||||||
|
|
||||||
it.putChar(cx, cy, c.toByte())
|
it.putChar(cx, cy, c.toByte())
|
||||||
|
|
||||||
|
it.applyDelay()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun putSymbolAt(cy: Int, cx: Int, c: Int) {
|
fun putSymbolAt(cy: Int, cx: Int, c: Int) {
|
||||||
getFirstGPU()?.putChar(cx - 1, cy - 1, c.toByte())
|
getFirstGPU()?.let {
|
||||||
|
it.putChar(cx - 1, cy - 1, c.toByte())
|
||||||
|
it.applyDelay()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*private fun GraphicsAdapter._loadbulk(fromAddr: Int, toAddr: Int, length: Int) {
|
/*private fun GraphicsAdapter._loadbulk(fromAddr: Int, toAddr: Int, length: Int) {
|
||||||
@@ -821,6 +868,7 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun decodeIpf1(srcPtr: Int, destRG: Int, destBA: Int, width: Int, height: Int, hasAlpha: Boolean) {
|
fun decodeIpf1(srcPtr: Int, destRG: Int, destBA: Int, width: Int, height: Int, hasAlpha: Boolean) {
|
||||||
|
val gpu = getFirstGPU()
|
||||||
val sign = if (destRG >= 0) 1 else -1
|
val sign = if (destRG >= 0) 1 else -1
|
||||||
if (destRG * destBA < 0) throw IllegalArgumentException("Both destination memories must be on the same domain (both being Usermem or HWmem)")
|
if (destRG * destBA < 0) throw IllegalArgumentException("Both destination memories must be on the same domain (both being Usermem or HWmem)")
|
||||||
val sptr = srcPtr.toLong()
|
val sptr = srcPtr.toLong()
|
||||||
@@ -828,7 +876,9 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
val dptr2 = destBA.toLong()
|
val dptr2 = destBA.toLong()
|
||||||
var readCount = 0
|
var readCount = 0
|
||||||
fun readShort() =
|
fun readShort() =
|
||||||
vm.peek(sptr + readCount++)!!.toUint() or vm.peek(sptr + readCount++)!!.toUint().shl(8)
|
vm.peek(sptr + readCount++)!!.toUint() or vm.peek(sptr + readCount++)!!.toUint().shl(8).also {
|
||||||
|
gpu?.applyDelay()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for (blockY in 0 until ceil(height / 4f)) {
|
for (blockY in 0 until ceil(height / 4f)) {
|
||||||
@@ -889,6 +939,7 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun decodeIpf2(srcPtr: Int, destRG: Int, destBA: Int, width: Int, height: Int, hasAlpha: Boolean) {
|
fun decodeIpf2(srcPtr: Int, destRG: Int, destBA: Int, width: Int, height: Int, hasAlpha: Boolean) {
|
||||||
|
val gpu = getFirstGPU()
|
||||||
val sign = if (destRG >= 0) 1 else -1
|
val sign = if (destRG >= 0) 1 else -1
|
||||||
if (destRG * destBA < 0) throw IllegalArgumentException("Both destination memories must be on the same domain (both being Usermem or HWmem)")
|
if (destRG * destBA < 0) throw IllegalArgumentException("Both destination memories must be on the same domain (both being Usermem or HWmem)")
|
||||||
val sptr = srcPtr.toLong()
|
val sptr = srcPtr.toLong()
|
||||||
@@ -896,9 +947,14 @@ class GraphicsJSR223Delegate(private val vm: VM) {
|
|||||||
val dptr2 = destBA.toLong()
|
val dptr2 = destBA.toLong()
|
||||||
var readCount = 0
|
var readCount = 0
|
||||||
fun readShort() =
|
fun readShort() =
|
||||||
vm.peek(sptr + readCount++)!!.toUint() or vm.peek(sptr + readCount++)!!.toUint().shl(8)
|
vm.peek(sptr + readCount++)!!.toUint() or vm.peek(sptr + readCount++)!!.toUint().shl(8).also {
|
||||||
|
gpu?.applyDelay()
|
||||||
|
}
|
||||||
fun readInt() =
|
fun readInt() =
|
||||||
vm.peek(sptr + readCount++)!!.toUint() or vm.peek(sptr + readCount++)!!.toUint().shl(8) or vm.peek(sptr + readCount++)!!.toUint().shl(16) or vm.peek(sptr + readCount++)!!.toUint().shl(24)
|
vm.peek(sptr + readCount++)!!.toUint() or vm.peek(sptr + readCount++)!!.toUint().shl(8) or vm.peek(sptr + readCount++)!!.toUint().shl(16) or vm.peek(sptr + readCount++)!!.toUint().shl(24).also {
|
||||||
|
gpu?.applyDelay()
|
||||||
|
gpu?.applyDelay()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
for (blockY in 0 until ceil(height / 4f)) {
|
for (blockY in 0 until ceil(height / 4f)) {
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ data class AdapterConfig(
|
|||||||
val paletteShader: String = DRAW_SHADER_FRAG,
|
val paletteShader: String = DRAW_SHADER_FRAG,
|
||||||
val drawScale: Float = 1f,
|
val drawScale: Float = 1f,
|
||||||
val scaleFiltered: Boolean = false,
|
val scaleFiltered: Boolean = false,
|
||||||
val baudRate: Double = 20_480_000.0,//57600.0,
|
val baudRate: Double = 10_240_000.0,//57600.0,
|
||||||
val bitsPerChar: Int = 10 // start bit + 8 data bits + stop bit
|
val bitsPerChar: Int = 10 // start bit + 8 data bits + stop bit
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -258,8 +258,7 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
|||||||
protected var slpcnt = 0L
|
protected var slpcnt = 0L
|
||||||
|
|
||||||
|
|
||||||
@SuppressWarnings()
|
fun applyDelay() {
|
||||||
protected fun applyDelay() {
|
|
||||||
slpcnt += sleepMillis * 1000000L + sleepNanos
|
slpcnt += sleepMillis * 1000000L + sleepNanos
|
||||||
val millis = slpcnt / 1000000L
|
val millis = slpcnt / 1000000L
|
||||||
|
|
||||||
@@ -298,7 +297,6 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
|||||||
poke(addr % VRAM_SIZE, byte)
|
poke(addr % VRAM_SIZE, byte)
|
||||||
} // HW mirroring
|
} // HW mirroring
|
||||||
}
|
}
|
||||||
applyDelay()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getTextmodeAttirbutes(): Byte = (currentChrRom.and(15).shl(4) or
|
private fun getTextmodeAttirbutes(): Byte = (currentChrRom.and(15).shl(4) or
|
||||||
@@ -713,6 +711,7 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
|||||||
textArea[memTextForeOffset + textOff] = foreColour
|
textArea[memTextForeOffset + textOff] = foreColour
|
||||||
textArea[memTextBackOffset + textOff] = backColour
|
textArea[memTextBackOffset + textOff] = backColour
|
||||||
textArea[memTextOffset + textOff] = text
|
textArea[memTextOffset + textOff] = text
|
||||||
|
applyDelay()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun emitChar(code: Int) {
|
override fun emitChar(code: Int) {
|
||||||
|
|||||||
@@ -46,7 +46,6 @@ open class TexticsAdapterBase(assetsRoot: String, vm: VM, config: AdapterConfig)
|
|||||||
|
|
||||||
override fun putChar(x: Int, y: Int, text: Byte, foreColour: Byte, backColour: Byte) {
|
override fun putChar(x: Int, y: Int, text: Byte, foreColour: Byte, backColour: Byte) {
|
||||||
super.putChar(x, y, text, foreColour, backColour)
|
super.putChar(x, y, text, foreColour, backColour)
|
||||||
applyDelay()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private val TEX_HEIGHT = WIDTH * Math.sqrt(HEIGHT.toDouble() / WIDTH).toFloat()
|
private val TEX_HEIGHT = WIDTH * Math.sqrt(HEIGHT.toDouble() / WIDTH).toFloat()
|
||||||
|
|||||||
Reference in New Issue
Block a user