mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
TEVD debugger proof-of-concept
This commit is contained in:
@@ -3,6 +3,7 @@ package net.torvald.tsvm
|
||||
import com.badlogic.gdx.Audio
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.reflection.extortField
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.toUint
|
||||
import net.torvald.tsvm.EmulatorGuiToolkit.Theme.COL_ACTIVE3
|
||||
import net.torvald.tsvm.EmulatorGuiToolkit.Theme.COL_HIGHLIGHT2
|
||||
@@ -182,17 +183,5 @@ class AudioMenu(parent: VMEmuExecutable, x: Int, y: Int, w: Int, h: Int) : EmuMe
|
||||
override fun dispose() {
|
||||
}
|
||||
|
||||
private fun Any.extortField(name: String): Any? { // yes I'm deliberately using negative words for the function name
|
||||
return this.javaClass.getDeclaredField(name).let {
|
||||
it.isAccessible = true
|
||||
it.get(this)
|
||||
}
|
||||
}
|
||||
private fun Any.forceInvoke(name: String, params: Array<Any>): Any? { // yes I'm deliberately using negative words for the function name
|
||||
return this.javaClass.getDeclaredMethod(name, *(params.map { it.javaClass }.toTypedArray())).let {
|
||||
it.isAccessible = true
|
||||
it.invoke(this, *params)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,11 @@ package net.torvald.tsvm
|
||||
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.reflection.extortField
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.EntryID
|
||||
import net.torvald.terrarum.modulecomputers.virtualcomputer.tvd.PartialDOM
|
||||
import net.torvald.tsvm.VMEmuExecutableWrapper.Companion.FONT
|
||||
import net.torvald.tsvm.peripheral.TevdDiskDrive
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2023-03-25.
|
||||
@@ -20,10 +24,33 @@ class TevdMenu(parent: VMEmuExecutable, x: Int, y: Int, w: Int, h: Int) : EmuMen
|
||||
|
||||
override fun render(batch: SpriteBatch) {
|
||||
|
||||
batch.inUse {
|
||||
batch.color = Color.CORAL
|
||||
FONT.draw(batch, "Tevd!", 12f, 12f)
|
||||
val dev = parent.currentlyPersistentVM?.vm?.getIO()?.blockTransferPorts?.getOrNull(cardIndex ?: -1)?.recipient
|
||||
|
||||
if (dev?.javaClass?.simpleName == "TevdDiskDrive") {
|
||||
val dev = dev as TevdDiskDrive
|
||||
val DOM = dev.extortField("DOM") as PartialDOM
|
||||
val DOMfileCache = DOM.extortField("fileCache") as HashMap<EntryID, *>
|
||||
|
||||
batch.inUse {
|
||||
batch.color = Color.WHITE
|
||||
FONT.draw(batch, "Disk UUID: ${dev.diskUUIDstr}", 12f, 12f)
|
||||
FONT.draw(batch, "F I L E C A C H E", 12f, 12f+FONT.H)
|
||||
var row = 2
|
||||
DOMfileCache.forEach { (id, entry) ->
|
||||
val str = "ID $id"
|
||||
FONT.draw(batch, str, 12f, 12f + FONT.H * row)
|
||||
|
||||
row += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
batch.inUse {
|
||||
batch.color = Color.WHITE
|
||||
FONT.draw(batch, "Device is not TevdDiskDrive", 12f, 12f)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user