mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
return of the cursor blink
This commit is contained in:
@@ -25,7 +25,7 @@ class VMGUI(val appConfig: LwjglApplicationConfiguration) : ApplicationAdapter()
|
||||
override fun create() {
|
||||
super.create()
|
||||
|
||||
gpu = GraphicsAdapter(lcdMode = false)
|
||||
gpu = GraphicsAdapter(lcdMode = true)
|
||||
|
||||
vm.peripheralTable[1] = PeripheralEntry(
|
||||
VM.PERITYPE_TERM,
|
||||
@@ -49,7 +49,7 @@ class VMGUI(val appConfig: LwjglApplicationConfiguration) : ApplicationAdapter()
|
||||
// TEST PRG
|
||||
vmRunner = VMRunnerFactory(vm, "js")
|
||||
coroutineJob = GlobalScope.launch {
|
||||
vmRunner.executeCommand(gpuTestPaletteJs)
|
||||
vmRunner.executeCommand(sanitiseJS(gpuTestPaletteJs))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -212,7 +212,7 @@ while true do
|
||||
end
|
||||
""".trimIndent()
|
||||
|
||||
private val jscode = """
|
||||
private val gpuTestPaletteJs = """
|
||||
var w = 560;
|
||||
var h = 448;
|
||||
var hwoff = 1048576;
|
||||
@@ -254,12 +254,18 @@ while (true) {
|
||||
|
||||
var tend = vm.nanoTime();
|
||||
|
||||
print("Apparent FPS: " + (1000000000 / (tend - tstart)));
|
||||
println("Apparent FPS: " + (1000000000 / (tend - tstart)));
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
private val gpuTestPaletteJs = "function print(s){vm.print(s)}eval('${jscode.replace(Regex("//[^\\n]*"), "").replace('\n', ' ')}')"
|
||||
|
||||
private val shitcode = """
|
||||
println("064 KB OK");
|
||||
println("");
|
||||
println("Starting TVDOS...");
|
||||
println("TSVM Disk Operating System, version 1.20");
|
||||
println("");
|
||||
print("C:\\\\>");
|
||||
""".trimIndent()
|
||||
|
||||
private val gpuTestPaletteJava = """
|
||||
int w = 560;
|
||||
|
||||
@@ -14,6 +14,10 @@ class VMJSR223Delegate(val vm: VM) {
|
||||
fun free(ptr: Int) = vm.free(ptr)
|
||||
|
||||
fun print(s: String) {
|
||||
//print("[Nashorn] $s")
|
||||
vm.printStream.write(s.toByteArray())
|
||||
}
|
||||
fun println(s: String) {
|
||||
//println("[Nashorn] $s")
|
||||
vm.printStream.write((s + '\n').toByteArray())
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.tsvm
|
||||
|
||||
import java.io.FileReader
|
||||
import javax.script.Compilable
|
||||
import javax.script.ScriptContext
|
||||
import javax.script.ScriptEngineManager
|
||||
@@ -53,6 +54,10 @@ object VMRunnerFactory {
|
||||
//bind.put("poke", { a: Long, b: Byte -> vm.poke(a, b) }) // kts: lambda does not work...
|
||||
//bind.put("nanotime", { System.nanoTime() })
|
||||
bind.put("serial", VMSerialDebugger(vm))
|
||||
|
||||
if (extension == "js") {
|
||||
engine.eval(toSingleLine(JS_INIT), context)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun executeCommand(command: String) {
|
||||
@@ -64,4 +69,16 @@ object VMRunnerFactory {
|
||||
//else -> throw UnsupportedOperationException("Unsupported script extension: $extension")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private val JS_INIT = """
|
||||
function print(s) {
|
||||
vm.print(s)
|
||||
}
|
||||
function println(s) {
|
||||
vm.println(s)
|
||||
}
|
||||
"""
|
||||
}
|
||||
|
||||
fun toSingleLine(code: String) = code.replace(Regex("//[^\\n]*"), "").replace('\n', ' ')
|
||||
fun sanitiseJS(code: String) = "eval('${toSingleLine(code)}')"
|
||||
|
||||
@@ -464,14 +464,16 @@ class GraphicsAdapter(val lcdMode: Boolean = false) : GlassTty(Companion.TEXT_RO
|
||||
|
||||
if (!graphicsUseSprites) {
|
||||
// draw texts
|
||||
val (cx, cy) = getCursorPos()
|
||||
|
||||
// prepare char buffer texture
|
||||
for (y in 0 until TEXT_ROWS) {
|
||||
for (x in 0 until TEXT_COLS) {
|
||||
val drawCursor = textCursorIsOn && cx == x && cy == y
|
||||
val addr = y.toLong() * TEXT_COLS + x
|
||||
val char = spriteAndTextArea[memTextOffset + addr].toInt().and(255)
|
||||
val back = spriteAndTextArea[memTextBackOffset + addr].toInt().and(255)
|
||||
val fore = spriteAndTextArea[memTextForeOffset + addr].toInt().and(255)
|
||||
val char = if (drawCursor) 0xDB else spriteAndTextArea[memTextOffset + addr].toInt().and(255)
|
||||
val back = if (drawCursor) ttyBack else spriteAndTextArea[memTextBackOffset + addr].toInt().and(255)
|
||||
val fore = if (drawCursor) ttyFore else spriteAndTextArea[memTextForeOffset + addr].toInt().and(255)
|
||||
|
||||
textPixmap.setColor(Color(0f, 0f, char / 255f, 1f))
|
||||
textPixmap.drawPixel(x, y)
|
||||
@@ -519,7 +521,7 @@ class GraphicsAdapter(val lcdMode: Boolean = false) : GlassTty(Companion.TEXT_RO
|
||||
paletteOfFloats[4 * ttyFore + 2],
|
||||
paletteOfFloats[4 * ttyFore + 3]
|
||||
)
|
||||
val (cursorx, cursory) = getTtyCursorPos()
|
||||
val (cursorx, cursory) = getCursorPos()
|
||||
batch.draw(faketex, cursorx * chrWidth, (TEXT_ROWS - cursory - 1) * chrHeight, chrWidth, chrHeight)
|
||||
}*/
|
||||
}
|
||||
|
||||
@@ -18,6 +18,5 @@ class IOSpace : PeriBase {
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user