mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
fix: DrawCallDrawLines arg xpos and len swapped
This commit is contained in:
18
assets/disk0/home/drawcalltest.js
Normal file
18
assets/disk0/home/drawcalltest.js
Normal file
@@ -0,0 +1,18 @@
|
||||
let bytecodes = [
|
||||
0xF1, 0, 0, 100, 0,0, 255,255,0,0,0,0, 255,255,0,0,0,0, // Y=100
|
||||
0x17, 0xc9, 0x40,0x2A, 0x40,0x2B, 0x40,0x2C, 0x40,0x2D, 0x40,0x2E, 0x40,0x2F, 0x40,0x30, 0x40,0x31, // DrawLines (x=256,256,256,256,256,256,256,256)
|
||||
0x1F, 0xc3, 0x40,0x2A, 0x40,0x2B, 0x40,0x2C, 0x40,0x2D, 0x40,0x2E, 0x40,0x2F, 0x40,0x30, 0x40,0x31, // DrawDoubleLines (x=256,256,256,256,256,256,256,256)
|
||||
|
||||
0xF1, 0, 0, 200, 0,0, 255,255,0,0,0,0, 255,255,0,0,0,0, // Y=200
|
||||
0x3D,0x68, 0x00,0x18, 0x10,0x20, 0x20,0x28, 0x30,0x30, 0x40,0x38, 0x50,0x40, 0x60,0x48, 0x70,0x50, // DrawMultiLines (x=360)
|
||||
|
||||
0xF1, 0, 0x1, 0x2C, 0,0, 255,255,0,0,0,0, 255,255,0,0,0,0, // Y=300
|
||||
0x5C,0xB4, 0x80,0x18, 0x90,0x20, 0xA0,0x28, 0xB0,0x30, 0xC0,0x38, 0xD0,0x40, 0xE0,0x48, 0xF0,0x50, // DrawDoubleMultiLines (x=180)
|
||||
0xf0, 0x0f, 0,0,0,0, 255,255,0,0,0,0, 255,255,0,0,0,0 // End
|
||||
]
|
||||
|
||||
bytecodes.forEach((b,i)=>{
|
||||
sys.poke(-131073 - 65536 - i, b)
|
||||
})
|
||||
|
||||
sys.poke(-131073 - 19, 1)
|
||||
@@ -556,10 +556,12 @@ Play Head Flags
|
||||
m: mode (0 for Tracker, 1 for PCM)
|
||||
Byte 2
|
||||
- PCM Mode: Sampling rate multiplier in 3.5 Unsigned Minifloat (0.03125x to 126x)
|
||||
Byte 3
|
||||
- BPM (24 to 280. Play Data will change this register; unused in PCM Mode)
|
||||
Byte 4
|
||||
- Tick Rate (Play Data will change this register; unused in PCM Mode)
|
||||
Byte 3 (Tracker Mode)
|
||||
- BPM (24 to 280. Play Data will change this register)
|
||||
Byte 4 (Tracker Mode)
|
||||
- Tick Rate (Play Data will change this register)
|
||||
Byte 3-4 (PCM Mode)
|
||||
- Signed Int16 Sampling rate difference from 30000 Hz
|
||||
|
||||
Play Head Position interpretion
|
||||
- Cuesheet Counter for Tracker mode
|
||||
|
||||
@@ -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