diff --git a/tsvm_core/src/net/torvald/tsvm/VM.kt b/tsvm_core/src/net/torvald/tsvm/VM.kt index 0fb4025..610c3c1 100644 --- a/tsvm_core/src/net/torvald/tsvm/VM.kt +++ b/tsvm_core/src/net/torvald/tsvm/VM.kt @@ -71,12 +71,7 @@ class VM( init { println("[VM] Creating new VM with ID of $id, memsize $memsize") - peripheralTable[0] = PeripheralEntry( - IOSpace(this), -// HW_RESERVE_SIZE, -// MMIO_SIZE.toInt() - 256, -// 64 - ) + peripheralTable[0] = PeripheralEntry(IOSpace(this)) } fun killAllContexts() { diff --git a/tsvm_executable/src/net/torvald/tsvm/ProfilesMenu.kt b/tsvm_executable/src/net/torvald/tsvm/ProfilesMenu.kt index 0fbe04c..292bc17 100644 --- a/tsvm_executable/src/net/torvald/tsvm/ProfilesMenu.kt +++ b/tsvm_executable/src/net/torvald/tsvm/ProfilesMenu.kt @@ -36,60 +36,68 @@ class ProfilesMenu(parent: VMEmuExecutable, x: Int, y: Int, w: Int, h: Int) : Em } + private var guiClickLatched = arrayOf(false, false, false, false, false, false, false, false) + override fun update() { if (Gdx.input.isButtonPressed(Buttons.LEFT)) { - val mx = Gdx.input.x - x - val my = Gdx.input.y - y + if (!guiClickLatched[Buttons.LEFT]) { + val mx = Gdx.input.x - x + val my = Gdx.input.y - y - // make profile list work - if (mx in 10 until 10+228) { - if (my in 11 until 11+446) { - val li = (my - 11) / (2*FONT.H) + // make profile list work + if (mx in 10 until 10 + 228) { + if (my in 11 until 11 + 446) { + val li = (my - 11) / (2 * FONT.H) - if (li < profileNames.size - profilesScroll) - selectedProfileIndex = li + profilesScroll - else - selectedProfileIndex = null + if (li < profileNames.size - profilesScroll) + selectedProfileIndex = li + profilesScroll + else + selectedProfileIndex = null + } } - } - // make controls for the selected profile work - if (selectedProfileIndex != null) profileNames[selectedProfileIndex!!].let { profileName -> - val theVM = parent.getVMbyProfileName(profileName) - if (theVM != null) { - // viewport selector - if (my in 427..453) { - if (mx in 253..640) { - val oldIndex = parent.getViewportForTheVM(theVM) - val newIndex = ((mx - 253) / 14).let { if (it == 0) null else it - 1 } + // make controls for the selected profile work + if (selectedProfileIndex != null) profileNames[selectedProfileIndex!!].let { profileName -> + val theVM = parent.getVMbyProfileName(profileName) + if (theVM != null) { + // viewport selector + if (my in 427..453) { + if (mx in 253..640) { + val oldIndex = parent.getViewportForTheVM(theVM) + val newIndex = ((mx - 253) / 14).let { if (it == 0) null else it - 1 } - if (newIndex == null || newIndex in 0 until viewportColumns * viewportRows - 1) { - if (oldIndex == null && newIndex != null) { - parent.addVMtoView(theVM, profileName, newIndex) - } - else if (oldIndex != null) { - parent.moveView(oldIndex, newIndex) + if (newIndex == null || newIndex in 0 until viewportColumns * viewportRows - 1) { + if (oldIndex == null && newIndex != null) { + parent.addVMtoView(theVM, profileName, newIndex) + } + else if (oldIndex != null) { + parent.moveView(oldIndex, newIndex) + } } } } - } - // stop and play buttons - else if (my in 375..401) { + // stop and play buttons + else if (my in 375..401) { - println("vm: $profileName; isRunning = ${theVM.isRunning}; mx = $mx") + println("vm: $profileName; isRunning = ${theVM.isRunning}; mx = $mx") - if (mx in 377..390 && theVM.isRunning) { - parent.killVMenv(theVM) - } - else if (mx in 398..412 && !theVM.isRunning) { - parent.initVMenv(theVM) + if (mx in 374..394 && theVM.isRunning) { + parent.killVMenv(theVM) + } + else if (mx in 395..415 && !theVM.isRunning) { + parent.initVMenv(theVM) + } } } + } - + guiClickLatched[Buttons.LEFT] = true } } + else { + guiClickLatched[Buttons.LEFT] = false + } } diff --git a/tsvm_executable/src/net/torvald/tsvm/VMEmuExecutable.kt b/tsvm_executable/src/net/torvald/tsvm/VMEmuExecutable.kt index d868462..04c7cbf 100644 --- a/tsvm_executable/src/net/torvald/tsvm/VMEmuExecutable.kt +++ b/tsvm_executable/src/net/torvald/tsvm/VMEmuExecutable.kt @@ -186,7 +186,7 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX: private fun changeActiveSession(index: Int?) { currentVMselection = index // TODO somehow implement the inputstream that cares about the currentVMselection - Gdx.input.inputProcessor = if (currentVMselection != null) vms[currentVMselection!!]?.vm?.getIO() else vmEmuInputProcessor + Gdx.input.inputProcessor = if (currentVMselection != null) vms[currentVMselection!!]?.vm?.getIO() ?: null else vmEmuInputProcessor } internal fun initVMenv(vm: VM) { @@ -214,6 +214,9 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX: vmRunners[vm.id]?.close() coroutineJobs[vm.id]?.cancel() + + // re-create the IOSpace (peripheral index 0) + vm.peripheralTable[0] = PeripheralEntry(IOSpace(vm)) } private fun setCameraPosition(newX: Float, newY: Float) {