mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 11:51:49 +09:00
RESET button impl but won't boot after the reset
This commit is contained in:
@@ -45,7 +45,7 @@ class VM(
|
||||
var getErrorStream: () -> OutputStream = { TODO() }
|
||||
var getInputStream: () -> InputStream = { TODO() }
|
||||
|
||||
val startTime: Long
|
||||
var startTime: Long = -1
|
||||
|
||||
var resetDown = false
|
||||
var stopDown = false
|
||||
@@ -54,6 +54,10 @@ class VM(
|
||||
internal set
|
||||
|
||||
init {
|
||||
init()
|
||||
}
|
||||
|
||||
fun init() {
|
||||
peripheralTable[0] = PeripheralEntry(
|
||||
"io",
|
||||
IOSpace(this),
|
||||
|
||||
@@ -84,6 +84,17 @@ class VMGUI(val loaderInfo: EmulInstance) : ApplicationAdapter() {
|
||||
}
|
||||
}
|
||||
|
||||
private var rebootRequested = false
|
||||
|
||||
private fun reboot() {
|
||||
coroutineJob.cancel("reboot requested")
|
||||
|
||||
vmRunner = VMRunnerFactory(vm, "js")
|
||||
coroutineJob = GlobalScope.launch {
|
||||
vmRunner.executeCommand(vm.roms[0]!!.readAll())
|
||||
}
|
||||
}
|
||||
|
||||
private var updateAkku = 0.0
|
||||
private var updateRate = 1f / 60f
|
||||
|
||||
@@ -113,14 +124,21 @@ class VMGUI(val loaderInfo: EmulInstance) : ApplicationAdapter() {
|
||||
private var latch = true
|
||||
|
||||
private fun updateGame(delta: Float) {
|
||||
if (!vm.resetDown && rebootRequested) {
|
||||
reboot()
|
||||
vm.init()
|
||||
rebootRequested = false
|
||||
}
|
||||
|
||||
vm.update(delta)
|
||||
|
||||
if (vm.resetDown) rebootRequested = true
|
||||
}
|
||||
|
||||
fun poke(addr: Long, value: Byte) = vm.poke(addr, value)
|
||||
|
||||
private fun renderGame(delta: Float) {
|
||||
gpu.render(delta, batch, 0f, 0f)
|
||||
//batch.inUse { batch.draw(testTex, 0f, 0f) }
|
||||
}
|
||||
|
||||
private fun setCameraPosition(newX: Float, newY: Float) {
|
||||
|
||||
Reference in New Issue
Block a user