From 411cc4974cb8f89a0c889bd0fa49794d855c07c3 Mon Sep 17 00:00:00 2001 From: mjbohn Date: Sun, 29 Jun 2025 11:27:12 +0200 Subject: [PATCH] introduced data dir to host programs and configs --- CPU_emu/CPU_emu.csproj | 6 ++++++ CPU_emu/Data/Programs/test.hex | 1 + CPU_emu/Forms/CPU_emu.cs | 7 ++++--- 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 CPU_emu/Data/Programs/test.hex diff --git a/CPU_emu/CPU_emu.csproj b/CPU_emu/CPU_emu.csproj index 96da8ce..3b56f78 100644 --- a/CPU_emu/CPU_emu.csproj +++ b/CPU_emu/CPU_emu.csproj @@ -13,6 +13,12 @@ + + + Always + + + diff --git a/CPU_emu/Data/Programs/test.hex b/CPU_emu/Data/Programs/test.hex new file mode 100644 index 0000000..b856138 --- /dev/null +++ b/CPU_emu/Data/Programs/test.hex @@ -0,0 +1 @@ +A9 ff a9 bc a2 0a a0 8d A9 00 00 00 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 \ No newline at end of file diff --git a/CPU_emu/Forms/CPU_emu.cs b/CPU_emu/Forms/CPU_emu.cs index 7a95853..2962e31 100644 --- a/CPU_emu/Forms/CPU_emu.cs +++ b/CPU_emu/Forms/CPU_emu.cs @@ -25,6 +25,7 @@ public partial class CPU_emu : Form private MemoryWatchForm MWFstack, MWFzeropage, MWFmemrange = null; private ConfigSettings config = new ConfigSettings(); + private string _configFilePath = Application.StartupPath + Path.DirectorySeparatorChar + "Data" + Path.DirectorySeparatorChar + "config.json"; public CPU_emu() { @@ -641,9 +642,9 @@ private void SetDisplayControlsVisibility(DisplayStyle style) private void CPU_emu_Load(object sender, EventArgs e) { - if (File.Exists(Application.StartupPath + Path.DirectorySeparatorChar + "config.json")) + if (File.Exists(_configFilePath)) { - config = JsonConvert.DeserializeObject(File.ReadAllText(Application.StartupPath + Path.DirectorySeparatorChar + "config.json")); + config = JsonConvert.DeserializeObject(File.ReadAllText(_configFilePath)); ApplyConfigsettings(); } @@ -720,7 +721,7 @@ private void SetMenuLabels() private void CPU_emu_FormClosing(object sender, FormClosingEventArgs e) { - File.WriteAllText(Application.StartupPath + Path.DirectorySeparatorChar + "config.json", JsonConvert.SerializeObject(config)); + File.WriteAllText(_configFilePath, JsonConvert.SerializeObject(config)); } }