diff --git a/tsvm_core/src/net/torvald/tsvm/GraphicsJSR223Delegate.kt b/tsvm_core/src/net/torvald/tsvm/GraphicsJSR223Delegate.kt index bbd3663..8c509a7 100644 --- a/tsvm_core/src/net/torvald/tsvm/GraphicsJSR223Delegate.kt +++ b/tsvm_core/src/net/torvald/tsvm/GraphicsJSR223Delegate.kt @@ -1618,15 +1618,11 @@ class GraphicsJSR223Delegate(private val vm: VM) { } // cover up top two and bottom two lines with current border colour - val lines = arrayOf(0, 1, height - 2, height - 1) - for (x in 0 until width) { - for (y in lines) { - val dest = (y * width + x) * 3 - vm.poke(outputRGBAddr + dest + 0, vm.peek(-1299457)!!) - vm.poke(outputRGBAddr + dest + 1, vm.peek(-1299458)!!) - vm.poke(outputRGBAddr + dest + 2, vm.peek(-1299459)!!) - } - } + val destT = 0 + val destB = (height - 2) * width * 3 + val col = (vm.peek(-1299457)!!.toUint() shl 16) or (vm.peek(-1299458)!!.toUint() shl 8) or vm.peek(-1299459)!!.toUint() + vm.memsetI24(outputRGBAddr.toInt() + destT, col, width * 6) + vm.memsetI24(outputRGBAddr.toInt() + destB, col, width * 6) } fun tevYcocgToRGB(yBlock: IntArray, coBlock: IntArray, cgBlock: IntArray): IntArray { diff --git a/tsvm_core/src/net/torvald/tsvm/VM.kt b/tsvm_core/src/net/torvald/tsvm/VM.kt index 10c6c5b..eeab9fe 100644 --- a/tsvm_core/src/net/torvald/tsvm/VM.kt +++ b/tsvm_core/src/net/torvald/tsvm/VM.kt @@ -549,6 +549,19 @@ class VM( return dest } + fun memsetI24(dest: Int, ch: Int, countInBytes: Int): Int { + val r = ch.ushr(16).and(255).toByte() + val g = ch.ushr(8).and(255).toByte() + val b = ch.ushr(0).and(255).toByte() + val incVec = if (dest >= 0) 1L else -1L + for (i in 0 until countInBytes step 3) { + poke(dest + (i + 0)*incVec, r) + poke(dest + (i + 1)*incVec, g) + poke(dest + (i + 2)*incVec, b) + } + return dest + } + fun bulkPeekShort(from: Int, to: ShortArray, sizeInBytes: Int) { if (from !in 0..8*1024*1024) throw IllegalArgumentException() UnsafeHelper.memcpyRaw(null, usermem.ptr + from, to, UnsafeHelper.getArrayOffset(to), sizeInBytes.toLong())