mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-10 21:21:51 +09:00
fix: DrawCallDrawLines arg xpos and len swapped
This commit is contained in:
@@ -11,7 +11,7 @@ internal interface DrawCall {
|
||||
fun execute(gpu: GraphicsAdapter)
|
||||
}
|
||||
|
||||
internal class DrawCallCompound(val call1: DrawCall, val call2: DrawCall, val call3: DrawCall) : DrawCall {
|
||||
internal data class DrawCallCompound(val call1: DrawCall, val call2: DrawCall, val call3: DrawCall) : DrawCall {
|
||||
override fun execute(gpu: GraphicsAdapter) {
|
||||
call1.execute(gpu)
|
||||
call2.execute(gpu)
|
||||
@@ -27,19 +27,19 @@ internal object DrawCallEnd : DrawCall {
|
||||
override fun execute(gpu: GraphicsAdapter) {}
|
||||
}
|
||||
|
||||
internal class GotoScanline(val line: Int) : DrawCall {
|
||||
internal data class GotoScanline(val line: Int) : DrawCall {
|
||||
override fun execute(gpu: GraphicsAdapter) {
|
||||
gpu.rScanline = line
|
||||
}
|
||||
}
|
||||
|
||||
internal class ChangeGraphicsMode(val mode: Int) : DrawCall {
|
||||
internal data class ChangeGraphicsMode(val mode: Int) : DrawCall {
|
||||
override fun execute(gpu: GraphicsAdapter) {
|
||||
gpu.mmio_write(12L, mode.toByte())
|
||||
}
|
||||
}
|
||||
|
||||
internal class JumpIfScanline(
|
||||
internal data class JumpIfScanline(
|
||||
val reg: Int,
|
||||
val compare: Int,
|
||||
val whenLessThan: Int,
|
||||
@@ -65,7 +65,7 @@ internal class JumpIfScanline(
|
||||
/**
|
||||
* DrawDoubleLines: simply double the `len` parameter
|
||||
*/
|
||||
internal class DrawCallDrawLines(
|
||||
internal data class DrawCallDrawLines(
|
||||
val opCount: Int, val colour: Int, val lenMult: Int,
|
||||
val xposs: IntArray, val lens: IntArray
|
||||
) : DrawCall {
|
||||
@@ -80,7 +80,7 @@ internal class DrawCallDrawLines(
|
||||
}
|
||||
|
||||
|
||||
internal class DrawCallDrawMultiLines(
|
||||
internal data class DrawCallDrawMultiLines(
|
||||
val opCount: Int, val xPosInit: Int, val lenMult: Int,
|
||||
val colours: IntArray, val lens: IntArray
|
||||
) : DrawCall {
|
||||
@@ -97,7 +97,7 @@ internal class DrawCallDrawMultiLines(
|
||||
}
|
||||
}
|
||||
|
||||
internal class DrawCallCopyPixels(
|
||||
internal data class DrawCallCopyPixels(
|
||||
val useTransparency: Boolean,
|
||||
val width: Int,
|
||||
val height: Int,
|
||||
|
||||
@@ -384,7 +384,13 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
||||
drawCallSize = 0
|
||||
while (true) {
|
||||
val bytes = (0..17).map { instArea.get(18L*drawCallSize + it) }.toByteArray()
|
||||
|
||||
println("Word #${drawCallSize+1}: ${bytes.joinToString(", ") { it.toUint().toString(16).padStart(2, '0') }}")
|
||||
|
||||
val instruction = compileWord(bytes)
|
||||
|
||||
println("Inst #${drawCallSize+1}: $instruction\n")
|
||||
|
||||
drawCallBuffer[drawCallSize] = instruction
|
||||
drawCallSize += 1
|
||||
|
||||
@@ -396,6 +402,7 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
||||
}
|
||||
|
||||
private fun compileWord(bytes: ByteArray): DrawCall {
|
||||
|
||||
val head = bytes[0]
|
||||
|
||||
when (head) {
|
||||
@@ -415,16 +422,6 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
||||
return DrawCallDrawLines(
|
||||
(head and 0xF).toInt() + 1,
|
||||
bytes[1].toUint(), 1,
|
||||
intArrayOf(
|
||||
bytes[3].toUint().and(63).unzero(64),
|
||||
bytes[5].toUint().and(63).unzero(64),
|
||||
bytes[7].toUint().and(63).unzero(64),
|
||||
bytes[9].toUint().and(63).unzero(64),
|
||||
bytes[11].toUint().and(63).unzero(64),
|
||||
bytes[13].toUint().and(63).unzero(64),
|
||||
bytes[15].toUint().and(63).unzero(64),
|
||||
bytes[17].toUint().and(63).unzero(64)
|
||||
),
|
||||
intArrayOf(
|
||||
bytes[2].toUint().shl(2) or bytes[3].toUint().and(192).ushr(6),
|
||||
bytes[4].toUint().shl(2) or bytes[5].toUint().and(192).ushr(6),
|
||||
@@ -434,6 +431,16 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
||||
bytes[12].toUint().shl(2) or bytes[13].toUint().and(192).ushr(6),
|
||||
bytes[14].toUint().shl(2) or bytes[15].toUint().and(192).ushr(6),
|
||||
bytes[16].toUint().shl(2) or bytes[17].toUint().and(192).ushr(6)
|
||||
),
|
||||
intArrayOf(
|
||||
bytes[3].toUint().and(63).unzero(64),
|
||||
bytes[5].toUint().and(63).unzero(64),
|
||||
bytes[7].toUint().and(63).unzero(64),
|
||||
bytes[9].toUint().and(63).unzero(64),
|
||||
bytes[11].toUint().and(63).unzero(64),
|
||||
bytes[13].toUint().and(63).unzero(64),
|
||||
bytes[15].toUint().and(63).unzero(64),
|
||||
bytes[17].toUint().and(63).unzero(64)
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -441,16 +448,6 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
||||
return DrawCallDrawLines(
|
||||
(head and 0xF).toInt() - 7,
|
||||
bytes[1].toUint(), 2,
|
||||
intArrayOf(
|
||||
bytes[3].toUint().and(63).unzero(64),
|
||||
bytes[5].toUint().and(63).unzero(64),
|
||||
bytes[7].toUint().and(63).unzero(64),
|
||||
bytes[9].toUint().and(63).unzero(64),
|
||||
bytes[11].toUint().and(63).unzero(64),
|
||||
bytes[13].toUint().and(63).unzero(64),
|
||||
bytes[15].toUint().and(63).unzero(64),
|
||||
bytes[17].toUint().and(63).unzero(64)
|
||||
),
|
||||
intArrayOf(
|
||||
bytes[2].toUint().shl(2) or bytes[3].toUint().and(192).ushr(6),
|
||||
bytes[4].toUint().shl(2) or bytes[5].toUint().and(192).ushr(6),
|
||||
@@ -460,6 +457,16 @@ open class GraphicsAdapter(private val assetsRoot: String, val vm: VM, val confi
|
||||
bytes[12].toUint().shl(2) or bytes[13].toUint().and(192).ushr(6),
|
||||
bytes[14].toUint().shl(2) or bytes[15].toUint().and(192).ushr(6),
|
||||
bytes[16].toUint().shl(2) or bytes[17].toUint().and(192).ushr(6)
|
||||
),
|
||||
intArrayOf(
|
||||
bytes[3].toUint().and(63).unzero(64),
|
||||
bytes[5].toUint().and(63).unzero(64),
|
||||
bytes[7].toUint().and(63).unzero(64),
|
||||
bytes[9].toUint().and(63).unzero(64),
|
||||
bytes[11].toUint().and(63).unzero(64),
|
||||
bytes[13].toUint().and(63).unzero(64),
|
||||
bytes[15].toUint().and(63).unzero(64),
|
||||
bytes[17].toUint().and(63).unzero(64)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user