Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-06 20:57:28 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-06 20:57:28 +0300
commit3a7111a4c8cb629e0c96dfb50842fb4ef3979eed (patch)
tree86162e035b96d8a7d5fa719afcdf703f63fa65db /SnesPresetEditor.cs
parent90bbb7552e5aaa9c99d23c4aa89ccac91f5669bb (diff)
New settings for SNES
Diffstat (limited to 'SnesPresetEditor.cs')
-rw-r--r--SnesPresetEditor.cs73
1 files changed, 73 insertions, 0 deletions
diff --git a/SnesPresetEditor.cs b/SnesPresetEditor.cs
new file mode 100644
index 00000000..2a31a0c4
--- /dev/null
+++ b/SnesPresetEditor.cs
@@ -0,0 +1,73 @@
+using com.clusterrr.hakchi_gui.Properties;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Diagnostics;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace com.clusterrr.hakchi_gui
+{
+ public partial class SnesPresetEditor : Form
+ {
+ SnesGame game;
+ bool wasCompressed;
+ SnesGame.SfromHeader2 header2;
+
+ public SnesPresetEditor(SnesGame game)
+ {
+ InitializeComponent();
+ try
+ {
+ wasCompressed = game.DecompressPossible().Count() > 0;
+ if (wasCompressed)
+ game.Decompress();
+ this.game = game;
+ header2 = game.ReadSfromHeader2();
+ textBoxPresetID.Text = string.Format("{0:X2}{1:X2}", header2.PresetID & 0xFF, (header2.PresetID >> 8) & 0xFF);
+ textBoxExtra.Text = string.Format("{0:X2}", header2.Chip & 0xFF);
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.Message + ex.StackTrace);
+ MessageBox.Show(this, ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void buttonOk_Click(object sender, EventArgs e)
+ {
+ try
+ {
+ var presetID = Convert.ToInt32(textBoxPresetID.Text, 16);
+ presetID = ((presetID & 0xFF) << 8) | ((presetID >> 8) & 0xFF);
+ var chip = Convert.ToInt32(textBoxExtra.Text, 16);
+ header2.PresetID = (ushort)presetID;
+ header2.Chip = (uint)chip;
+ game.WriteSfromHeader2(header2);
+ Close();
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.Message + ex.StackTrace);
+ MessageBox.Show(this, ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+
+ private void SnesPresetEditor_FormClosing(object sender, FormClosingEventArgs e)
+ {
+ try
+ {
+ if (wasCompressed)
+ game.Compress();
+ }
+ catch (Exception ex)
+ {
+ Debug.WriteLine(ex.Message + ex.StackTrace);
+ MessageBox.Show(this, ex.Message, Resources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
+ }
+ }
+ }
+}