diff --git a/README.md b/README.md new file mode 100644 index 0000000..c8dee6e --- /dev/null +++ b/README.md @@ -0,0 +1,8 @@ +# Super Mario 3D Land Savegame Editor: +Code mirrored from [this user](https://gbatemp.net/members/110449), thanks. + +A Savegame editor for the game Super Mario 3D Land (3DS). +Tested on EUR Game/O3DSXL (Card, I dont have eshop version of this game). +* Unlock all worlds is a **WIP** Option - Make sure you have a backup of your save. + +More information: https://gbatemp.net/threads/396816 diff --git a/Super Mario Land 3D Savegame Editor.sln b/Super Mario Land 3D Savegame Editor.sln new file mode 100644 index 0000000..ef45c79 --- /dev/null +++ b/Super Mario Land 3D Savegame Editor.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Super Mario Land 3D Savegame Editor", "Super Mario Land 3D Savegame Editor\Super Mario Land 3D Savegame Editor.csproj", "{EF07776A-F706-4494-A3E3-A46C2E4E0650}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EF07776A-F706-4494-A3E3-A46C2E4E0650}.Debug|x86.ActiveCfg = Debug|x86 + {EF07776A-F706-4494-A3E3-A46C2E4E0650}.Debug|x86.Build.0 = Debug|x86 + {EF07776A-F706-4494-A3E3-A46C2E4E0650}.Release|x86.ActiveCfg = Release|x86 + {EF07776A-F706-4494-A3E3-A46C2E4E0650}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Super Mario Land 3D Savegame Editor/Crc32.cs b/Super Mario Land 3D Savegame Editor/Crc32.cs new file mode 100644 index 0000000..233defb --- /dev/null +++ b/Super Mario Land 3D Savegame Editor/Crc32.cs @@ -0,0 +1,119 @@ +// Copyright (c) Damien Guard. All rights reserved. +// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. +// You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 +// Originally published at http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net + +using System; +using System.Collections.Generic; +using System.Security.Cryptography; + +namespace Super_Mario_Land_3D_Savegame_Editor +{ + /// + /// Implements a 32-bit CRC hash algorithm compatible with Zip etc. + /// + /// + /// Crc32 should only be used for backward compatibility with older file formats + /// and algorithms. It is not secure enough for new applications. + /// If you need to call multiple times for the same data either use the HashAlgorithm + /// interface or remember that the result of one Compute call needs to be ~ (XOR) before + /// being passed in as the seed for the next Compute call. + /// + public sealed class Crc32 : HashAlgorithm + { + public const UInt32 DefaultPolynomial = 0xedb88320u; + public const UInt32 DefaultSeed = 0xffffffffu; + + static UInt32[] defaultTable; + + readonly UInt32 seed; + readonly UInt32[] table; + UInt32 hash; + + public Crc32() + : this(DefaultPolynomial, DefaultSeed) + { + } + + public Crc32(UInt32 polynomial, UInt32 seed) + { + table = InitializeTable(polynomial); + this.seed = hash = seed; + } + + public override void Initialize() + { + hash = seed; + } + + protected override void HashCore(byte[] array, int ibStart, int cbSize) + { + hash = CalculateHash(table, hash, array, ibStart, cbSize); + } + + protected override byte[] HashFinal() + { + var hashBuffer = UInt32ToBigEndianBytes(~hash); + HashValue = hashBuffer; + return hashBuffer; + } + + public override int HashSize { get { return 32; } } + + public static UInt32 Compute(byte[] buffer) + { + return Compute(DefaultSeed, buffer); + } + + public static UInt32 Compute(UInt32 seed, byte[] buffer) + { + return Compute(DefaultPolynomial, seed, buffer); + } + + public static UInt32 Compute(UInt32 polynomial, UInt32 seed, byte[] buffer) + { + return ~CalculateHash(InitializeTable(polynomial), seed, buffer, 0, buffer.Length); + } + + static UInt32[] InitializeTable(UInt32 polynomial) + { + if (polynomial == DefaultPolynomial && defaultTable != null) + return defaultTable; + + var createTable = new UInt32[256]; + for (var i = 0; i < 256; i++) + { + var entry = (UInt32)i; + for (var j = 0; j < 8; j++) + if ((entry & 1) == 1) + entry = (entry >> 1) ^ polynomial; + else + entry = entry >> 1; + createTable[i] = entry; + } + + if (polynomial == DefaultPolynomial) + defaultTable = createTable; + + return createTable; + } + + static UInt32 CalculateHash(UInt32[] table, UInt32 seed, IList buffer, int start, int size) + { + var crc = seed; + for (var i = start; i < size - start; i++) + crc = (crc >> 8) ^ table[buffer[i] ^ crc & 0xff]; + return crc; + } + + static byte[] UInt32ToBigEndianBytes(UInt32 uint32) + { + var result = BitConverter.GetBytes(uint32); + + if (BitConverter.IsLittleEndian) + Array.Reverse(result); + + return result; + } + } +} \ No newline at end of file diff --git a/Super Mario Land 3D Savegame Editor/Program.cs b/Super Mario Land 3D Savegame Editor/Program.cs new file mode 100644 index 0000000..fed105a --- /dev/null +++ b/Super Mario Land 3D Savegame Editor/Program.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Windows.Forms; + +namespace Super_Mario_Land_3D_Savegame_Editor +{ + static class Program + { + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + [STAThread] + static void Main() + { + Application.EnableVisualStyles(); + Application.SetCompatibleTextRenderingDefault(false); + Application.Run(new SM3DL_SGE()); + } + } +} diff --git a/Super Mario Land 3D Savegame Editor/Properties/AssemblyInfo.cs b/Super Mario Land 3D Savegame Editor/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6c9d3fe --- /dev/null +++ b/Super Mario Land 3D Savegame Editor/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die mit einer Assembly verknüpft sind. +[assembly: AssemblyTitle("Super Mario Land 3D Savegame Editor")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Super Mario Land 3D Savegame Editor")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar +// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von +// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("e78b334b-54d0-4fd0-84bd-98ce56a6c092")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern +// übernehmen, indem Sie "*" eingeben: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Super Mario Land 3D Savegame Editor/Properties/Resources.Designer.cs b/Super Mario Land 3D Savegame Editor/Properties/Resources.Designer.cs new file mode 100644 index 0000000..89f71b1 --- /dev/null +++ b/Super Mario Land 3D Savegame Editor/Properties/Resources.Designer.cs @@ -0,0 +1,83 @@ +//------------------------------------------------------------------------------ +// +// Dieser Code wurde von einem Tool generiert. +// Laufzeitversion:4.0.30319.18408 +// +// Änderungen an dieser Datei können falsches Verhalten verursachen und gehen verloren, wenn +// der Code erneut generiert wird. +// +//------------------------------------------------------------------------------ + +namespace Super_Mario_Land_3D_Savegame_Editor.Properties { + using System; + + + /// + /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw. + /// + // Diese Klasse wurde von der StronglyTypedResourceBuilder automatisch generiert + // -Klasse über ein Tool wie ResGen oder Visual Studio automatisch generiert. + // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen + // mit der /str-Option erneut aus, oder Sie erstellen Ihr VS-Projekt neu. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Super_Mario_Land_3D_Savegame_Editor.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle + /// Ressourcenzuordnungen, die diese stark typisierte Ressourcenklasse verwenden. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap nsmb2_lives { + get { + object obj = ResourceManager.GetObject("nsmb2_lives", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + + /// + /// Sucht eine lokalisierte Ressource vom Typ System.Drawing.Bitmap. + /// + internal static System.Drawing.Bitmap nsmb2_starcoin { + get { + object obj = ResourceManager.GetObject("nsmb2_starcoin", resourceCulture); + return ((System.Drawing.Bitmap)(obj)); + } + } + } +} diff --git a/Super Mario Land 3D Savegame Editor/Properties/Resources.resx b/Super Mario Land 3D Savegame Editor/Properties/Resources.resx new file mode 100644 index 0000000..350aec3 --- /dev/null +++ b/Super Mario Land 3D Savegame Editor/Properties/Resources.resx @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + ..\Resources\nsmb2_lives.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + + ..\Resources\nsmb2_starcoin.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a + + \ No newline at end of file diff --git a/Super Mario Land 3D Savegame Editor/Properties/Settings.Designer.cs b/Super Mario Land 3D Savegame Editor/Properties/Settings.Designer.cs new file mode 100644 index 0000000..5e50051 --- /dev/null +++ b/Super Mario Land 3D Savegame Editor/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.18408 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Super_Mario_Land_3D_Savegame_Editor.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/Super Mario Land 3D Savegame Editor/Properties/Settings.settings b/Super Mario Land 3D Savegame Editor/Properties/Settings.settings new file mode 100644 index 0000000..abf36c5 --- /dev/null +++ b/Super Mario Land 3D Savegame Editor/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Super Mario Land 3D Savegame Editor/Resources/nsmb2_lives.png b/Super Mario Land 3D Savegame Editor/Resources/nsmb2_lives.png new file mode 100644 index 0000000..b8509e5 Binary files /dev/null and b/Super Mario Land 3D Savegame Editor/Resources/nsmb2_lives.png differ diff --git a/Super Mario Land 3D Savegame Editor/Resources/nsmb2_starcoin.png b/Super Mario Land 3D Savegame Editor/Resources/nsmb2_starcoin.png new file mode 100644 index 0000000..45c83d3 Binary files /dev/null and b/Super Mario Land 3D Savegame Editor/Resources/nsmb2_starcoin.png differ diff --git a/Super Mario Land 3D Savegame Editor/SM3DL_SGE.Designer.cs b/Super Mario Land 3D Savegame Editor/SM3DL_SGE.Designer.cs new file mode 100644 index 0000000..3d5b3ba --- /dev/null +++ b/Super Mario Land 3D Savegame Editor/SM3DL_SGE.Designer.cs @@ -0,0 +1,502 @@ +namespace Super_Mario_Land_3D_Savegame_Editor +{ + partial class SM3DL_SGE + { + /// + /// Erforderliche Designervariable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Verwendete Ressourcen bereinigen. + /// + /// True, wenn verwaltete Ressourcen gelöscht werden sollen; andernfalls False. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Vom Windows Form-Designer generierter Code + + /// + /// Erforderliche Methode für die Designerunterstützung. + /// Der Inhalt der Methode darf nicht mit dem Code-Editor geändert werden. + /// + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.button2 = new System.Windows.Forms.Button(); + this.groupBox1 = new System.Windows.Forms.GroupBox(); + this.unlock_worlds_s1 = new System.Windows.Forms.CheckBox(); + this.label2 = new System.Windows.Forms.Label(); + this.label1 = new System.Windows.Forms.Label(); + this.p1_itembox = new System.Windows.Forms.ComboBox(); + this.p1_start_as = new System.Windows.Forms.ComboBox(); + this.box_file1_coins = new System.Windows.Forms.TextBox(); + this.box_file1_lives = new System.Windows.Forms.TextBox(); + this.pictureBox2 = new System.Windows.Forms.PictureBox(); + this.pictureBox1 = new System.Windows.Forms.PictureBox(); + this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.unlock_worlds_s2 = new System.Windows.Forms.CheckBox(); + this.label5 = new System.Windows.Forms.Label(); + this.box_file2_coins = new System.Windows.Forms.TextBox(); + this.label6 = new System.Windows.Forms.Label(); + this.box_file2_lives = new System.Windows.Forms.TextBox(); + this.p2_itembox = new System.Windows.Forms.ComboBox(); + this.pictureBox3 = new System.Windows.Forms.PictureBox(); + this.p2_start_as = new System.Windows.Forms.ComboBox(); + this.pictureBox4 = new System.Windows.Forms.PictureBox(); + this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.unlock_worlds_s3 = new System.Windows.Forms.CheckBox(); + this.label3 = new System.Windows.Forms.Label(); + this.box_file3_coins = new System.Windows.Forms.TextBox(); + this.label4 = new System.Windows.Forms.Label(); + this.p3_itembox = new System.Windows.Forms.ComboBox(); + this.box_file3_lives = new System.Windows.Forms.TextBox(); + this.p3_start_as = new System.Windows.Forms.ComboBox(); + this.pictureBox5 = new System.Windows.Forms.PictureBox(); + this.pictureBox6 = new System.Windows.Forms.PictureBox(); + this.groupBox1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); + this.groupBox2.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).BeginInit(); + this.groupBox3.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).BeginInit(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(3, 36); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(194, 23); + this.button1.TabIndex = 0; + this.button1.Text = "open GameData"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // button2 + // + this.button2.Location = new System.Drawing.Point(3, 97); + this.button2.Name = "button2"; + this.button2.Size = new System.Drawing.Size(194, 23); + this.button2.TabIndex = 2; + this.button2.Text = "save GameData"; + this.button2.UseVisualStyleBackColor = true; + this.button2.Click += new System.EventHandler(this.button2_Click); + // + // groupBox1 + // + this.groupBox1.Controls.Add(this.unlock_worlds_s1); + this.groupBox1.Controls.Add(this.label2); + this.groupBox1.Controls.Add(this.label1); + this.groupBox1.Controls.Add(this.p1_itembox); + this.groupBox1.Controls.Add(this.p1_start_as); + this.groupBox1.Controls.Add(this.box_file1_coins); + this.groupBox1.Controls.Add(this.box_file1_lives); + this.groupBox1.Controls.Add(this.pictureBox2); + this.groupBox1.Controls.Add(this.pictureBox1); + this.groupBox1.Location = new System.Drawing.Point(212, 12); + this.groupBox1.Name = "groupBox1"; + this.groupBox1.Size = new System.Drawing.Size(194, 140); + this.groupBox1.TabIndex = 3; + this.groupBox1.TabStop = false; + this.groupBox1.Text = "Save File 1"; + // + // unlock_worlds_s1 + // + this.unlock_worlds_s1.AutoSize = true; + this.unlock_worlds_s1.Location = new System.Drawing.Point(74, 117); + this.unlock_worlds_s1.Name = "unlock_worlds_s1"; + this.unlock_worlds_s1.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.unlock_worlds_s1.Size = new System.Drawing.Size(110, 17); + this.unlock_worlds_s1.TabIndex = 13; + this.unlock_worlds_s1.Text = "Unlock All Worlds"; + this.unlock_worlds_s1.UseVisualStyleBackColor = true; + this.unlock_worlds_s1.CheckedChanged += new System.EventHandler(this.unlock_worlds_s1_CheckedChanged); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(6, 85); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(55, 13); + this.label2.TabIndex = 7; + this.label2.Text = "itembox ->"; + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(6, 58); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(53, 13); + this.label1.TabIndex = 6; + this.label1.Text = "start as ->"; + // + // p1_itembox + // + this.p1_itembox.FormattingEnabled = true; + this.p1_itembox.Items.AddRange(new object[] { + "Nothing", + "Mushroom", + "Fire Flower", + "Tanooki Leaf", + "Statue Leaf", + "Boomerang Flower"}); + this.p1_itembox.Location = new System.Drawing.Point(67, 82); + this.p1_itembox.Name = "p1_itembox"; + this.p1_itembox.Size = new System.Drawing.Size(117, 21); + this.p1_itembox.TabIndex = 5; + // + // p1_start_as + // + this.p1_start_as.FormattingEnabled = true; + this.p1_start_as.Items.AddRange(new object[] { + "Big Mario", + "Small Mario", + "Fire Mario", + "Tanooki Mario", + "Boomerang Mario", + "Statue Mario"}); + this.p1_start_as.Location = new System.Drawing.Point(67, 55); + this.p1_start_as.Name = "p1_start_as"; + this.p1_start_as.Size = new System.Drawing.Size(117, 21); + this.p1_start_as.TabIndex = 4; + // + // box_file1_coins + // + this.box_file1_coins.Location = new System.Drawing.Point(129, 24); + this.box_file1_coins.MaxLength = 3; + this.box_file1_coins.Name = "box_file1_coins"; + this.box_file1_coins.Size = new System.Drawing.Size(55, 20); + this.box_file1_coins.TabIndex = 3; + // + // box_file1_lives + // + this.box_file1_lives.Location = new System.Drawing.Point(37, 24); + this.box_file1_lives.MaxLength = 4; + this.box_file1_lives.Name = "box_file1_lives"; + this.box_file1_lives.Size = new System.Drawing.Size(55, 20); + this.box_file1_lives.TabIndex = 2; + // + // pictureBox2 + // + this.pictureBox2.Image = global::Super_Mario_Land_3D_Savegame_Editor.Properties.Resources.nsmb2_starcoin; + this.pictureBox2.Location = new System.Drawing.Point(98, 19); + this.pictureBox2.Name = "pictureBox2"; + this.pictureBox2.Size = new System.Drawing.Size(25, 25); + this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox2.TabIndex = 1; + this.pictureBox2.TabStop = false; + // + // pictureBox1 + // + this.pictureBox1.Image = global::Super_Mario_Land_3D_Savegame_Editor.Properties.Resources.nsmb2_lives; + this.pictureBox1.Location = new System.Drawing.Point(6, 19); + this.pictureBox1.Name = "pictureBox1"; + this.pictureBox1.Size = new System.Drawing.Size(25, 25); + this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox1.TabIndex = 0; + this.pictureBox1.TabStop = false; + // + // groupBox2 + // + this.groupBox2.Controls.Add(this.unlock_worlds_s2); + this.groupBox2.Controls.Add(this.label5); + this.groupBox2.Controls.Add(this.box_file2_coins); + this.groupBox2.Controls.Add(this.label6); + this.groupBox2.Controls.Add(this.box_file2_lives); + this.groupBox2.Controls.Add(this.p2_itembox); + this.groupBox2.Controls.Add(this.pictureBox3); + this.groupBox2.Controls.Add(this.p2_start_as); + this.groupBox2.Controls.Add(this.pictureBox4); + this.groupBox2.Location = new System.Drawing.Point(3, 158); + this.groupBox2.Name = "groupBox2"; + this.groupBox2.Size = new System.Drawing.Size(194, 140); + this.groupBox2.TabIndex = 4; + this.groupBox2.TabStop = false; + this.groupBox2.Text = "Save File 2"; + // + // unlock_worlds_s2 + // + this.unlock_worlds_s2.AutoSize = true; + this.unlock_worlds_s2.Location = new System.Drawing.Point(74, 117); + this.unlock_worlds_s2.Name = "unlock_worlds_s2"; + this.unlock_worlds_s2.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.unlock_worlds_s2.Size = new System.Drawing.Size(110, 17); + this.unlock_worlds_s2.TabIndex = 12; + this.unlock_worlds_s2.Text = "Unlock All Worlds"; + this.unlock_worlds_s2.UseVisualStyleBackColor = true; + this.unlock_worlds_s2.CheckedChanged += new System.EventHandler(this.unlock_worlds_s2_CheckedChanged); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(6, 85); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(55, 13); + this.label5.TabIndex = 11; + this.label5.Text = "itembox ->"; + // + // box_file2_coins + // + this.box_file2_coins.Location = new System.Drawing.Point(129, 24); + this.box_file2_coins.MaxLength = 3; + this.box_file2_coins.Name = "box_file2_coins"; + this.box_file2_coins.Size = new System.Drawing.Size(55, 20); + this.box_file2_coins.TabIndex = 3; + // + // label6 + // + this.label6.AutoSize = true; + this.label6.Location = new System.Drawing.Point(6, 58); + this.label6.Name = "label6"; + this.label6.Size = new System.Drawing.Size(53, 13); + this.label6.TabIndex = 10; + this.label6.Text = "start as ->"; + // + // box_file2_lives + // + this.box_file2_lives.Location = new System.Drawing.Point(37, 24); + this.box_file2_lives.MaxLength = 4; + this.box_file2_lives.Name = "box_file2_lives"; + this.box_file2_lives.Size = new System.Drawing.Size(55, 20); + this.box_file2_lives.TabIndex = 2; + // + // p2_itembox + // + this.p2_itembox.FormattingEnabled = true; + this.p2_itembox.Items.AddRange(new object[] { + "Nothing", + "Mushroom", + "Fire Flower", + "Tanooki Leaf", + "Statue Leaf", + "Boomerang Flower"}); + this.p2_itembox.Location = new System.Drawing.Point(67, 82); + this.p2_itembox.Name = "p2_itembox"; + this.p2_itembox.Size = new System.Drawing.Size(117, 21); + this.p2_itembox.TabIndex = 9; + // + // pictureBox3 + // + this.pictureBox3.Image = global::Super_Mario_Land_3D_Savegame_Editor.Properties.Resources.nsmb2_starcoin; + this.pictureBox3.Location = new System.Drawing.Point(98, 19); + this.pictureBox3.Name = "pictureBox3"; + this.pictureBox3.Size = new System.Drawing.Size(25, 25); + this.pictureBox3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox3.TabIndex = 1; + this.pictureBox3.TabStop = false; + // + // p2_start_as + // + this.p2_start_as.FormattingEnabled = true; + this.p2_start_as.Items.AddRange(new object[] { + "Big Mario", + "Small Mario", + "Fire Mario", + "Tanooki Mario", + "Boomerang Mario", + "Statue Mario"}); + this.p2_start_as.Location = new System.Drawing.Point(67, 55); + this.p2_start_as.Name = "p2_start_as"; + this.p2_start_as.Size = new System.Drawing.Size(117, 21); + this.p2_start_as.TabIndex = 8; + // + // pictureBox4 + // + this.pictureBox4.Image = global::Super_Mario_Land_3D_Savegame_Editor.Properties.Resources.nsmb2_lives; + this.pictureBox4.Location = new System.Drawing.Point(6, 19); + this.pictureBox4.Name = "pictureBox4"; + this.pictureBox4.Size = new System.Drawing.Size(25, 25); + this.pictureBox4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox4.TabIndex = 0; + this.pictureBox4.TabStop = false; + // + // groupBox3 + // + this.groupBox3.Controls.Add(this.unlock_worlds_s3); + this.groupBox3.Controls.Add(this.label3); + this.groupBox3.Controls.Add(this.box_file3_coins); + this.groupBox3.Controls.Add(this.label4); + this.groupBox3.Controls.Add(this.p3_itembox); + this.groupBox3.Controls.Add(this.box_file3_lives); + this.groupBox3.Controls.Add(this.p3_start_as); + this.groupBox3.Controls.Add(this.pictureBox5); + this.groupBox3.Controls.Add(this.pictureBox6); + this.groupBox3.Location = new System.Drawing.Point(212, 158); + this.groupBox3.Name = "groupBox3"; + this.groupBox3.Size = new System.Drawing.Size(194, 140); + this.groupBox3.TabIndex = 5; + this.groupBox3.TabStop = false; + this.groupBox3.Text = "Save File 3"; + // + // unlock_worlds_s3 + // + this.unlock_worlds_s3.AutoSize = true; + this.unlock_worlds_s3.Location = new System.Drawing.Point(74, 117); + this.unlock_worlds_s3.Name = "unlock_worlds_s3"; + this.unlock_worlds_s3.RightToLeft = System.Windows.Forms.RightToLeft.Yes; + this.unlock_worlds_s3.Size = new System.Drawing.Size(110, 17); + this.unlock_worlds_s3.TabIndex = 14; + this.unlock_worlds_s3.Text = "Unlock All Worlds"; + this.unlock_worlds_s3.UseVisualStyleBackColor = true; + this.unlock_worlds_s3.CheckedChanged += new System.EventHandler(this.unlock_worlds_s3_CheckedChanged); + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(6, 85); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(55, 13); + this.label3.TabIndex = 11; + this.label3.Text = "itembox ->"; + // + // box_file3_coins + // + this.box_file3_coins.Location = new System.Drawing.Point(129, 24); + this.box_file3_coins.MaxLength = 3; + this.box_file3_coins.Name = "box_file3_coins"; + this.box_file3_coins.Size = new System.Drawing.Size(55, 20); + this.box_file3_coins.TabIndex = 3; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(6, 58); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(53, 13); + this.label4.TabIndex = 10; + this.label4.Text = "start as ->"; + // + // p3_itembox + // + this.p3_itembox.FormattingEnabled = true; + this.p3_itembox.Items.AddRange(new object[] { + "Nothing", + "Mushroom", + "Fire Flower", + "Tanooki Leaf", + "Statue Leaf", + "Boomerang Flower"}); + this.p3_itembox.Location = new System.Drawing.Point(67, 82); + this.p3_itembox.Name = "p3_itembox"; + this.p3_itembox.Size = new System.Drawing.Size(117, 21); + this.p3_itembox.TabIndex = 9; + // + // box_file3_lives + // + this.box_file3_lives.Location = new System.Drawing.Point(37, 24); + this.box_file3_lives.MaxLength = 4; + this.box_file3_lives.Name = "box_file3_lives"; + this.box_file3_lives.Size = new System.Drawing.Size(55, 20); + this.box_file3_lives.TabIndex = 2; + // + // p3_start_as + // + this.p3_start_as.FormattingEnabled = true; + this.p3_start_as.Items.AddRange(new object[] { + "Big Mario", + "Small Mario", + "Fire Mario", + "Tanooki Mario", + "Boomerang Mario", + "Statue Mario"}); + this.p3_start_as.Location = new System.Drawing.Point(67, 55); + this.p3_start_as.Name = "p3_start_as"; + this.p3_start_as.Size = new System.Drawing.Size(117, 21); + this.p3_start_as.TabIndex = 8; + // + // pictureBox5 + // + this.pictureBox5.Image = global::Super_Mario_Land_3D_Savegame_Editor.Properties.Resources.nsmb2_starcoin; + this.pictureBox5.Location = new System.Drawing.Point(98, 19); + this.pictureBox5.Name = "pictureBox5"; + this.pictureBox5.Size = new System.Drawing.Size(25, 25); + this.pictureBox5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox5.TabIndex = 1; + this.pictureBox5.TabStop = false; + // + // pictureBox6 + // + this.pictureBox6.Image = global::Super_Mario_Land_3D_Savegame_Editor.Properties.Resources.nsmb2_lives; + this.pictureBox6.Location = new System.Drawing.Point(6, 19); + this.pictureBox6.Name = "pictureBox6"; + this.pictureBox6.Size = new System.Drawing.Size(25, 25); + this.pictureBox6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; + this.pictureBox6.TabIndex = 0; + this.pictureBox6.TabStop = false; + // + // SM3DL_SGE + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(418, 313); + this.Controls.Add(this.groupBox3); + this.Controls.Add(this.groupBox2); + this.Controls.Add(this.groupBox1); + this.Controls.Add(this.button2); + this.Controls.Add(this.button1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; + this.Name = "SM3DL_SGE"; + this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; + this.Text = "Super Mario 3D Land SGE v2b"; + this.groupBox1.ResumeLayout(false); + this.groupBox1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); + this.groupBox2.ResumeLayout(false); + this.groupBox2.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox3)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox4)).EndInit(); + this.groupBox3.ResumeLayout(false); + this.groupBox3.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox5)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.pictureBox6)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.Button button2; + private System.Windows.Forms.GroupBox groupBox1; + private System.Windows.Forms.PictureBox pictureBox2; + private System.Windows.Forms.PictureBox pictureBox1; + private System.Windows.Forms.TextBox box_file1_coins; + private System.Windows.Forms.TextBox box_file1_lives; + private System.Windows.Forms.GroupBox groupBox2; + private System.Windows.Forms.TextBox box_file2_coins; + private System.Windows.Forms.TextBox box_file2_lives; + private System.Windows.Forms.PictureBox pictureBox3; + private System.Windows.Forms.PictureBox pictureBox4; + private System.Windows.Forms.GroupBox groupBox3; + private System.Windows.Forms.TextBox box_file3_coins; + private System.Windows.Forms.TextBox box_file3_lives; + private System.Windows.Forms.PictureBox pictureBox5; + private System.Windows.Forms.PictureBox pictureBox6; + private System.Windows.Forms.ComboBox p1_start_as; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.ComboBox p1_itembox; + private System.Windows.Forms.Label label5; + private System.Windows.Forms.Label label6; + private System.Windows.Forms.ComboBox p2_itembox; + private System.Windows.Forms.ComboBox p2_start_as; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.ComboBox p3_itembox; + private System.Windows.Forms.ComboBox p3_start_as; + private System.Windows.Forms.CheckBox unlock_worlds_s1; + private System.Windows.Forms.CheckBox unlock_worlds_s2; + private System.Windows.Forms.CheckBox unlock_worlds_s3; + } +} + diff --git a/Super Mario Land 3D Savegame Editor/SM3DL_SGE.cs b/Super Mario Land 3D Savegame Editor/SM3DL_SGE.cs new file mode 100644 index 0000000..b1d4f2e --- /dev/null +++ b/Super Mario Land 3D Savegame Editor/SM3DL_SGE.cs @@ -0,0 +1,661 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using System.IO; + + +namespace Super_Mario_Land_3D_Savegame_Editor +{ + public partial class SM3DL_SGE : Form + { + public SM3DL_SGE() + { + InitializeComponent(); + } + + public string savegame; + public byte[] crc32_data; + public byte[] world_unlock = { 0xFF, 0xFF, 0xFF, 0xFF }; + + public string ByteArrayToString(byte[] byteArray) + { + var hex = new StringBuilder(byteArray.Length * 2); + foreach (var b in byteArray) + hex.AppendFormat("{0:X2}", b); + return hex.ToString(); + } + public static byte[] BLKDTH_StringToByteArray(string hex) + { + return Enumerable.Range(0, hex.Length) + .Where(x => x % 2 == 0) + .Select(x => Convert.ToByte(hex.Substring(x, 2), 16)) + .ToArray(); + + } + + private void BLKDTH_get_openfile() + { + OpenFileDialog openFD = new OpenFileDialog(); + if (openFD.ShowDialog() == DialogResult.OK) + { + savegame = openFD.FileName; + } + } + private void BLKDTH_get_data() + { + { + FileStream savegame_fs = new FileStream(savegame, FileMode.Open); + BinaryReader savegame_br = new BinaryReader(savegame_fs); + long length = savegame_fs.Length; + + #region Save 1 main + // lives save 1 + savegame_br.BaseStream.Position = 0x34DF; + byte[] lives1 = savegame_br.ReadBytes(2); + int f1l = BitConverter.ToInt16(lives1, 0); + box_file1_lives.Text = (f1l.ToString()); + // star coins save 1 + savegame_br.BaseStream.Position = 0x34E1; + byte[] scoins1 = savegame_br.ReadBytes(2); + int f1c = BitConverter.ToInt16(scoins1, 0); + box_file1_coins.Text = (f1c.ToString()); + #endregion + #region Save 1 status item + // start as p1 + savegame_br.BaseStream.Position = 0x2B7A; + byte[] p1_start_byte = savegame_br.ReadBytes(1); + if (ByteArrayToString(p1_start_byte) == "00") + { + p1_start_as.SelectedIndex = 0; + } + if (ByteArrayToString(p1_start_byte) == "01") + { + p1_start_as.SelectedIndex = 1; + } + if (ByteArrayToString(p1_start_byte) == "02") + { + p1_start_as.SelectedIndex = 2; + } + if (ByteArrayToString(p1_start_byte) == "03") + { + p1_start_as.SelectedIndex = 3; + } + if (ByteArrayToString(p1_start_byte) == "04") + { + p1_start_as.SelectedIndex = 4; + } + if (ByteArrayToString(p1_start_byte) == "05") + { + p1_start_as.SelectedIndex = 5; + } + else + { + } + // item p1 + savegame_br.BaseStream.Position = 0x2B7C; + byte[] p1_item_byte = savegame_br.ReadBytes(1); + if (ByteArrayToString(p1_item_byte) == "00") + { + p1_itembox.SelectedIndex = 0; + } + if (ByteArrayToString(p1_item_byte) == "01") + { + p1_itembox.SelectedIndex = 1; + } + if (ByteArrayToString(p1_item_byte) == "02") + { + p1_itembox.SelectedIndex = 2; + } + if (ByteArrayToString(p1_item_byte) == "03") + { + p1_itembox.SelectedIndex = 3; + } + if (ByteArrayToString(p1_item_byte) == "04") + { + p1_itembox.SelectedIndex = 4; + } + if (ByteArrayToString(p1_item_byte) == "05") + { + p1_itembox.SelectedIndex = 5; + } + else + { + + } + #endregion + + #region Save 2 main + // lives save 2 + savegame_br.BaseStream.Position = 0x3E62; + byte[] lives2 = savegame_br.ReadBytes(2); + int f2l = BitConverter.ToInt16(lives2, 0); + box_file2_lives.Text = (f2l.ToString()); + // star coins save 2 + savegame_br.BaseStream.Position = 0x3E64; + byte[] scoins2 = savegame_br.ReadBytes(2); + int f2c = BitConverter.ToInt16(scoins2, 0); + box_file2_coins.Text = (f2c.ToString()); + #endregion + #region Save 2 status item + // start as p2 + savegame_br.BaseStream.Position = 0x34FD; + byte[] p2_start_byte = savegame_br.ReadBytes(1); + if (ByteArrayToString(p2_start_byte) == "00") + { + p2_start_as.SelectedIndex = 0; + } + if (ByteArrayToString(p2_start_byte) == "01") + { + p2_start_as.SelectedIndex = 1; + } + if (ByteArrayToString(p2_start_byte) == "02") + { + p2_start_as.SelectedIndex = 2; + } + if (ByteArrayToString(p2_start_byte) == "03") + { + p2_start_as.SelectedIndex = 3; + } + if (ByteArrayToString(p2_start_byte) == "04") + { + p2_start_as.SelectedIndex = 4; + } + if (ByteArrayToString(p2_start_byte) == "05") + { + p2_start_as.SelectedIndex = 5; + } + else + { + } + // item p2 + savegame_br.BaseStream.Position = 0x34FF; + byte[] p2_item_byte = savegame_br.ReadBytes(1); + if (ByteArrayToString(p2_item_byte) == "00") + { + p2_itembox.SelectedIndex = 0; + } + if (ByteArrayToString(p2_item_byte) == "01") + { + p2_itembox.SelectedIndex = 1; + } + if (ByteArrayToString(p2_item_byte) == "02") + { + p2_itembox.SelectedIndex = 2; + } + if (ByteArrayToString(p2_item_byte) == "03") + { + p2_itembox.SelectedIndex = 3; + } + if (ByteArrayToString(p2_item_byte) == "04") + { + p2_itembox.SelectedIndex = 4; + } + if (ByteArrayToString(p2_item_byte) == "05") + { + p2_itembox.SelectedIndex = 5; + } + else + { + } + #endregion + + #region Save 3 main + // lives save 3 + savegame_br.BaseStream.Position = 0x47E5; + byte[] lives3 = savegame_br.ReadBytes(2); + int f3l = BitConverter.ToInt16(lives3, 0); + box_file3_lives.Text = (f3l.ToString()); + // star coins save 3 + savegame_br.BaseStream.Position = 0x47E7; + byte[] scoins3 = savegame_br.ReadBytes(2); + int f3c = BitConverter.ToInt16(scoins3, 0); + box_file3_coins.Text = (f3c.ToString()); + #endregion + #region Save 3 status item + // start as p3 + savegame_br.BaseStream.Position = 0x3E80; + byte[] p3_start_byte = savegame_br.ReadBytes(1); + if (ByteArrayToString(p3_start_byte) == "00") + { + p3_start_as.SelectedIndex = 0; + } + if (ByteArrayToString(p3_start_byte) == "01") + { + p3_start_as.SelectedIndex = 1; + } + else if (ByteArrayToString(p3_start_byte) == "02") + { + p3_start_as.SelectedIndex = 2; + } + else if (ByteArrayToString(p3_start_byte) == "03") + { + p3_start_as.SelectedIndex = 3; + } + else if (ByteArrayToString(p3_start_byte) == "04") + { + p3_start_as.SelectedIndex = 4; + } + else if (ByteArrayToString(p3_start_byte) == "05") + { + p3_start_as.SelectedIndex = 5; + } + else + { + } + // item p3 + savegame_br.BaseStream.Position = 0x3E82; + byte[] p3_item_byte = savegame_br.ReadBytes(1); + if (ByteArrayToString(p3_item_byte) == "00") + { + p3_itembox.SelectedIndex = 0; + } + if (ByteArrayToString(p3_item_byte) == "01") + { + p3_itembox.SelectedIndex = 1; + } + if (ByteArrayToString(p3_item_byte) == "02") + { + p3_itembox.SelectedIndex = 2; + } + if (ByteArrayToString(p3_item_byte) == "03") + { + p3_itembox.SelectedIndex = 3; + } + if (ByteArrayToString(p3_item_byte) == "04") + { + p3_itembox.SelectedIndex = 4; + } + if (ByteArrayToString(p3_item_byte) == "05") + { + p3_itembox.SelectedIndex = 5; + } + else + { + } + #endregion + + savegame_br.Close(); + } + } + private void BLKDTH_set_data() + { + FileStream update_save_open = null; + BinaryWriter update_save_write = null; + update_save_open = new FileStream(savegame, FileMode.OpenOrCreate); + update_save_write = new BinaryWriter(update_save_open); + + #region Save main + byte[] f1_lives = BLKDTH_StringToByteArray(int.Parse(box_file1_lives.Text).ToString("X8")); + Array.Reverse(f1_lives); + update_save_open.Position = Convert.ToInt64("34DF", 16); + update_save_write.Write(f1_lives); + + byte[] f1_coins = BLKDTH_StringToByteArray(int.Parse(box_file1_coins.Text).ToString("X8")); + Array.Reverse(f1_coins); + update_save_open.Position = Convert.ToInt64("34E1", 16); + update_save_write.Write(f1_coins); + #endregion + #region Save 1 status item + // p1 start as + update_save_open.Position = 0x2B7A; + + if (p1_start_as.SelectedIndex == 0) + { + byte[] x1s = { 0x00 }; + update_save_write.Write(x1s, 0, 1); + } + if (p1_start_as.SelectedIndex == 1) + { + byte[] x1s = { 0x01 }; + update_save_write.Write(x1s, 0, 1); + } + if (p1_start_as.SelectedIndex == 2) + { + byte[] x1s = { 0x02 }; + update_save_write.Write(x1s, 0, 1); + } + if (p1_start_as.SelectedIndex == 3) + { + byte[] x1s = { 0x03 }; + update_save_write.Write(x1s, 0, 1); + } + if (p1_start_as.SelectedIndex == 4) + { + byte[] x1s = { 0x04 }; + update_save_write.Write(x1s, 0, 1); + } + if (p1_start_as.SelectedIndex == 5) + { + byte[] x1s = { 0x05 }; + update_save_write.Write(x1s, 0, 1); + } + else + { + } + // p1 itembox + update_save_open.Position = 0x2B7C; + + if (p1_itembox.SelectedIndex == 0) + { + byte[] x1i = { 0x00 }; + update_save_write.Write(x1i, 0, 1); + } + if (p1_itembox.SelectedIndex == 1) + { + byte[] x1i = { 0x01 }; + update_save_write.Write(x1i, 0, 1); + } + if (p1_itembox.SelectedIndex == 2) + { + byte[] x1i = { 0x02 }; + update_save_write.Write(x1i, 0, 1); + } + if (p1_itembox.SelectedIndex == 3) + { + byte[] x1i = { 0x03 }; + update_save_write.Write(x1i, 0, 1); + } + if (p1_itembox.SelectedIndex == 4) + { + byte[] x1i = { 0x04 }; + update_save_write.Write(x1i, 0, 1); + } + if (p1_itembox.SelectedIndex == 5) + { + byte[] x1i = { 0x05 }; + update_save_write.Write(x1i, 0, 1); + } + else + { + } + #endregion + #region Save 1 unlock worlds + if (unlock_worlds_s1.Checked == true) + { + update_save_open.Position = 0x2B8C; + update_save_write.Write(world_unlock); + } + #endregion + + #region Save 2 main + byte[] f2_lives = BLKDTH_StringToByteArray(int.Parse(box_file2_lives.Text).ToString("X8")); + Array.Reverse(f2_lives); + update_save_open.Position = Convert.ToInt64("3E62", 16); + update_save_write.Write(f2_lives); + + byte[] f2_coins = BLKDTH_StringToByteArray(int.Parse(box_file2_coins.Text).ToString("X8")); + Array.Reverse(f2_coins); + update_save_open.Position = Convert.ToInt64("3E64", 16); + update_save_write.Write(f2_coins); + #endregion + #region Save 2 status item + // p2 start as + update_save_open.Position = 0x34FD; + + if (p2_start_as.SelectedIndex == 0) + { + byte[] x2s = { 0x00 }; + update_save_write.Write(x2s, 0, 1); + } + if (p2_start_as.SelectedIndex == 1) + { + byte[] x2s = { 0x01 }; + update_save_write.Write(x2s, 0, 1); + } + if (p2_start_as.SelectedIndex == 2) + { + byte[] x2s = { 0x02 }; + update_save_write.Write(x2s, 0, 1); + } + if (p2_start_as.SelectedIndex == 3) + { + byte[] x2s = { 0x03 }; + update_save_write.Write(x2s, 0, 1); + } + if (p2_start_as.SelectedIndex == 4) + { + byte[] x2s = { 0x04 }; + update_save_write.Write(x2s, 0, 1); + } + if (p2_start_as.SelectedIndex == 5) + { + byte[] x2s = { 0x05 }; + update_save_write.Write(x2s, 0, 1); + } + else + { + } + // p2 itembox + update_save_open.Position = 0x34FF; + + if (p2_itembox.SelectedIndex == 0) + { + byte[] x2i = { 0x00 }; + update_save_write.Write(x2i, 0, 1); + } + if (p2_itembox.SelectedIndex == 1) + { + byte[] x2i = { 0x01 }; + update_save_write.Write(x2i, 0, 1); + } + if (p2_itembox.SelectedIndex == 2) + { + byte[] x2i = { 0x02 }; + update_save_write.Write(x2i, 0, 1); + } + if (p2_itembox.SelectedIndex == 3) + { + byte[] x2i = { 0x03 }; + update_save_write.Write(x2i, 0, 1); + } + if (p2_itembox.SelectedIndex == 4) + { + byte[] x2i = { 0x04 }; + update_save_write.Write(x2i, 0, 1); + } + if (p2_itembox.SelectedIndex == 5) + { + byte[] x2i = { 0x05 }; + update_save_write.Write(x2i, 0, 1); + } + else + { + } + #endregion + #region Save 2 unlock worlds + if (unlock_worlds_s2.Checked == true) + { + update_save_open.Position = 0x350F; + update_save_write.Write(world_unlock); + } + #endregion + + #region Save 3 main + byte[] f3_lives = BLKDTH_StringToByteArray(int.Parse(box_file3_lives.Text).ToString("X8")); + Array.Reverse(f3_lives); + update_save_open.Position = Convert.ToInt64("47E5", 16); + update_save_write.Write(f3_lives); + + byte[] f3_coins = BLKDTH_StringToByteArray(int.Parse(box_file3_coins.Text).ToString("X8")); + Array.Reverse(f3_coins); + update_save_open.Position = Convert.ToInt64("47E7", 16); + update_save_write.Write(f3_coins); + #endregion + #region Save 3 status item + // p3 start as + update_save_open.Position = 0x3E80; + + if (p3_start_as.SelectedIndex == 0) + { + byte[] x3s = { 0x00 }; + update_save_write.Write(x3s, 0, 1); + } + if (p3_start_as.SelectedIndex == 1) + { + byte[] x3s = { 0x01 }; + update_save_write.Write(x3s, 0, 1); + } + if (p3_start_as.SelectedIndex == 2) + { + byte[] x3s = { 0x02 }; + update_save_write.Write(x3s, 0, 1); + } + if (p3_start_as.SelectedIndex == 3) + { + byte[] x3s = { 0x03 }; + update_save_write.Write(x3s, 0, 1); + } + if (p3_start_as.SelectedIndex == 4) + { + byte[] x3s = { 0x04 }; + update_save_write.Write(x3s, 0, 1); + } + if (p3_start_as.SelectedIndex == 5) + { + byte[] x3s = { 0x05 }; + update_save_write.Write(x3s, 0, 1); + } + else + { + } + // p3 itembox + update_save_open.Position = 0x3E82; + + if (p3_itembox.SelectedIndex == 0) + { + byte[] x3i = { 0x00 }; + update_save_write.Write(x3i, 0, 1); + } + if (p3_itembox.SelectedIndex == 1) + { + byte[] x3i = { 0x01 }; + update_save_write.Write(x3i, 0, 1); + } + if (p3_itembox.SelectedIndex == 2) + { + byte[] x3i = { 0x02 }; + update_save_write.Write(x3i, 0, 1); + } + if (p3_itembox.SelectedIndex == 3) + { + byte[] x3i = { 0x03 }; + update_save_write.Write(x3i, 0, 1); + } + if (p3_itembox.SelectedIndex == 4) + { + byte[] x3i = { 0x04 }; + update_save_write.Write(x3i, 0, 1); + } + if (p3_itembox.SelectedIndex == 5) + { + byte[] x3i = { 0x05 }; + update_save_write.Write(x3i, 0, 1); + } + else + { + } + #endregion + #region Save 3 unlock worlds + if (unlock_worlds_s3.Checked == true) + { + update_save_open.Position = 0x3E92; + update_save_write.Write(world_unlock); + } + #endregion + + update_save_open.Close(); + } + private void BLKDTH_crc32fix() + { + { + FileStream savegame_fs = new FileStream(savegame, FileMode.Open); + BinaryReader savegame_br = new BinaryReader(savegame_fs); + BinaryWriter update_save_crc32 = null; + + savegame_br.BaseStream.Position = 0x04; + byte[] crc32_data = savegame_br.ReadBytes(Convert.ToInt32(savegame_fs.Length)); + Crc32 crc32 = new Crc32(); + String hash = String.Empty; + foreach (byte b in crc32.ComputeHash(crc32_data)) hash += b.ToString("x2");//.ToLower(); + byte[] crc32_data_fixed = BLKDTH_StringToByteArray(hash); + Array.Reverse(crc32_data_fixed); + int f2c = BitConverter.ToInt32(crc32_data_fixed, 0); + + update_save_crc32 = new BinaryWriter(savegame_fs); + savegame_fs.Position = Convert.ToInt64("00", 16); + update_save_crc32.Write(crc32_data_fixed); + savegame_br.Close(); + } + } + + private void button2_Click(object sender, EventArgs e) + { + BLKDTH_set_data(); + BLKDTH_crc32fix(); + MessageBox.Show("Data saved"); + } + private void button1_Click(object sender, EventArgs e) + { + BLKDTH_get_openfile(); + if (string.IsNullOrEmpty(savegame)) + { + MessageBox.Show("no savegame selected"); + } + else + { + BLKDTH_get_data(); + } + } + +#region WIP Option +private void unlock_worlds_s1_CheckedChanged(object sender, EventArgs e) + { + if (unlock_worlds_s1.Checked == true) + { + if (MessageBox.Show("This is a WIP Option." + Environment.NewLine + "Make sure you have a backup of your savegame", "unlock all Worlds", MessageBoxButtons.OKCancel) == DialogResult.OK) + { + unlock_worlds_s1.Checked = true; + } + else + { + unlock_worlds_s1.Checked = false; + } + } + } + private void unlock_worlds_s2_CheckedChanged(object sender, EventArgs e) + { + if (unlock_worlds_s2.Checked == true) + { + if (MessageBox.Show("This is a WIP Option." + Environment.NewLine + "Make sure you have a backup of your savegame", "unlock all Worlds", MessageBoxButtons.OKCancel) == DialogResult.OK) + { + unlock_worlds_s2.Checked = true; + } + else + { + unlock_worlds_s2.Checked = false; + } + } + } + private void unlock_worlds_s3_CheckedChanged(object sender, EventArgs e) + { + if (unlock_worlds_s3.Checked == true) + { + if (MessageBox.Show("This is a WIP Option." + Environment.NewLine + "Make sure you have a backup of your savegame", "unlock all Worlds", MessageBoxButtons.OKCancel) == DialogResult.OK) + { + unlock_worlds_s3.Checked = true; + } + else + { + unlock_worlds_s3.Checked = false; + } + } + } +#endregion + + } +} diff --git a/Super Mario Land 3D Savegame Editor/SM3DL_SGE.resx b/Super Mario Land 3D Savegame Editor/SM3DL_SGE.resx new file mode 100644 index 0000000..29dcb1b --- /dev/null +++ b/Super Mario Land 3D Savegame Editor/SM3DL_SGE.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/Super Mario Land 3D Savegame Editor/Super Mario Land 3D Savegame Editor.csproj b/Super Mario Land 3D Savegame Editor/Super Mario Land 3D Savegame Editor.csproj new file mode 100644 index 0000000..5200947 --- /dev/null +++ b/Super Mario Land 3D Savegame Editor/Super Mario Land 3D Savegame Editor.csproj @@ -0,0 +1,95 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {EF07776A-F706-4494-A3E3-A46C2E4E0650} + WinExe + Properties + Super_Mario_Land_3D_Savegame_Editor + Super Mario Land 3D Savegame Editor + v4.0 + Client + 512 + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + Form + + + SM3DL_SGE.cs + + + + + SM3DL_SGE.cs + + + ResXFileCodeGenerator + Resources.Designer.cs + Designer + + + True + Resources.resx + True + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + True + Settings.settings + True + + + + + + + + + + + \ No newline at end of file