working profiles loading and saving

This commit is contained in:
minjaesong
2022-10-27 23:08:42 +09:00
parent 024e97c31c
commit a7aff5a6e6
2 changed files with 13 additions and 8 deletions

View File

@@ -14,8 +14,8 @@ public class AppLoader {
public static String appTitle = "tsvm";
public static Lwjgl3ApplicationConfiguration appConfig;
public static int WIDTH = 1080;//640;
public static int HEIGHT = 436;//480;
public static int WIDTH = 640;//1080;//640;
public static int HEIGHT = 480;//436;//480;
public static void main(String[] args) {
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[]{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("./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 pipvm = new VM("./assets", 4096, new TheRealWorld(), new VMProgramRom[]{PipBios.INSTANCE, PipROM.INSTANCE}, 8);
@@ -62,6 +62,6 @@ public class AppLoader {
pipvm, 160, 140
))));*/
new Lwjgl3Application(new VMGUI(portable, WIDTH, HEIGHT), appConfig);
new Lwjgl3Application(new VMGUI(reference, WIDTH, HEIGHT), appConfig);
}
}

View File

@@ -5,6 +5,7 @@ import com.badlogic.gdx.Gdx
import com.badlogic.gdx.files.FileHandle
import com.badlogic.gdx.graphics.*
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.utils.Json
import com.badlogic.gdx.utils.JsonReader
import com.badlogic.gdx.utils.JsonValue
import com.badlogic.gdx.utils.JsonWriter
@@ -102,15 +103,15 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
out.append('{')
profiles.forEach { name, jsonValue ->
out.append("\"$name\":{")
out.append("\"$name\":")
out.append(jsonValue.toJson(JsonWriter.OutputType.json))
out.append("},")
out.append(",")
println("[VMEmuExecutable] wrote VM profile $name")
}
out.deleteCharAt(out.lastIndex).append('}')
val outstr = out.toString()
println(outstr)
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
if (!FILE_PROFILES.exists()) {
FILE_PROFILES.writeString("{${defaultProfile}}", false)
println("[VMEmuExecutable] creating new profile.json")
}
// read profiles
JsonFetcher(FILE_PROFILES.file()).let {
JsonFetcher.forEachSiblings(it) { 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()
coroutineJobs.values.forEach { it.cancel() }
vms.forEach { it?.vm?.dispose() }
writeProfilesToFile(Gdx.files.absolute("$APPDATADIR/profiles_new.json"))
}
private val menuTabW = windowWidth - 4