Added Key System editor

This commit is contained in:
suloku
2016-03-08 16:24:45 +01:00
parent 93bbbc0bd6
commit 5de5a4d6a1
6 changed files with 907 additions and 1 deletions

View File

@@ -50,6 +50,10 @@
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Editors\KeySystem.cs" />
<Compile Include="Editors\KeySystem.Designer.cs">
<DependentUpon>KeySystem.cs</DependentUpon>
</Compile>
<Compile Include="Editors\Text.cs" />
<Compile Include="Editors\Dumper.cs" />
<Compile Include="Editors\Dumper.Designer.cs">
@@ -98,6 +102,9 @@
<EmbeddedResource Include="Editors\Grotto.resx">
<DependentUpon>Grotto.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Editors\KeySystem.resx">
<DependentUpon>KeySystem.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Editors\Medals.resx">
<DependentUpon>Medals.cs</DependentUpon>
</EmbeddedResource>

436
BW_tool/Editors/KeySystem.Designer.cs generated Normal file
View File

@@ -0,0 +1,436 @@
/*
* Created by SharpDevelop.
* User: suloku
* Date: 08/03/2016
* Time: 13:54
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
namespace BW_tool
{
partial class KeySystem
{
/// <summary>
/// Designer variable used to keep track of non-visual components.
/// </summary>
private System.ComponentModel.IContainer components = null;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.CheckBox icebergkeybox;
private System.Windows.Forms.CheckBox easykeybox;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.CheckBox ironkeybox;
private System.Windows.Forms.CheckBox challengekeybox;
private System.Windows.Forms.CheckBox citykeybox;
private System.Windows.Forms.GroupBox groupBox3;
private System.Windows.Forms.CheckBox challengemodebox;
private System.Windows.Forms.CheckBox easymodebox;
private System.Windows.Forms.CheckBox icebergbox;
private System.Windows.Forms.CheckBox ironbox;
private System.Windows.Forms.CheckBox citybox;
private System.Windows.Forms.RadioButton cfg_chamber_ice;
private System.Windows.Forms.RadioButton cfg_chamber_iron;
private System.Windows.Forms.RadioButton cfg_chamber_rock;
private System.Windows.Forms.RadioButton cfg_chamber_def;
private System.Windows.Forms.RadioButton cfg_city_foreing;
private System.Windows.Forms.RadioButton cfg_city_game;
private System.Windows.Forms.RadioButton cfg_city_def;
private System.Windows.Forms.RadioButton cfg_mode_3;
private System.Windows.Forms.RadioButton cfg_mode_2;
private System.Windows.Forms.RadioButton cfg_mode_1;
private System.Windows.Forms.RadioButton cfg_mode_def;
private System.Windows.Forms.Button Saveexit_but;
private System.Windows.Forms.Button Exit_but;
private System.Windows.Forms.GroupBox groupBox4;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.GroupBox groupBox6;
/// <summary>
/// Disposes resources used by the form.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing) {
if (components != null) {
components.Dispose();
}
}
base.Dispose(disposing);
}
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.icebergkeybox = new System.Windows.Forms.CheckBox();
this.easykeybox = new System.Windows.Forms.CheckBox();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.ironkeybox = new System.Windows.Forms.CheckBox();
this.challengekeybox = new System.Windows.Forms.CheckBox();
this.citykeybox = new System.Windows.Forms.CheckBox();
this.groupBox3 = new System.Windows.Forms.GroupBox();
this.icebergbox = new System.Windows.Forms.CheckBox();
this.ironbox = new System.Windows.Forms.CheckBox();
this.citybox = new System.Windows.Forms.CheckBox();
this.challengemodebox = new System.Windows.Forms.CheckBox();
this.easymodebox = new System.Windows.Forms.CheckBox();
this.Saveexit_but = new System.Windows.Forms.Button();
this.Exit_but = new System.Windows.Forms.Button();
this.cfg_mode_def = new System.Windows.Forms.RadioButton();
this.cfg_mode_1 = new System.Windows.Forms.RadioButton();
this.cfg_mode_2 = new System.Windows.Forms.RadioButton();
this.cfg_mode_3 = new System.Windows.Forms.RadioButton();
this.cfg_city_def = new System.Windows.Forms.RadioButton();
this.cfg_city_game = new System.Windows.Forms.RadioButton();
this.cfg_city_foreing = new System.Windows.Forms.RadioButton();
this.cfg_chamber_def = new System.Windows.Forms.RadioButton();
this.cfg_chamber_rock = new System.Windows.Forms.RadioButton();
this.cfg_chamber_iron = new System.Windows.Forms.RadioButton();
this.cfg_chamber_ice = new System.Windows.Forms.RadioButton();
this.groupBox4 = new System.Windows.Forms.GroupBox();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBox6.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
//
this.groupBox1.Controls.Add(this.icebergkeybox);
this.groupBox1.Controls.Add(this.easykeybox);
this.groupBox1.Location = new System.Drawing.Point(23, 12);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(210, 77);
this.groupBox1.TabIndex = 0;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "White 2 Keys";
//
// icebergkeybox
//
this.icebergkeybox.Location = new System.Drawing.Point(6, 43);
this.icebergkeybox.Name = "icebergkeybox";
this.icebergkeybox.Size = new System.Drawing.Size(141, 24);
this.icebergkeybox.TabIndex = 1;
this.icebergkeybox.Text = "Iceberg Chamber Key";
this.icebergkeybox.UseVisualStyleBackColor = true;
//
// easykeybox
//
this.easykeybox.Location = new System.Drawing.Point(6, 19);
this.easykeybox.Name = "easykeybox";
this.easykeybox.Size = new System.Drawing.Size(104, 24);
this.easykeybox.TabIndex = 0;
this.easykeybox.Text = "Easy Mode Key";
this.easykeybox.UseVisualStyleBackColor = true;
//
// groupBox2
//
this.groupBox2.Controls.Add(this.ironkeybox);
this.groupBox2.Controls.Add(this.challengekeybox);
this.groupBox2.Location = new System.Drawing.Point(239, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(210, 77);
this.groupBox2.TabIndex = 1;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "Black 2 Keys";
//
// ironkeybox
//
this.ironkeybox.Location = new System.Drawing.Point(6, 43);
this.ironkeybox.Name = "ironkeybox";
this.ironkeybox.Size = new System.Drawing.Size(141, 24);
this.ironkeybox.TabIndex = 2;
this.ironkeybox.Text = "Iron Chamber Key";
this.ironkeybox.UseVisualStyleBackColor = true;
//
// challengekeybox
//
this.challengekeybox.Location = new System.Drawing.Point(6, 19);
this.challengekeybox.Name = "challengekeybox";
this.challengekeybox.Size = new System.Drawing.Size(104, 24);
this.challengekeybox.TabIndex = 1;
this.challengekeybox.Text = "Challenge Mode Key";
this.challengekeybox.UseVisualStyleBackColor = true;
//
// citykeybox
//
this.citykeybox.Location = new System.Drawing.Point(164, 95);
this.citykeybox.Name = "citykeybox";
this.citykeybox.Size = new System.Drawing.Size(138, 24);
this.citykeybox.TabIndex = 2;
this.citykeybox.Text = "Tower/Treehollow Key";
this.citykeybox.UseVisualStyleBackColor = true;
//
// groupBox3
//
this.groupBox3.Controls.Add(this.icebergbox);
this.groupBox3.Controls.Add(this.ironbox);
this.groupBox3.Controls.Add(this.citybox);
this.groupBox3.Controls.Add(this.challengemodebox);
this.groupBox3.Controls.Add(this.easymodebox);
this.groupBox3.Location = new System.Drawing.Point(29, 125);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(423, 79);
this.groupBox3.TabIndex = 3;
this.groupBox3.TabStop = false;
this.groupBox3.Text = "Unlockables";
//
// icebergbox
//
this.icebergbox.Location = new System.Drawing.Point(291, 42);
this.icebergbox.Name = "icebergbox";
this.icebergbox.Size = new System.Drawing.Size(115, 24);
this.icebergbox.TabIndex = 6;
this.icebergbox.Text = "Iceberg Chamber";
this.icebergbox.UseVisualStyleBackColor = true;
//
// ironbox
//
this.ironbox.Location = new System.Drawing.Point(291, 19);
this.ironbox.Name = "ironbox";
this.ironbox.Size = new System.Drawing.Size(104, 24);
this.ironbox.TabIndex = 5;
this.ironbox.Text = "Iron Chamber";
this.ironbox.UseVisualStyleBackColor = true;
//
// citybox
//
this.citybox.Location = new System.Drawing.Point(139, 19);
this.citybox.Name = "citybox";
this.citybox.Size = new System.Drawing.Size(146, 24);
this.citybox.TabIndex = 4;
this.citybox.Text = "Black City/White Forest";
this.citybox.UseVisualStyleBackColor = true;
//
// challengemodebox
//
this.challengemodebox.Location = new System.Drawing.Point(6, 42);
this.challengemodebox.Name = "challengemodebox";
this.challengemodebox.Size = new System.Drawing.Size(104, 24);
this.challengemodebox.TabIndex = 3;
this.challengemodebox.Text = "Challenge Mode";
this.challengemodebox.UseVisualStyleBackColor = true;
//
// easymodebox
//
this.easymodebox.Location = new System.Drawing.Point(6, 19);
this.easymodebox.Name = "easymodebox";
this.easymodebox.Size = new System.Drawing.Size(104, 24);
this.easymodebox.TabIndex = 2;
this.easymodebox.Text = "Easy Mode";
this.easymodebox.UseVisualStyleBackColor = true;
//
// Saveexit_but
//
this.Saveexit_but.Location = new System.Drawing.Point(350, 334);
this.Saveexit_but.Name = "Saveexit_but";
this.Saveexit_but.Size = new System.Drawing.Size(102, 23);
this.Saveexit_but.TabIndex = 5;
this.Saveexit_but.Text = "Save and Exit";
this.Saveexit_but.UseVisualStyleBackColor = true;
this.Saveexit_but.Click += new System.EventHandler(this.Saveexit_butClick);
//
// Exit_but
//
this.Exit_but.Location = new System.Drawing.Point(29, 334);
this.Exit_but.Name = "Exit_but";
this.Exit_but.Size = new System.Drawing.Size(102, 23);
this.Exit_but.TabIndex = 6;
this.Exit_but.Text = "Exit";
this.Exit_but.UseVisualStyleBackColor = true;
this.Exit_but.Click += new System.EventHandler(this.Exit_butClick);
//
// cfg_mode_def
//
this.cfg_mode_def.Enabled = false;
this.cfg_mode_def.Location = new System.Drawing.Point(6, 16);
this.cfg_mode_def.Name = "cfg_mode_def";
this.cfg_mode_def.Size = new System.Drawing.Size(104, 24);
this.cfg_mode_def.TabIndex = 0;
this.cfg_mode_def.TabStop = true;
this.cfg_mode_def.Text = "Default";
this.cfg_mode_def.UseVisualStyleBackColor = true;
//
// cfg_mode_1
//
this.cfg_mode_1.Enabled = false;
this.cfg_mode_1.Location = new System.Drawing.Point(6, 36);
this.cfg_mode_1.Name = "cfg_mode_1";
this.cfg_mode_1.Size = new System.Drawing.Size(104, 24);
this.cfg_mode_1.TabIndex = 1;
this.cfg_mode_1.TabStop = true;
this.cfg_mode_1.Text = "Easy Mode";
this.cfg_mode_1.UseVisualStyleBackColor = true;
//
// cfg_mode_2
//
this.cfg_mode_2.Enabled = false;
this.cfg_mode_2.Location = new System.Drawing.Point(6, 55);
this.cfg_mode_2.Name = "cfg_mode_2";
this.cfg_mode_2.Size = new System.Drawing.Size(104, 24);
this.cfg_mode_2.TabIndex = 2;
this.cfg_mode_2.TabStop = true;
this.cfg_mode_2.Text = "Normal Mode";
this.cfg_mode_2.UseVisualStyleBackColor = true;
//
// cfg_mode_3
//
this.cfg_mode_3.Enabled = false;
this.cfg_mode_3.Location = new System.Drawing.Point(6, 74);
this.cfg_mode_3.Name = "cfg_mode_3";
this.cfg_mode_3.Size = new System.Drawing.Size(104, 24);
this.cfg_mode_3.TabIndex = 3;
this.cfg_mode_3.TabStop = true;
this.cfg_mode_3.Text = "Challenge Mode";
this.cfg_mode_3.UseVisualStyleBackColor = true;
//
// cfg_city_def
//
this.cfg_city_def.Enabled = false;
this.cfg_city_def.Location = new System.Drawing.Point(13, 17);
this.cfg_city_def.Name = "cfg_city_def";
this.cfg_city_def.Size = new System.Drawing.Size(104, 23);
this.cfg_city_def.TabIndex = 4;
this.cfg_city_def.TabStop = true;
this.cfg_city_def.Text = "Default";
this.cfg_city_def.UseVisualStyleBackColor = true;
//
// cfg_city_game
//
this.cfg_city_game.Enabled = false;
this.cfg_city_game.Location = new System.Drawing.Point(13, 38);
this.cfg_city_game.Name = "cfg_city_game";
this.cfg_city_game.Size = new System.Drawing.Size(104, 20);
this.cfg_city_game.TabIndex = 5;
this.cfg_city_game.TabStop = true;
this.cfg_city_game.Text = "Game\'s City";
this.cfg_city_game.UseVisualStyleBackColor = true;
//
// cfg_city_foreing
//
this.cfg_city_foreing.Enabled = false;
this.cfg_city_foreing.Location = new System.Drawing.Point(13, 56);
this.cfg_city_foreing.Name = "cfg_city_foreing";
this.cfg_city_foreing.Size = new System.Drawing.Size(104, 22);
this.cfg_city_foreing.TabIndex = 6;
this.cfg_city_foreing.TabStop = true;
this.cfg_city_foreing.Text = "Foreign City";
this.cfg_city_foreing.UseVisualStyleBackColor = true;
//
// cfg_chamber_def
//
this.cfg_chamber_def.Enabled = false;
this.cfg_chamber_def.Location = new System.Drawing.Point(22, 16);
this.cfg_chamber_def.Name = "cfg_chamber_def";
this.cfg_chamber_def.Size = new System.Drawing.Size(104, 24);
this.cfg_chamber_def.TabIndex = 7;
this.cfg_chamber_def.TabStop = true;
this.cfg_chamber_def.Text = "Default";
this.cfg_chamber_def.UseVisualStyleBackColor = true;
//
// cfg_chamber_rock
//
this.cfg_chamber_rock.Enabled = false;
this.cfg_chamber_rock.Location = new System.Drawing.Point(22, 36);
this.cfg_chamber_rock.Name = "cfg_chamber_rock";
this.cfg_chamber_rock.Size = new System.Drawing.Size(104, 24);
this.cfg_chamber_rock.TabIndex = 8;
this.cfg_chamber_rock.TabStop = true;
this.cfg_chamber_rock.Text = "Rock Chamber";
this.cfg_chamber_rock.UseVisualStyleBackColor = true;
//
// cfg_chamber_iron
//
this.cfg_chamber_iron.Enabled = false;
this.cfg_chamber_iron.Location = new System.Drawing.Point(22, 55);
this.cfg_chamber_iron.Name = "cfg_chamber_iron";
this.cfg_chamber_iron.Size = new System.Drawing.Size(104, 24);
this.cfg_chamber_iron.TabIndex = 9;
this.cfg_chamber_iron.TabStop = true;
this.cfg_chamber_iron.Text = "Iron Chamber";
this.cfg_chamber_iron.UseVisualStyleBackColor = true;
//
// cfg_chamber_ice
//
this.cfg_chamber_ice.Enabled = false;
this.cfg_chamber_ice.Location = new System.Drawing.Point(22, 74);
this.cfg_chamber_ice.Name = "cfg_chamber_ice";
this.cfg_chamber_ice.Size = new System.Drawing.Size(115, 24);
this.cfg_chamber_ice.TabIndex = 10;
this.cfg_chamber_ice.TabStop = true;
this.cfg_chamber_ice.Text = "Iceberg Chamber";
this.cfg_chamber_ice.UseVisualStyleBackColor = true;
//
// groupBox4
//
this.groupBox4.Controls.Add(this.cfg_mode_3);
this.groupBox4.Controls.Add(this.cfg_mode_2);
this.groupBox4.Controls.Add(this.cfg_mode_def);
this.groupBox4.Controls.Add(this.cfg_mode_1);
this.groupBox4.Location = new System.Drawing.Point(29, 213);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(116, 100);
this.groupBox4.TabIndex = 11;
this.groupBox4.TabStop = false;
this.groupBox4.Text = "Difficulty config:";
//
// groupBox5
//
this.groupBox5.Controls.Add(this.cfg_city_foreing);
this.groupBox5.Controls.Add(this.cfg_city_game);
this.groupBox5.Controls.Add(this.cfg_city_def);
this.groupBox5.Location = new System.Drawing.Point(151, 213);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(136, 100);
this.groupBox5.TabIndex = 12;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "City config:";
//
// groupBox6
//
this.groupBox6.Controls.Add(this.cfg_chamber_iron);
this.groupBox6.Controls.Add(this.cfg_chamber_rock);
this.groupBox6.Controls.Add(this.cfg_chamber_def);
this.groupBox6.Controls.Add(this.cfg_chamber_ice);
this.groupBox6.Location = new System.Drawing.Point(293, 213);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(159, 100);
this.groupBox6.TabIndex = 13;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "Chamber config:";
//
// KeySystem
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(479, 369);
this.Controls.Add(this.groupBox6);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.Exit_but);
this.Controls.Add(this.Saveexit_but);
this.Controls.Add(this.groupBox3);
this.Controls.Add(this.citykeybox);
this.Controls.Add(this.groupBox2);
this.Controls.Add(this.groupBox1);
this.Name = "KeySystem";
this.Text = "KeySystem";
this.groupBox1.ResumeLayout(false);
this.groupBox2.ResumeLayout(false);
this.groupBox3.ResumeLayout(false);
this.groupBox4.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox6.ResumeLayout(false);
this.ResumeLayout(false);
}
}
}

View File

@@ -0,0 +1,321 @@
/*
* Created by SharpDevelop.
* User: suloku
* Date: 08/03/2016
* Time: 13:54
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Drawing;
using System.Windows.Forms;
namespace BW_tool
{
/// <summary>
/// Description of KeySystem.
/// </summary>
public partial class KeySystem : Form
{
KEY keys;
int keyblock = 69;
public KeySystem()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
keys = new KEY(MainForm.save.getBlock(keyblock));
if (keys.KeysUnlocked() == false)
MessageBox.Show("\t\tWarning!\n\nThis savefile doesn't seem to have unlocked the key system yet.\nKey system is unlocked after beating the Elite Four.\n\nYou can still edit it though.");
updatekeys();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
public void updatekeys()
{
easykeybox.Checked = keys.getKeyState(0);
challengekeybox.Checked = keys.getKeyState(1);
citykeybox.Checked = keys.getKeyState(2);
ironkeybox.Checked = keys.getKeyState(3);
icebergkeybox.Checked = keys.getKeyState(4);
easymodebox.Checked = keys.getKeyState(5);
challengemodebox.Checked = keys.getKeyState(6);
citybox.Checked = keys.getKeyState(7);
ironbox.Checked = keys.getKeyState(8);
icebergbox.Checked = keys.getKeyState(9);
switch(keys.getConfig(0))
{
case 0:
cfg_mode_def.Checked = true;
break;
case 1:
cfg_mode_1.Checked = true;
break;
case 2:
cfg_mode_2.Checked = true;
break;
case 3:
cfg_mode_3.Checked = true;
break;
}
switch(keys.getConfig(1))
{
case 0:
cfg_city_def.Checked = true;
break;
case 1:
cfg_city_game.Checked = true;
break;
case 2:
cfg_city_foreing.Checked = true;
break;
}
switch(keys.getConfig(2))
{
case 0:
cfg_chamber_def.Checked = true;
break;
case 1:
cfg_chamber_rock.Checked = true;
break;
case 2:
cfg_chamber_iron.Checked = true;
break;
case 3:
cfg_chamber_ice.Checked = true;
break;
}
}
public void setAllkeys()
{
keys.setKey(easykeybox.Checked, 0);
keys.setKey(challengekeybox.Checked, 1);
keys.setKey(citykeybox.Checked, 2);
keys.setKey(ironkeybox.Checked, 3);
keys.setKey(icebergkeybox.Checked, 4);
keys.setKey(easymodebox.Checked, 5);
keys.setKey(challengemodebox.Checked, 6);
keys.setKey(citybox.Checked, 7);
keys.setKey(ironbox.Checked, 8);
keys.setKey(icebergbox.Checked, 9);
}
void Exit_butClick(object sender, EventArgs e)
{
this.Close();
}
void Saveexit_butClick(object sender, EventArgs e)
{
setAllkeys();
MainForm.save.setBlock(keys.Data, keyblock);
this.Close();
}
public class KEY
{
internal int Size = MainForm.save.getBlockLength(69);
public byte[] Data;
public KEY(byte[] data = null)
{
Data = data ?? new byte[Size];
}
/*
0x00-0x07 - Unknown
0x08-0x17 - Seems always 0x00
0x18-0x27 - Unknown
0x28 - Easy key (W) - 0x00035691
0x2C - Challenge key (B) - 0x00018256
0x30 - Tower Key (B)/ Treehollow key (W) - 0x00059389
0x34 - Iron Key (B) - 0x00048292
0x38 - Iceberg Key (W) - 0x00009892
0x3C - Easy mode unlocked - 0x00093389
0x40 - Challenge mode unlocked - 0x00022843
0x44 - Black City / White forest unlocked - 0x00034771
0x48 - Iron chamber unlocked - 0x000AB031
0x4C - Iceberg chamber unlocked - 0x000B3818
0x50 - Difficulty config (easy 0x00031239 | normal 0x00015657 | challenge 0x00049589)
0x54 - Black city/White city config (black city 0x00034525| white city 0x00011963)
0x58 - Chamber config (rock 0x00094525 | iron 0x00081963 | iceberg 0x00038569)
0x5C - Unique ID used to xor the keys (also present in memory link block)
0x60 - Counter
0x62 - ccrit checksum
*/
private const UInt32 easykey = 0x00035691;
private const UInt32 challengekey = 0x00018256;
private const UInt32 citykey = 0x00059389;
private const UInt32 ironkey = 0x00048292;
private const UInt32 icebergkey = 0x00009892;
private const UInt32 easy_u = 0x00093389;
private const UInt32 challenge_u = 0x00022843;
private const UInt32 city_u = 0x00034771;
private const UInt32 iron_u = 0x000AB031;
private const UInt32 iceberg_u = 0x000B3818;
private UInt32[] difficult_cfg = new UInt32[4] {0x0, 0x00031239,0x00015657,0x00049589};
private UInt32[] city_cfg = new UInt32[3] {0x0, 0x00034525,0x00011963};
private UInt32[] chamber_cfg = new UInt32[4] {0x0, 0x00094525, 0x00081963, 0x00038569};
private const UInt32 zero = 0;
public bool KeysUnlocked()
{
int i = 0;
for (i=0;i<0x5C;i++)
{
if (Data[i] != 0x00)
return true;
}
return false;
}
public int getConfig(int configIndex)
{
int i;
if (configIndex == 0)
{
for (i=0;i<4;i++)
{
if (getKeyXor(10) == difficult_cfg[i])
{
return i;
break;
}
}
return 0;
}
else if (configIndex == 1)
{
for (i=0;i<3;i++)
{
if (getKeyXor(11) == city_cfg[i])
{
return i;
break;
}
}
return 0;
}
else if (configIndex == 2)
{
for (i=0;i<4;i++)
{
if (getKeyXor(12) == chamber_cfg[i])
{
return i;
break;
}
}
return 0;
}else
{
return 0;
}
}
private UInt32 getKey(int keyIndex)
{
return BitConverter.ToUInt32(Data, 0x28+(keyIndex*4));
}
private UInt32 getKeyXor(int keyIndex)
{
return getKey(keyIndex)^ID;
}
public bool getKeyState(int keyIndex)
{
switch (getKeyXor(keyIndex))
{
case easykey:
return true;
break;
case challengekey:
return true;
break;
case citykey:
return true;
break;
case ironkey:
return true;
break;
case icebergkey:
return true;
break;
case easy_u:
return true;
break;
case challenge_u:
return true;
break;
case city_u:
return true;
break;
case iron_u:
return true;
break;
case iceberg_u:
return true;
break;
default:
return false;
break;
}
}
public void setKey(bool state, int keyIndex)
{
if (state == false)
{
Array.Copy(BitConverter.GetBytes(zero), 0, Data, 0x28+(keyIndex*4), 4);
}
else
{
UInt32 xorkey;
switch (keyIndex)
{
case 0:
xorkey = easykey;
break;
case 1:
xorkey = challengekey;
break;
case 2:
xorkey = citykey;
break;
case 3:
xorkey = ironkey;
break;
case 4:
xorkey = icebergkey;
break;
case 5:
xorkey = easy_u;
break;
case 6:
xorkey = challenge_u;
break;
case 7:
xorkey = city_u;
break;
case 8:
xorkey = iron_u;
break;
case 9:
xorkey = iceberg_u;
break;
default: //Invalid index, this should never happen
xorkey = zero;
break;
}
Array.Copy(BitConverter.GetBytes((ID^xorkey)), 0, Data, 0x28+(keyIndex*4), 4);
}
}
private UInt32 id;
private UInt32 ID {
get { return BitConverter.ToUInt32(Data, 0x5C); }
set { BitConverter.GetBytes(value).CopyTo(Data, 0x5C); } }
}
}
}

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@@ -25,6 +25,7 @@ namespace BW_tool
private System.Windows.Forms.Button trainer_records_but;
private System.Windows.Forms.Button medal_but;
private System.Windows.Forms.Button forest_but;
private System.Windows.Forms.Button key_but;
/// <summary>
/// Disposes resources used by the form.
@@ -58,6 +59,7 @@ namespace BW_tool
this.trainer_records_but = new System.Windows.Forms.Button();
this.medal_but = new System.Windows.Forms.Button();
this.forest_but = new System.Windows.Forms.Button();
this.key_but = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// loadsave_but
@@ -173,11 +175,23 @@ namespace BW_tool
this.forest_but.UseVisualStyleBackColor = true;
this.forest_but.Click += new System.EventHandler(this.Forest_butClick);
//
// key_but
//
this.key_but.Enabled = false;
this.key_but.Location = new System.Drawing.Point(158, 136);
this.key_but.Name = "key_but";
this.key_but.Size = new System.Drawing.Size(140, 23);
this.key_but.TabIndex = 11;
this.key_but.Text = "Key System";
this.key_but.UseVisualStyleBackColor = true;
this.key_but.Click += new System.EventHandler(this.Key_butClick);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(503, 147);
this.ClientSize = new System.Drawing.Size(503, 192);
this.Controls.Add(this.key_but);
this.Controls.Add(this.forest_but);
this.Controls.Add(this.medal_but);
this.Controls.Add(this.trainer_records_but);

View File

@@ -65,6 +65,7 @@ namespace BW_tool
trainer_records_but.Enabled = true;
medal_but.Enabled = true;
forest_but.Enabled = true;
key_but.Enabled = true;
}
else if (save.BW)
{
@@ -78,6 +79,7 @@ namespace BW_tool
trainer_records_but.Enabled = false;
medal_but.Enabled = false;
forest_but.Enabled = true;
key_but.Enabled = false;
}
else versiontext.Text = "Invalid file";
@@ -93,6 +95,7 @@ namespace BW_tool
trainer_records_but.Enabled = false;
medal_but.Enabled = false;
forest_but.Enabled = false;
key_but.Enabled = false;
}
}
void Save_butClick(object sender, EventArgs e)
@@ -138,5 +141,10 @@ namespace BW_tool
Form forest = new Entralink();
forest.ShowDialog();
}
void Key_butClick(object sender, EventArgs e)
{
Form keys = new KeySystem();
keys.ShowDialog();
}
}
}