mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-03-07 19:51:51 +09:00
temporarily using threads instead of who-knows-what-the-fucks-have-changed new coroutine
This commit is contained in:
@@ -8,8 +8,6 @@ import com.badlogic.gdx.graphics.*
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.utils.JsonValue
|
||||
import com.badlogic.gdx.utils.JsonWriter
|
||||
import kotlin.coroutines.Job
|
||||
import kotlin.coroutines.cancel
|
||||
import net.torvald.terrarum.DefaultGL32Shaders
|
||||
import net.torvald.terrarum.FlippingSpriteBatch
|
||||
import net.torvald.terrarum.imagefont.TinyAlphNum
|
||||
@@ -85,7 +83,7 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
|
||||
lateinit var camera: OrthographicCamera
|
||||
|
||||
var vmRunners = HashMap<VmId, VMRunner>() // <VM's identifier, VMRunner>
|
||||
var coroutineJobs = HashMap<VmId, Job>() // <VM's identifier, Job>
|
||||
var coroutineJobs = HashMap<VmId, Thread>() // <VM's identifier, Job>
|
||||
|
||||
companion object {
|
||||
val APPDATADIR = TsvmEmulator.defaultDir
|
||||
@@ -277,7 +275,7 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
|
||||
val vm = currentlyLoadedProfiles[profileName]!!
|
||||
|
||||
vmRunners[vm.id]!!.close()
|
||||
coroutineJobs[vm.id]!!.cancel("reboot requested")
|
||||
coroutineJobs[vm.id]!!.interrupt()
|
||||
|
||||
vm.init()
|
||||
initVMenv(vm, profileName)
|
||||
@@ -406,7 +404,7 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
|
||||
batch.dispose()
|
||||
fbatch.dispose()
|
||||
fullscreenQuad.dispose()
|
||||
coroutineJobs.values.forEach { it.cancel() }
|
||||
coroutineJobs.values.forEach { it.interrupt() }
|
||||
vms.forEach { it?.vm?.dispose() }
|
||||
|
||||
writeProfilesToFile(Gdx.files.absolute("$APPDATADIR/profiles.json"))
|
||||
|
||||
@@ -43,7 +43,7 @@ class VMGUI(val loaderInfo: EmulInstance, val viewportWidth: Int, val viewportHe
|
||||
|
||||
var gpu: GraphicsAdapter? = null
|
||||
lateinit var vmRunner: VMRunner
|
||||
lateinit var coroutineJob: Job
|
||||
lateinit var coroutineJob: Thread
|
||||
lateinit var memvwr: Memvwr
|
||||
lateinit var fullscreenQuad: Mesh
|
||||
|
||||
@@ -115,16 +115,16 @@ class VMGUI(val loaderInfo: EmulInstance, val viewportWidth: Int, val viewportHe
|
||||
|
||||
|
||||
vmRunner = VMRunnerFactory(vm.assetsDir, vm, "js")
|
||||
coroutineJob = GlobalScope.launch {
|
||||
coroutineJob = Thread({
|
||||
vmRunner.executeCommand(vm.roms[0]!!.readAll())
|
||||
}
|
||||
}, "VmRunner:${vm.id}")
|
||||
}
|
||||
|
||||
private var rebootRequested = false
|
||||
|
||||
private fun reboot() {
|
||||
vmRunner.close()
|
||||
coroutineJob.cancel("reboot requested")
|
||||
coroutineJob.interrupt()
|
||||
|
||||
vm.init()
|
||||
init()
|
||||
@@ -217,7 +217,7 @@ class VMGUI(val loaderInfo: EmulInstance, val viewportWidth: Int, val viewportHe
|
||||
super.dispose()
|
||||
batch.dispose()
|
||||
fullscreenQuad.dispose()
|
||||
coroutineJob.cancel()
|
||||
coroutineJob.interrupt()
|
||||
vm.dispose()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user