mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-09 22:54:03 +09:00
working profiles loading and saving
This commit is contained in:
@@ -14,8 +14,8 @@ public class AppLoader {
|
|||||||
public static String appTitle = "tsvm";
|
public static String appTitle = "tsvm";
|
||||||
public static Lwjgl3ApplicationConfiguration appConfig;
|
public static Lwjgl3ApplicationConfiguration appConfig;
|
||||||
|
|
||||||
public static int WIDTH = 1080;//640;
|
public static int WIDTH = 640;//1080;//640;
|
||||||
public static int HEIGHT = 436;//480;
|
public static int HEIGHT = 480;//436;//480;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ShaderProgram.pedantic = false;
|
ShaderProgram.pedantic = false;
|
||||||
@@ -36,9 +36,9 @@ public class AppLoader {
|
|||||||
|
|
||||||
// VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, BasicRom.INSTANCE});
|
// VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, BasicRom.INSTANCE});
|
||||||
// VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{OEMBios.INSTANCE, BasicRom.INSTANCE});
|
// VM vm = new VM(64 << 10, new TheRealWorld(), new VMProgramRom[]{OEMBios.INSTANCE, BasicRom.INSTANCE});
|
||||||
VM vm = new VM("./assets", 64 << 10, new TheRealWorld(), new VMProgramRom[]{TandemBios.INSTANCE, BasicRom.INSTANCE}, 2);
|
// VM vm = new VM("./assets", 64 << 10, new TheRealWorld(), new VMProgramRom[]{TandemBios.INSTANCE, BasicRom.INSTANCE}, 2);
|
||||||
// VM vm = new VM(128 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, WPBios.INSTANCE});
|
// VM vm = new VM(128 << 10, new TheRealWorld(), new VMProgramRom[]{BasicBios.INSTANCE, WPBios.INSTANCE});
|
||||||
// VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{TsvmBios.INSTANCE}, 8);
|
VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{TsvmBios.INSTANCE}, 8);
|
||||||
// VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{OpenBios.INSTANCE}, 8);
|
// VM vm = new VM("./assets", 8192 << 10, new TheRealWorld(), new VMProgramRom[]{OpenBios.INSTANCE}, 8);
|
||||||
// VM pipvm = new VM("./assets", 4096, new TheRealWorld(), new VMProgramRom[]{PipBios.INSTANCE, PipROM.INSTANCE}, 8);
|
// VM pipvm = new VM("./assets", 4096, new TheRealWorld(), new VMProgramRom[]{PipBios.INSTANCE, PipROM.INSTANCE}, 8);
|
||||||
|
|
||||||
@@ -62,6 +62,6 @@ public class AppLoader {
|
|||||||
pipvm, 160, 140
|
pipvm, 160, 140
|
||||||
))));*/
|
))));*/
|
||||||
|
|
||||||
new Lwjgl3Application(new VMGUI(portable, WIDTH, HEIGHT), appConfig);
|
new Lwjgl3Application(new VMGUI(reference, WIDTH, HEIGHT), appConfig);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.badlogic.gdx.Gdx
|
|||||||
import com.badlogic.gdx.files.FileHandle
|
import com.badlogic.gdx.files.FileHandle
|
||||||
import com.badlogic.gdx.graphics.*
|
import com.badlogic.gdx.graphics.*
|
||||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||||
|
import com.badlogic.gdx.utils.Json
|
||||||
import com.badlogic.gdx.utils.JsonReader
|
import com.badlogic.gdx.utils.JsonReader
|
||||||
import com.badlogic.gdx.utils.JsonValue
|
import com.badlogic.gdx.utils.JsonValue
|
||||||
import com.badlogic.gdx.utils.JsonWriter
|
import com.badlogic.gdx.utils.JsonWriter
|
||||||
@@ -102,15 +103,15 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
|
|||||||
out.append('{')
|
out.append('{')
|
||||||
|
|
||||||
profiles.forEach { name, jsonValue ->
|
profiles.forEach { name, jsonValue ->
|
||||||
out.append("\"$name\":{")
|
out.append("\"$name\":")
|
||||||
out.append(jsonValue.toJson(JsonWriter.OutputType.json))
|
out.append(jsonValue.toJson(JsonWriter.OutputType.json))
|
||||||
out.append("},")
|
out.append(",")
|
||||||
|
println("[VMEmuExecutable] wrote VM profile $name")
|
||||||
}
|
}
|
||||||
|
|
||||||
out.deleteCharAt(out.lastIndex).append('}')
|
out.deleteCharAt(out.lastIndex).append('}')
|
||||||
|
|
||||||
val outstr = out.toString()
|
val outstr = out.toString()
|
||||||
println(outstr)
|
|
||||||
|
|
||||||
outFile.writeString(outstr, false)
|
outFile.writeString(outstr, false)
|
||||||
}
|
}
|
||||||
@@ -132,11 +133,13 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
|
|||||||
// create profiles.json if the file is not there
|
// create profiles.json if the file is not there
|
||||||
if (!FILE_PROFILES.exists()) {
|
if (!FILE_PROFILES.exists()) {
|
||||||
FILE_PROFILES.writeString("{${defaultProfile}}", false)
|
FILE_PROFILES.writeString("{${defaultProfile}}", false)
|
||||||
|
println("[VMEmuExecutable] creating new profile.json")
|
||||||
}
|
}
|
||||||
// read profiles
|
// read profiles
|
||||||
JsonFetcher(FILE_PROFILES.file()).let {
|
JsonFetcher(FILE_PROFILES.file()).let {
|
||||||
JsonFetcher.forEachSiblings(it) { profileName, profileJson ->
|
JsonFetcher.forEachSiblings(it) { profileName, profileJson ->
|
||||||
profiles[profileName] = profileJson
|
profiles[profileName] = profileJson
|
||||||
|
println("[VMEmuExecutable] read VM profile $profileName")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -360,6 +363,8 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
|
|||||||
fullscreenQuad.dispose()
|
fullscreenQuad.dispose()
|
||||||
coroutineJobs.values.forEach { it.cancel() }
|
coroutineJobs.values.forEach { it.cancel() }
|
||||||
vms.forEach { it?.vm?.dispose() }
|
vms.forEach { it?.vm?.dispose() }
|
||||||
|
|
||||||
|
writeProfilesToFile(Gdx.files.absolute("$APPDATADIR/profiles_new.json"))
|
||||||
}
|
}
|
||||||
|
|
||||||
private val menuTabW = windowWidth - 4
|
private val menuTabW = windowWidth - 4
|
||||||
|
|||||||
Reference in New Issue
Block a user