Added support for Expanded ARM9 memory, new search location feature

- Fixed Text message search being case sensitive no matter what
- Added new ROM Toolbox icon
- Added ARM9 memory expander to the Toolbox
- Added placeholder BDHCAM button to toolbox
- Added placeholder "Pokemon names case converter" button to toolbox
- New search location feature
- Fixed Encounters editor not opening
This commit is contained in:
AdAstra-LD
2021-01-10 03:58:27 +01:00
parent 76736663bc
commit fa2a015170
15 changed files with 1354 additions and 803 deletions

View File

@@ -1,128 +0,0 @@
namespace DSPRE
{
partial class ASMHacksDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.applyItemStandardizeButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.applyARM9ExpansionButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// applyItemStandardizeButton
//
this.applyItemStandardizeButton.Location = new System.Drawing.Point(330, 107);
this.applyItemStandardizeButton.Name = "applyItemStandardizeButton";
this.applyItemStandardizeButton.Size = new System.Drawing.Size(100, 31);
this.applyItemStandardizeButton.TabIndex = 0;
this.applyItemStandardizeButton.Text = "Apply";
this.applyItemStandardizeButton.UseVisualStyleBackColor = true;
this.applyItemStandardizeButton.Click += new System.EventHandler(this.applyItemStandardizeButton_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(15, 92);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(155, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Standardize Item Numbers";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(15, 107);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(305, 26);
this.label2.TabIndex = 2;
this.label2.Text = "Makes it so that PokéBall item scripts follow the order of items\r\nas indexed in t" +
"he ROM. Needed for \'Item\' option in Event Editor\r\n";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(15, 32);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(309, 39);
this.label3.TabIndex = 5;
this.label3.Text = "Expands ARM9 by repointing the Map Headers table to another \r\nmemory region, leav" +
"ing free space in the original location. \r\nNeeded to add new Headers and for oth" +
"er ASM hacks.";
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(15, 17);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(187, 13);
this.label4.TabIndex = 4;
this.label4.Text = "ARM9 Expansion (Experimental)";
//
// applyARM9ExpansionButton
//
this.applyARM9ExpansionButton.Enabled = false;
this.applyARM9ExpansionButton.Location = new System.Drawing.Point(330, 30);
this.applyARM9ExpansionButton.Name = "applyARM9ExpansionButton";
this.applyARM9ExpansionButton.Size = new System.Drawing.Size(100, 31);
this.applyARM9ExpansionButton.TabIndex = 3;
this.applyARM9ExpansionButton.Text = "Work in progress";
this.applyARM9ExpansionButton.UseVisualStyleBackColor = true;
this.applyARM9ExpansionButton.Click += new System.EventHandler(this.applyARM9ExpansionButton_Click);
//
// ASMHacksDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(442, 156);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.applyARM9ExpansionButton);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.applyItemStandardizeButton);
this.Name = "ASMHacksDialog";
this.Text = "ASM Hacks";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button applyItemStandardizeButton;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button applyARM9ExpansionButton;
}
}

View File

@@ -1,39 +0,0 @@
using System;
using System.IO;
using System.Windows.Forms;
namespace DSPRE
{
public partial class ASMHacksDialog : Form
{
RomInfo info;
public bool standardizedItems = new bool();
public ASMHacksDialog(RomInfo romInfo)
{
InitializeComponent();
info = romInfo;
}
private void applyItemStandardizeButton_Click(object sender, EventArgs e)
{
string path = info.GetScriptFolderPath() + "\\" + info.GetItemScriptFileNumber().ToString("D4");
ScriptFile file = new ScriptFile(new FileStream(path, FileMode.Open), info.getGameVersion());
for (int i = 0; i < file.scripts.Count - 1; i++)
{
file.scripts[i].commands[0].parameters[1] = BitConverter.GetBytes((ushort)i); // Fix item index
file.scripts[i].commands[1].parameters[1] = BitConverter.GetBytes((ushort)1); // Fix item quantity
}
using (BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.Create))) writer.Write(file.Save());
standardizedItems = true;
}
private void applyARM9ExpansionButton_Click(object sender, EventArgs e)
{
}
}
}

View File

@@ -91,11 +91,11 @@
<ItemGroup>
<Compile Include="AB.cs" />
<Compile Include="AreaData.cs" />
<Compile Include="ASMHacksDialog.cs">
<Compile Include="ROMToolboxDialog.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="ASMHacksDialog.Designer.cs">
<DependentUpon>ASMHacksDialog.cs</DependentUpon>
<Compile Include="ROMToolboxDialog.Designer.cs">
<DependentUpon>ROMToolboxDialog.cs</DependentUpon>
</Compile>
<Compile Include="BuildingEditor.cs">
<SubType>Form</SubType>
@@ -231,8 +231,8 @@
<Compile Include="SPK.Designer.cs">
<DependentUpon>SPK.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="ASMHacksDialog.resx">
<DependentUpon>ASMHacksDialog.cs</DependentUpon>
<EmbeddedResource Include="ROMToolboxDialog.resx">
<DependentUpon>ROMToolboxDialog.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="BuildingEditor.resx">
<DependentUpon>BuildingEditor.cs</DependentUpon>
@@ -404,6 +404,8 @@
<None Include="Graphics\Weather\DPPt\ptspotlight.gif" />
<None Include="Graphics\Weather\HGSS\hgssdark2.png" />
<Content Include="app.ico" />
<None Include="Resources\exploreKit.Image.bmp" />
<None Include="Resources\exploreKit.Image.png" />
<Content Include="Tools\blz.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@@ -9,17 +9,17 @@ namespace DSPRE
0x2 // ushort: Matrix number
0x4 // ushort: Script file number
0x6 // ushort: Level script file number
0x8 // ushort: Message file number
0x8 // ushort: Text Archive number
0xA // ushort: Day music track number
0xC // ushort: Night music track number
0xE // ushort: Wild Pok<6F>mon file number
0x10 // ushort: Event file number
* Diamond/Pearl:
0x12 // ushort: Index of map name in message file #382 (US version)
0x12 // ushort: Index of map name in Text Archive #382 (US version)
* Platinum:
0x12 // byte: Index of map name in message file #382 (US version)
0x12 // byte: Index of map name in Text Archive #382 (US version)
0x13 // byte: Map name textbox type value
0x14 // byte: Weather value
@@ -45,11 +45,11 @@ namespace DSPRE
0x4 // ushort: Matrix number
0x6 // ushort: Script file number
0x8 // ushort: Level script file
0xA // ushort: Message file number
0xA // ushort: Text Archive number
0xC // ushort: Day music track number
0xE // ushort: Night music track number
0x10 // ushort: Event file number
0x12 // byte: Index of map name in message file #382 (US version)
0x12 // byte: Index of map name in Text Archive #382 (US version)
0x13 // byte: Map name textbox type value
0x14 // byte: Weather value
0x15 // byte: Camera value

View File

@@ -9,17 +9,17 @@ namespace DSPRE
0x2 // ushort: Matrix number
0x4 // ushort: Script file number
0x6 // ushort: Level script file number
0x8 // ushort: Message file number
0x8 // ushort: Text Archive number
0xA // ushort: Day music track number
0xC // ushort: Night music track number
0xE // ushort: Wild Pok<6F>mon file number
0x10 // ushort: Event file number
* Diamond/Pearl:
0x12 // ushort: Index of map name in message file #382 (US version)
0x12 // ushort: Index of map name in Text Archive #382 (US version)
* Platinum:
0x12 // byte: Index of map name in message file #382 (US version)
0x12 // byte: Index of map name in Text Archive #382 (US version)
0x13 // byte: Map name textbox type value
0x14 // byte: Weather value
@@ -45,11 +45,11 @@ namespace DSPRE
0x4 // ushort: Matrix number
0x6 // ushort: Script file number
0x8 // ushort: Level script file
0xA // ushort: Message file number
0xA // ushort: Text Archive number
0xC // ushort: Day music track number
0xE // ushort: Night music track number
0x10 // ushort: Event file number
0x12 // byte: Index of map name in message file #382 (US version)
0x12 // byte: Index of map name in Text Archive #382 (US version)
0x13 // byte: Map name textbox type value
0x14 // byte: Weather value
0x15 // byte: Camera value

File diff suppressed because it is too large Load Diff

View File

@@ -15,8 +15,8 @@ using LibNDSFormats.NSBMD;
using LibNDSFormats.NSBTX;
namespace DSPRE {
public partial class Form1 : Form {
public Form1() {
public partial class MainProgram : Form {
public MainProgram() {
InitializeComponent();
}
@@ -40,7 +40,7 @@ namespace DSPRE {
/* ROM Information */
public static string gameCode;
public static string[] narcList;
public static string[] narcFolders;
public static string[] extractedNarcFolders;
RomInfo romInfo;
private String gameVersion;
@@ -179,7 +179,7 @@ namespace DSPRE {
}
public MessageFile LoadMessageFile(int fileID) {
return new MessageFile(new FileStream(romInfo.GetMessageFolderPath() + "\\" + fileID.ToString("D4"), FileMode.Open));
return new MessageFile(new FileStream(romInfo.GetTextArchivesPath() + "\\" + fileID.ToString("D4"), FileMode.Open));
}
private EventFile LoadEventFile(int fileID) {
@@ -284,16 +284,25 @@ namespace DSPRE {
}
else return;
}
private byte[] ReadFromArm9(int startOffset, int numberOfBytes) {
public static byte[] ReadFromArm9(long startOffset, long numberOfBytes) {
BinaryReader readArm9 = new BinaryReader(File.OpenRead(workDir + @"arm9.bin"));
readArm9.BaseStream.Position = startOffset;
byte[] targetBytes = readArm9.ReadBytes(numberOfBytes);
byte[] targetBytes = null;
if (numberOfBytes < 0) {
numberOfBytes = 2097152; //ARM9 is definitely smaller than 2MB
}
try {
targetBytes = readArm9.ReadBytes((int)numberOfBytes);
} catch (EndOfStreamException) {
Console.WriteLine("ARM9 Stream ended");
}
readArm9.Dispose();
return targetBytes;
}
private void RepackNARCs() {
foreach (var tuple in narcList.Zip(narcFolders, Tuple.Create))
foreach (var tuple in narcList.Zip(extractedNarcFolders, Tuple.Create))
{
Narc.FromFolder(tuple.Item2).Save(workDir + tuple.Item1); // Make new NARC from folder
//Directory.Delete(tuple.Item2, true); // Delete folder
@@ -301,7 +310,7 @@ namespace DSPRE {
}
private void DeleteTempFolders() {
foreach (var tuple in narcList.Zip(narcFolders, Tuple.Create)) {
foreach (var tuple in narcList.Zip(extractedNarcFolders, Tuple.Create)) {
Directory.Delete(tuple.Item2, true); // Delete folder
}
}
@@ -546,7 +555,8 @@ namespace DSPRE {
weatherComboBox.Items.AddRange(headerInfo.HGSSWeatherValues);
break;
}
if (headerListBox.Items.Count > 0)
headerListBox.SelectedIndex = 0;
}
private void SetupMapEditor()
{
@@ -782,7 +792,7 @@ namespace DSPRE {
private void SetupTextEditor()
{
for (int i = 0; i < romInfo.GetMessageCount(); i++)
selectTextFileComboBox.Items.Add("Message File " + i);
selectTextFileComboBox.Items.Add("Text Archive " + i);
selectTextFileComboBox.SelectedIndex = 0;
}
@@ -879,12 +889,13 @@ namespace DSPRE {
@"data\msgdata\msg.narc",
@"data\fielddata\script\scr_seq_release.narc",
@"data\data\mmodel\mmodel.narc",
@"data\poketool\trainer\trdata.narc"
@"data\poketool\trainer\trdata.narc",
@"data\data\weather_sys.narc"
};
narcFolders = new string[] {
extractedNarcFolders = new string[] {
romInfo.GetBuildingTexturesFolderPath(),
workDir + @"extracted\area_build",
workDir + @"unpacked\area_build",
romInfo.GetAreaDataFolderPath(),
romInfo.GetMapTexturesFolderPath(),
romInfo.GetBuildingModelsFolderPath(false),
@@ -892,10 +903,11 @@ namespace DSPRE {
romInfo.GetEventFolderPath(),
romInfo.GetMapFolderPath(),
romInfo.GetMatrixFolderPath(),
romInfo.GetMessageFolderPath(),
romInfo.GetTextArchivesPath(),
romInfo.GetScriptFolderPath(),
romInfo.GetOverworldFolderPath(),
romInfo.GetTrainerDataFolderPath(),
romInfo.getSyntheticOverlayPath()
};
if (gameVersion == "Diamond") {
@@ -904,7 +916,7 @@ namespace DSPRE {
narcList[5] += "p_enc_data.narc";
}
foreach (var tuple in narcList.Zip(narcFolders, Tuple.Create)) {
foreach (var tuple in narcList.Zip(extractedNarcFolders, Tuple.Create)) {
Narc.Open(workDir + tuple.Item1).ExtractToFolder(tuple.Item2);
}
}
@@ -924,13 +936,14 @@ namespace DSPRE {
@"data\msgdata\pl_msg.narc",
@"data\fielddata\script\scr_seq.narc",
@"data\data\mmodel\mmodel.narc",
@"data\poketool\trainer\trdata.narc"
@"data\poketool\trainer\trdata.narc",
@"data\data\weather_sys.narc"
};
narcFolders = new string[]
extractedNarcFolders = new string[]
{
romInfo.GetBuildingTexturesFolderPath(),
workDir + @"extracted\area_build",
workDir + @"unpacked\area_build",
romInfo.GetAreaDataFolderPath(),
romInfo.GetMapTexturesFolderPath(),
romInfo.GetBuildingModelsFolderPath(false),
@@ -938,13 +951,14 @@ namespace DSPRE {
romInfo.GetEventFolderPath(),
romInfo.GetMapFolderPath(),
romInfo.GetMatrixFolderPath(),
romInfo.GetMessageFolderPath(),
romInfo.GetTextArchivesPath(),
romInfo.GetScriptFolderPath(),
romInfo.GetOverworldFolderPath(),
romInfo.GetTrainerDataFolderPath()
romInfo.GetTrainerDataFolderPath(),
romInfo.getSyntheticOverlayPath()
};
foreach (var tuple in narcList.Zip(narcFolders, Tuple.Create))
foreach (var tuple in narcList.Zip(extractedNarcFolders, Tuple.Create))
{
Narc.Open(workDir + tuple.Item1).ExtractToFolder(tuple.Item2);
}
@@ -966,27 +980,29 @@ namespace DSPRE {
@"data\a\0\8\1",
@"data\a\0\5\5",
@"data\a\0\3\7",
@"data\a\1\4\8"
@"data\a\1\4\8",
@"data\a\0\2\8"
};
narcFolders = new string[]
extractedNarcFolders = new string[]
{
romInfo.GetBuildingTexturesFolderPath(),
workDir + @"extracted\area_build",
workDir + @"unpacked\area_build",
romInfo.GetAreaDataFolderPath(),
romInfo.GetMapTexturesFolderPath(),
romInfo.GetBuildingModelsFolderPath(false),
romInfo.GetEventFolderPath(),
romInfo.GetMapFolderPath(),
romInfo.GetMatrixFolderPath(),
romInfo.GetMessageFolderPath(),
romInfo.GetTextArchivesPath(),
romInfo.GetScriptFolderPath(),
romInfo.GetOverworldFolderPath(),
romInfo.GetTrainerDataFolderPath(),
romInfo.GetEncounterFolderPath(),
romInfo.GetBuildingModelsFolderPath(true)
romInfo.GetBuildingModelsFolderPath(true),
romInfo.getSyntheticOverlayPath()
};
foreach (var tuple in narcList.Zip(narcFolders, Tuple.Create))
foreach (var tuple in narcList.Zip(extractedNarcFolders, Tuple.Create))
{
Narc.Open(workDir + tuple.Item1).ExtractToFolder(tuple.Item2);
}
@@ -1010,17 +1026,17 @@ namespace DSPRE {
@"data\a\0\3\7",
@"data\a\1\4\8"
};
narcFolders = new string[]
extractedNarcFolders = new string[]
{
romInfo.GetBuildingTexturesFolderPath(),
workDir + @"extracted\area_build",
workDir + @"unpacked\area_build",
romInfo.GetAreaDataFolderPath(),
romInfo.GetMapTexturesFolderPath(),
romInfo.GetBuildingModelsFolderPath(false),
romInfo.GetEventFolderPath(),
romInfo.GetMapFolderPath(),
romInfo.GetMatrixFolderPath(),
romInfo.GetMessageFolderPath(),
romInfo.GetTextArchivesPath(),
romInfo.GetScriptFolderPath(),
romInfo.GetOverworldFolderPath(),
romInfo.GetTrainerDataFolderPath(),
@@ -1028,12 +1044,12 @@ namespace DSPRE {
romInfo.GetBuildingModelsFolderPath(true)
};
foreach (var tuple in narcList.Zip(narcFolders, Tuple.Create))
foreach (var tuple in narcList.Zip(extractedNarcFolders, Tuple.Create))
{
Narc.Open(workDir + tuple.Item1).ExtractToFolder(tuple.Item2);
}
}
private void WriteToArm9(int startOffset, byte[] bytesToWrite)
public static void WriteToArm9(long startOffset, byte[] bytesToWrite)
{
using (BinaryWriter writer = new BinaryWriter(File.OpenWrite(workDir + @"arm9.bin")))
{
@@ -1045,7 +1061,7 @@ namespace DSPRE {
private void asmHacksToolStripMenuItem_Click(object sender, EventArgs e)
{
using (ASMHacksDialog window = new ASMHacksDialog(romInfo))
using (ROMToolboxDialog window = new ROMToolboxDialog(romInfo))
{
window.ShowDialog();
if (window.standardizedItems) isItemRadioButton.Enabled = true;
@@ -1057,7 +1073,7 @@ namespace DSPRE {
}
private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
{
string message = "DS Pokémon Rom Editor by Nømura (Unofficial Branch)" + Environment.NewLine + "version 1.0.4c" + Environment.NewLine
string message = "DS Pokémon Rom Editor by Nømura (Unofficial Branch)" + Environment.NewLine + "version 1.0.5" + Environment.NewLine
+ Environment.NewLine + "This tool was largely inspired by Markitus95's Spiky's DS Map Editor, from which certain assets were also recycled. Credits go to Markitus, Ark, Zark, Florian, and everyone else who owes credit for SDSME." + Environment.NewLine +
"Special thanks go to Trifindo, Mikelan98, BagBoy, and JackHack96, whose help, research and expertise in the field of NDS Rom Hacking made the development of this tool possible.";
@@ -1118,9 +1134,11 @@ namespace DSPRE {
mainTabControl.Show();
saveRomButton.Enabled = true;
romToolboxButton.Enabled = true;
buildingEditorButton.Enabled = true;
wildEditorButton.Enabled = true;
loadRomButton.Enabled = false;
openROMToolStripMenuItem.Enabled = false;
statusLabel.Text = "Ready";
}
@@ -1154,19 +1172,27 @@ namespace DSPRE {
}
private void wildEditorButton_Click(object sender, EventArgs e)
{
openWildEditor();
}
private void openWildEditor() {
switch (gameVersion) {
case "Diamond":
case "Pearl":
case "Platinum":
using (WildEditorDPPt editor = new WildEditorDPPt(romInfo.GetEncounterFolderPath(), GetPokémonNames()))
using (WildEditorDPPt editor = new WildEditorDPPt(romInfo.GetEncounterFolderPath(), GetPokémonNames()))
editor.ShowDialog();
break;
default:
using (WildEditorHGSS editor = new WildEditorHGSS(romInfo.GetEncounterFolderPath(), GetPokémonNames()))
using (WildEditorHGSS editor = new WildEditorHGSS(romInfo.GetEncounterFolderPath(), GetPokémonNames()))
editor.ShowDialog();
break;
}
}
private void openWildEditorWithIdButtonClick(object sender, EventArgs e) {
openWildEditor();
}
#endregion
#region Header Editor
@@ -1349,10 +1375,13 @@ namespace DSPRE {
if (disableHandlers)
return;
currentHeader = LoadHeader(headerListBox.SelectedIndex);
String currentInternalName = headerListBox.SelectedItem.ToString();
const String separator = ": ";
int separatorLoc = currentInternalName.IndexOf(separator);
currentHeader = LoadHeader( Int32.Parse(currentInternalName.Substring(0, separatorLoc )) );
/* Setup controls for common fields across headers */
internalNameBox.Text = internalNames[headerListBox.SelectedIndex];
internalNameBox.Text = currentInternalName.Substring(separatorLoc+separator.Length);
matrixUpDown.Value = currentHeader.matrix;
areaDataUpDown.Value = currentHeader.areaDataID;
scriptFileUpDown.Value = currentHeader.script;
@@ -1530,6 +1559,78 @@ namespace DSPRE {
int headerOffset = romInfo.GetHeaderTableOffset() + 0x18 * headerListBox.SelectedIndex;
WriteToArm9(headerOffset, currentHeader.SaveHeader());
}
private void resetButton_Click(object sender, EventArgs e) {
if (headerListBox.Items.Count < internalNames.Count)
resetHeaderSearchResults();
}
private void resetHeaderSearchResults() {
headerListBox.Enabled = true;
searchLocationTextBox.Clear();
headerListBox.Items.Clear();
for (int i = 0; i < internalNames.Count; i++) {
String name = internalNames[i];
headerListBox.Items.Add(i + ": " + name);
}
}
private void searchHeaderTextBox_KeyPress(object sender, KeyEventArgs e) {
if (e.KeyCode == Keys.Enter) {
startSearchGameLocation();
}
}
private void searchHeaderButton_Click(object sender, EventArgs e) {
startSearchGameLocation();
}
private void startSearchGameLocation() {
if (searchLocationTextBox.Text.Length != 0) {
headerListBox.Items.Clear();
bool notEmpty = false;
switch (gameVersion) {
case "Diamond":
case "Pearl":
for (int i = 0; i < internalNames.Count; i++) {
String locationName = mapNameComboBox.Items[((HeaderDP)LoadHeader(i)).mapName].ToString();
if (locationName.IndexOf(searchLocationTextBox.Text, StringComparison.InvariantCultureIgnoreCase) >= 0) {
headerListBox.Items.Add(i + ": " + internalNames[i]);
notEmpty = true;
}
}
break;
case "Platinum":
for (int i = 0; i < internalNames.Count; i++) {
String locationName = mapNameComboBox.Items[((HeaderPt)LoadHeader(i)).mapName].ToString();
if (locationName.IndexOf(searchLocationTextBox.Text, StringComparison.InvariantCultureIgnoreCase) >= 0) {
headerListBox.Items.Add(i + ": " + internalNames[i]);
notEmpty = true;
}
}
break;
case "HeartGold":
case "SoulSilver":
for (int i = 0; i < internalNames.Count; i++) {
String locationName = mapNameComboBox.Items[((HeaderHGSS)LoadHeader(i)).mapName].ToString();
if (locationName.IndexOf(searchLocationTextBox.Text, StringComparison.InvariantCultureIgnoreCase) >= 0) {
headerListBox.Items.Add(i + ": " + internalNames[i]);
notEmpty = true;
}
}
break;
}
if (notEmpty)
headerListBox.SelectedIndex = 0;
else {
headerListBox.Items.Add("No Result for " + '"' + searchLocationTextBox.Text + '"');
headerListBox.Enabled = false;
}
} else if (headerListBox.Items.Count < internalNames.Count) {
resetHeaderSearchResults();
}
}
private void scriptFileUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
@@ -1537,7 +1638,8 @@ namespace DSPRE {
}
private void showNameComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers)
return;
currentHeader.showName = Byte.Parse(showNameComboBox.SelectedItem.ToString().Substring(1, 3));
}
private void textFileUpDown_ValueChanged(object sender, EventArgs e)
@@ -1691,6 +1793,8 @@ namespace DSPRE {
}
private void headersGridView_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
{
if (headerListBox.Items.Count < internalNames.Count)
resetHeaderSearchResults();
if (e.RowIndex >= 0 && e.ColumnIndex >= 0)
{
int headerNumber = Convert.ToInt32(headersGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value);
@@ -3959,18 +4063,21 @@ namespace DSPRE {
}
private void owIDNumericUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers)
return;
if (currentEventFile.overworlds.Any() && overworldsListBox.SelectedIndex > 0)
currentEventFile.overworlds[overworldsListBox.SelectedIndex].owID = (ushort)owIDNumericUpDown.Value;
}
private void owMovementComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers)
return;
currentEventFile.overworlds[overworldsListBox.SelectedIndex].movement = (ushort)owMovementComboBox.SelectedIndex;
}
private void owOrientationComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers)
return;
currentEventFile.overworlds[overworldsListBox.SelectedIndex].orientation = (ushort)owOrientationComboBox.SelectedIndex;
owSpritePictureBox.BackgroundImage = GetOverworldImage(currentEventFile.overworlds[overworldsListBox.SelectedIndex].spriteID, currentEventFile.overworlds[overworldsListBox.SelectedIndex].orientation);
DisplayActiveEvents();
@@ -3978,21 +4085,26 @@ namespace DSPRE {
}
private void owScriptNumericUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers)
return;
currentEventFile.overworlds[overworldsListBox.SelectedIndex].scriptNumber = (ushort)owScriptNumericUpDown.Value;
}
private void owSightRangeUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers)
return;
currentEventFile.overworlds[overworldsListBox.SelectedIndex].sightRange = (ushort)owSightRangeUpDown.Value;
}
private void owSpriteComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
currentEventFile.overworlds[overworldsListBox.SelectedIndex].spriteID = (ushort)owSpriteComboBox.SelectedIndex;
owSpritePictureBox.BackgroundImage = GetOverworldImage(currentEventFile.overworlds[overworldsListBox.SelectedIndex].spriteID, currentEventFile.overworlds[overworldsListBox.SelectedIndex].orientation);
DisplayActiveEvents();
owSpritePictureBox.Invalidate();
if (disableHandlers)
return;
if (currentEventFile.overworlds.Count != 0) {
currentEventFile.overworlds[overworldsListBox.SelectedIndex].spriteID = (ushort)owSpriteComboBox.SelectedIndex;
owSpritePictureBox.BackgroundImage = GetOverworldImage(currentEventFile.overworlds[overworldsListBox.SelectedIndex].spriteID, currentEventFile.overworlds[overworldsListBox.SelectedIndex].orientation);
DisplayActiveEvents();
owSpritePictureBox.Invalidate();
}
}
private void owPartnerTrainerCheckBox_CheckedChanged(object sender, EventArgs e)
{
@@ -4632,13 +4744,13 @@ namespace DSPRE {
for (int j = 0; j < file.scripts.Count; j++) {
for (int k = 0; k < file.scripts[j].commands.Count; k++) {
if (file.scripts[j].commands[k].cmdName.Contains(searchString))
searchInScriptsResultTextBox.AppendText((i + 1) + " - " + "Script " + (j + 1) + ": " + file.scripts[j].commands[k].cmdName + Environment.NewLine);
searchInScriptsResultTextBox.AppendText(i + " - " + "Script " + (j + 1) + ": " + file.scripts[j].commands[k].cmdName + Environment.NewLine);
}
}
for (int j = 0; j < file.functions.Count; j++) {
for (int k = 0; k < file.functions[j].commands.Count; k++) {
if (file.functions[j].commands[k].cmdName.Contains(searchString))
searchInScriptsResultTextBox.AppendText((i + 1) + " - " + "Function " + (j+1) + ": " + file.functions[j].commands[k].cmdName + Environment.NewLine);
searchInScriptsResultTextBox.AppendText(i + " - " + "Function " + (j + 1) + ": " + file.functions[j].commands[k].cmdName + Environment.NewLine);
}
}
}
@@ -4933,11 +5045,11 @@ namespace DSPRE {
private void addMessageFileButton_Click(object sender, EventArgs e)
{
/* Add new event file to event folder */
string messageFilePath = romInfo.GetMessageFolderPath() + "\\" + selectTextFileComboBox.Items.Count.ToString("D4");
string messageFilePath = romInfo.GetTextArchivesPath() + "\\" + selectTextFileComboBox.Items.Count.ToString("D4");
using (BinaryWriter writer = new BinaryWriter(new FileStream(messageFilePath, FileMode.Create))) writer.Write(LoadMessageFile(0).Save());
/* Update ComboBox and select new file */
selectTextFileComboBox.Items.Add("Message File " + selectTextFileComboBox.Items.Count);
selectTextFileComboBox.Items.Add("Text Archive " + selectTextFileComboBox.Items.Count);
selectTextFileComboBox.SelectedIndex = selectTextFileComboBox.Items.Count - 1;
}
private void addStringButton_Click(object sender, EventArgs e)
@@ -4955,7 +5067,7 @@ namespace DSPRE {
private void exportTextFileButton_Click(object sender, EventArgs e)
{
SaveFileDialog sf = new SaveFileDialog();
sf.Filter = "Message File (*.msg)|*.msg";
sf.Filter = "Text Archive (*.msg)|*.msg";
if (sf.ShowDialog(this) != DialogResult.OK)
return;
@@ -4965,23 +5077,23 @@ namespace DSPRE {
{
/* Prompt user to select .msg file */
OpenFileDialog of = new OpenFileDialog();
of.Filter = "Message File (*.msg)|*.msg";
of.Filter = "Text Archive (*.msg)|*.msg";
if (of.ShowDialog(this) != DialogResult.OK) return;
/* Update message file object in memory */
string path = romInfo.GetMessageFolderPath() + "\\" + selectTextFileComboBox.SelectedIndex.ToString("D4");
/* Update Text Archive object in memory */
string path = romInfo.GetTextArchivesPath() + "\\" + selectTextFileComboBox.SelectedIndex.ToString("D4");
File.Copy(of.FileName, path, true);
/* Display success message */
MessageBox.Show("Message file imported successfully!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
MessageBox.Show("Text Archive imported successfully!", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
/* Refresh controls */
selectTextFileComboBox_SelectedIndexChanged(null, null);
}
private void removeMessageFileButton_Click(object sender, EventArgs e)
{
/* Delete message file */
File.Delete(romInfo.GetMessageFolderPath() + "\\" + (selectTextFileComboBox.Items.Count - 1).ToString("D4"));
/* Delete Text Archive */
File.Delete(romInfo.GetTextArchivesPath() + "\\" + (selectTextFileComboBox.Items.Count - 1).ToString("D4"));
/* Check if currently selected file is the last one, and in that case select the one before it */
int lastIndex = selectTextFileComboBox.Items.Count - 1;
@@ -4998,9 +5110,12 @@ namespace DSPRE {
textEditorDataGridView.Rows.RemoveAt(textEditorDataGridView.Rows.Count - 1);
}
}
private void saveMessageFileButton_Click(object sender, EventArgs e)
{
BinaryWriter textWriter = new BinaryWriter(new FileStream(romInfo.GetMessageFolderPath() + "\\" + selectTextFileComboBox.SelectedIndex.ToString("D4"), FileMode.Create));
private void saveTextArchiveButton_Click(object sender, EventArgs e) {
saveTextArchive();
}
private void saveTextArchive() {
BinaryWriter textWriter = new BinaryWriter(new FileStream(romInfo.GetTextArchivesPath() + "\\" + selectTextFileComboBox.SelectedIndex.ToString("D4"), FileMode.Create));
textWriter.Write((UInt16)currentMessageFile.messages.Count);
textWriter.Write((UInt16)currentMessageFile.initialKey);
int key = (currentMessageFile.initialKey * 0x2FD) & 0xFFFF;
@@ -5023,8 +5138,7 @@ namespace DSPRE {
{
key = (0x91BD3 * (i + 1)) & 0xFFFF;
int[] currentString = currentMessageFile.EncodeString(textEditorDataGridView[0, i].Value.ToString(), i, stringSize[i]);
for (int j = 0; j < stringSize[i] - 1; j++)
{
for (int j = 0; j < stringSize[i] - 1; j++) {
textWriter.Write((UInt16)(currentString[j] ^ key));
key += 0x493D;
key &= 0xFFFF;
@@ -5041,21 +5155,33 @@ namespace DSPRE {
int msgCount = romInfo.GetMessageCount();
if (msgCount > 828)
msgCount = 828;
for (int i = 0; i < msgCount; i++)
{
MessageFile file = LoadMessageFile(i);
string result = "File" + " " + i + ", " + "n. ";
for (int j = 0; j < file.messages.Count; j++)
if (file.messages[j].Contains(searchString))
result += j.ToString("D") + ", ";
if (result != "File" + " " + i + ", " + "n. ")
searchMessageResultTextBox.AppendText(result + Environment.NewLine);
for (int i = 0; i < msgCount; i++) {
caseSensitiveCheckbox.Enabled = false;
MessageFile file = LoadMessageFile(i);
string result = '(' + i + ')' + " - Line #";
if (caseSensitiveCheckbox.Checked) {
for (int j = 0; j < file.messages.Count; j++)
if (file.messages[j].Contains(searchString))
result += j.ToString("D") + ", ";
if (result != ('(' + i + ')' + " - Line #"))
searchMessageResultTextBox.AppendText(result + Environment.NewLine);
} else {
for (int j = 0; j < file.messages.Count; j++)
if (file.messages[j].IndexOf(searchString, StringComparison.InvariantCultureIgnoreCase) >= 0)
result += j.ToString("D") + ", ";
if (result != ('(' + i + ')' + " - Line #"))
searchMessageResultTextBox.AppendText(result + Environment.NewLine);
}
textSearchProgressBar.Value = i;
}
textSearchProgressBar.Value = 0;
caseSensitiveCheckbox.Enabled = true;
}
private void replaceMessageButton_Click(object sender, EventArgs e)
{
@@ -5093,7 +5219,7 @@ namespace DSPRE {
textEditorDataGridView.Rows[i].HeaderCell.Value = "0x" + i.ToString("X");
}
disableHandlers = false;
BinaryWriter textWriter = new BinaryWriter(new FileStream(romInfo.GetMessageFolderPath() + "\\" + k.ToString("D4"), FileMode.Create));
BinaryWriter textWriter = new BinaryWriter(new FileStream(romInfo.GetTextArchivesPath() + "\\" + k.ToString("D4"), FileMode.Create));
textWriter.Write((UInt16)currentMessageFile.messages.Count);
textWriter.Write((UInt16)currentMessageFile.initialKey);
int key = (currentMessageFile.initialKey * 0x2FD) & 0xFFFF;
@@ -5356,9 +5482,5 @@ namespace DSPRE {
#endregion
private void button10_Click(object sender, EventArgs e) {
}
}
}

View File

@@ -117,43 +117,9 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="texturePictureBox.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAMAAABrrFhUAAAABGdBTUEAALGPC/xhBQAAAwBQTFRFv7+/
////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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R7EGedBnHEexBnnQZxxHsT7dvuw4VnnQZxxHsQZ50Gc
cR7EGedBnHEexBnnQZzxm38WxhnnQZxxHsQZ50GccR7EGedBnHEexBnnQbxvtw8bnnUexBnnQZxxHsQZ
50GccR7EGedBnHEexBm/+WdhnHEexBnnQZxxHsQZ50GccR7EGedBnHEexPt2+7DhWedBnHEexBnnQZxx
HsQZ50GccR7EGedBnPGbfxbGGedBnHEexBnnQZxxHsQZ50GccR7EGedBvG+3DxuedR7EGedBnHEexBnn
QZxxHsQZ50GccR7EEX8+38T8gAGeHzYoAAAAAElFTkSuQmCC
</value>
</data>
<metadata name="messageColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="mainTabImageList.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>239, 17</value>
</metadata>
@@ -162,7 +128,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACA
DwAAAk1TRnQBSQFMAgEBBwEAASABAgEgAQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
DwAAAk1TRnQBSQFMAgEBBwEAAXQBAgF0AQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA
@@ -231,6 +197,7 @@
AR8BAAEBAQABAQL/Cw==
</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="messageButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
@@ -485,9 +452,42 @@
<metadata name="messageColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="messageColumn.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<data name="texturePictureBox.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAMAAABrrFhUAAAABGdBTUEAALGPC/xhBQAAAwBQTFRFv7+/
////AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAA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QZ50GccR7EEX8+38T8gAGeHzYoAAAAAElFTkSuQmCC
</value>
</data>
<metadata name="menuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
@@ -533,6 +533,19 @@
X7slg+9Xrkqr/pkFIueSCfl8ZdyMYQO7rTVptfciYWIOF9yqg2bAgN5XkrQFjIggpqJhA82aZ0odhR/X
b9vywwW36qAZMJCvlaTY6PwN31qQvnzFov9CQk50Tv1AetaOOifm5vYC3GighWbAgItMOmXh+34s3Nxe
COsUCoWxfwD3PuPq9HO7GwAAAABJRU5ErkJggg==
</value>
</data>
<data name="romToolboxButton.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGNSURBVFhH7ZQxUsJAGEY5EiWlJcegpOQIHMHSI1hSUlJy
BEtLS0o6nbfmOZ9LEjAjaEb/mTfRze7/veyGTEZR0+n0VZqh2xWhj+tF4Xg83laCsP12+UcFMnw+nxee
Xg7XFyCgLTwFhtJEdBeT3O46PAUOz5uLKQ/ycFc4K8GE++2ul9wFmrdRhzv++wUomyceQUoAY3lkYqDr
VotZgV5NzOXFomzYthueceGaAjRPCf6erXYfO1ULEJpy4xUgCJbrdStIKJICn8SGCPi0vnTCJxk2u30h
RVLYnVLkSwJMpnlbcP6vBBiqkAIp0rQ/Xz8qwEQaGNInwDUlMniQhOE0M8Bg6RNgfQbWEr0ChoMBiiSG
1eHA2pT4doEM6xLgXVBisEA2E8drXOO8/eL9J8dYhiN8VsAmfMW45tP7TXdODcFCrwyWTgHDbeCXKwW4
z7giGZgwz34ZfnUB7gNbP0ggz5EAxgwDx51T45lzVaKmiTstbnpmnls+veTT+BLmuovCuioXD6Vp9V9j
qcnkDWXJtp9DVaw7AAAAAElFTkSuQmCC
</value>
</data>
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

View File

@@ -16,7 +16,7 @@ namespace DSPRE
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Application.Run(new MainProgram());
}
}
}

View File

@@ -4,11 +4,11 @@ using System.Runtime.InteropServices;
// Le informazioni generali relative a un assembly sono controllate dal seguente
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
// associate a un assembly.
[assembly: AssemblyTitle("DSPRE Reloaded 1.0.4a")]
[assembly: AssemblyTitle("DSPRE Reloaded 1.0.5")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DSPRE Reloaded 1.0.4a")]
[assembly: AssemblyProduct("DSPRE Reloaded 1.0.5")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
@@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
// usando l'asterisco '*' come illustrato di seguito:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.4")]
[assembly: AssemblyFileVersion("1.0.4")]
[assembly: AssemblyVersion("1.0.5")]
[assembly: AssemblyFileVersion("1.0.5")]

208
DS_Map/ROMToolboxDialog.Designer.cs generated Normal file
View File

@@ -0,0 +1,208 @@
namespace DSPRE
{
partial class ROMToolboxDialog
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent() {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ROMToolboxDialog));
this.applyItemStandardizeButton = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.label2 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
this.applyARM9ExpansionButton = new System.Windows.Forms.Button();
this.label5 = new System.Windows.Forms.Label();
this.label6 = new System.Windows.Forms.Label();
this.button1 = new System.Windows.Forms.Button();
this.label7 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.namesToNormalCaseButton = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// applyItemStandardizeButton
//
this.applyItemStandardizeButton.Location = new System.Drawing.Point(330, 273);
this.applyItemStandardizeButton.Name = "applyItemStandardizeButton";
this.applyItemStandardizeButton.Size = new System.Drawing.Size(100, 31);
this.applyItemStandardizeButton.TabIndex = 0;
this.applyItemStandardizeButton.Text = "Apply";
this.applyItemStandardizeButton.UseVisualStyleBackColor = true;
this.applyItemStandardizeButton.Click += new System.EventHandler(this.applyItemStandardizeButton_Click);
//
// label1
//
this.label1.AutoSize = true;
this.label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label1.Location = new System.Drawing.Point(15, 258);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(155, 13);
this.label1.TabIndex = 1;
this.label1.Text = "Standardize Item Numbers";
//
// label2
//
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(15, 273);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(305, 26);
this.label2.TabIndex = 2;
this.label2.Text = "Makes it so that PokéBall item scripts follow the order of items\r\nas indexed in t" +
"he ROM. Needed for \'Item\' option in Event Editor\r\n";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(15, 32);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(298, 52);
this.label3.TabIndex = 5;
this.label3.Text = resources.GetString("label3.Text");
//
// label4
//
this.label4.AutoSize = true;
this.label4.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label4.Location = new System.Drawing.Point(15, 17);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(103, 13);
this.label4.TabIndex = 4;
this.label4.Text = "ARM9 Expansion";
//
// applyARM9ExpansionButton
//
this.applyARM9ExpansionButton.Location = new System.Drawing.Point(330, 32);
this.applyARM9ExpansionButton.Name = "applyARM9ExpansionButton";
this.applyARM9ExpansionButton.Size = new System.Drawing.Size(100, 31);
this.applyARM9ExpansionButton.TabIndex = 3;
this.applyARM9ExpansionButton.Text = "Expand ARM9";
this.applyARM9ExpansionButton.UseVisualStyleBackColor = true;
this.applyARM9ExpansionButton.Click += new System.EventHandler(this.applyARM9ExpansionButton_Click);
//
// label5
//
this.label5.AutoSize = true;
this.label5.Location = new System.Drawing.Point(14, 118);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(314, 52);
this.label5.TabIndex = 8;
this.label5.Text = "Adds Dynamic BDHC Cameras to current ROM.\r\nWith this patch, you can make the game" +
" camera move\r\nbased on the player\'s position.\r\nYou will need Trifindo\'s PDSMS, i" +
"n order to make BDHCAM Files.\r\n";
//
// label6
//
this.label6.AutoSize = true;
this.label6.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label6.Location = new System.Drawing.Point(14, 103);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(269, 13);
this.label6.TabIndex = 7;
this.label6.Text = "Dynamic Cameras (Requires ARM9 Expansion)";
//
// button1
//
this.button1.Enabled = false;
this.button1.Location = new System.Drawing.Point(330, 118);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(100, 31);
this.button1.TabIndex = 6;
this.button1.Text = "Coming soon";
this.button1.UseVisualStyleBackColor = true;
//
// label7
//
this.label7.AutoSize = true;
this.label7.Location = new System.Drawing.Point(15, 208);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(305, 26);
this.label7.TabIndex = 11;
this.label7.Text = "Makes it so that PokéBall item scripts follow the order of items\r\nas indexed in t" +
"he ROM. Needed for \'Item\' option in Event Editor\r\n";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.label8.Location = new System.Drawing.Point(15, 193);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(155, 13);
this.label8.TabIndex = 10;
this.label8.Text = "Standardize Item Numbers";
//
// namesToNormalCaseButton
//
this.namesToNormalCaseButton.Enabled = false;
this.namesToNormalCaseButton.Location = new System.Drawing.Point(330, 208);
this.namesToNormalCaseButton.Name = "namesToNormalCaseButton";
this.namesToNormalCaseButton.Size = new System.Drawing.Size(100, 31);
this.namesToNormalCaseButton.TabIndex = 9;
this.namesToNormalCaseButton.Text = "Coming soon";
this.namesToNormalCaseButton.UseVisualStyleBackColor = true;
this.namesToNormalCaseButton.Click += new System.EventHandler(this.applyPokemonNamesToNormalCase_Click);
//
// ROMToolboxDialog
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.ClientSize = new System.Drawing.Size(442, 328);
this.Controls.Add(this.label7);
this.Controls.Add(this.label8);
this.Controls.Add(this.namesToNormalCaseButton);
this.Controls.Add(this.label5);
this.Controls.Add(this.label6);
this.Controls.Add(this.button1);
this.Controls.Add(this.label3);
this.Controls.Add(this.label4);
this.Controls.Add(this.applyARM9ExpansionButton);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Controls.Add(this.applyItemStandardizeButton);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "ROMToolboxDialog";
this.Text = "ROM Toolbox";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Button applyItemStandardizeButton;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Button applyARM9ExpansionButton;
private System.Windows.Forms.Label label5;
private System.Windows.Forms.Label label6;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label7;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.Button namesToNormalCaseButton;
}
}

264
DS_Map/ROMToolboxDialog.cs Normal file
View File

@@ -0,0 +1,264 @@
using NarcAPI;
using System;
using System.IO;
using System.Windows.Forms;
namespace DSPRE
{
public partial class ROMToolboxDialog : Form
{
RomInfo rom;
public bool standardizedItems = new bool();
public ROMToolboxDialog(RomInfo romInfo)
{
InitializeComponent();
this.rom = romInfo;
}
private void applyItemStandardizeButton_Click(object sender, EventArgs e)
{
string path = rom.GetScriptFolderPath() + "\\" + rom.GetItemScriptFileNumber().ToString("D4");
ScriptFile file = new ScriptFile(new FileStream(path, FileMode.Open), rom.getGameVersion());
for (int i = 0; i < file.scripts.Count - 1; i++)
{
file.scripts[i].commands[0].parameters[1] = BitConverter.GetBytes((ushort)i); // Fix item index
file.scripts[i].commands[1].parameters[1] = BitConverter.GetBytes((ushort)1); // Fix item quantity
}
using (BinaryWriter writer = new BinaryWriter(new FileStream(path, FileMode.Create))) writer.Write(file.Save());
standardizedItems = true;
}
private void applyARM9ExpansionButton_Click(object sender, EventArgs e) {
String version = rom.getGameVersion();
String lang = rom.GetLanguage();
String arm9path = rom.getWorkingFolder() + @"arm9.bin";
long initOffset;
String initString;
long branchOffset;
String branchCodeString;
int fileID = -1;
switch (version) {
case "Diamond":
case "Pearl":
fileID = 9;
branchOffset = 0x02000C80;
initString = "FC B5 05 48 " +
"C0 46 41 21 " +
"09 22 02 4D " +
"A8 47 00 20 " +
"03 21 FC BD " +
"F1 64 00 02 " +
"00 80 3C 02";
switch (lang) {
case "USA":
initOffset = 0x021064EC;
branchCodeString = "05 F1 34 FC";
break;
case "ESP":
initOffset = 0x0210668C;
branchCodeString = "05 F1 04 FD";
break;
default:
unsupportedROMLanguage();
return;
}
break;
case "Platinum":
fileID = 9;
branchOffset = 0x02000CB4;
switch (lang) {
case "USA":
initString = "FC B5 05 48 " +
"C0 46 41 21 " +
"09 22 02 4D " +
"A8 47 00 20 " +
"03 21 FC BD " +
"A5 6A 00 02 " +
"00 80 3C 02";
initOffset = 0x02100E20;
branchCodeString = "00 F1 B4 F8";
break;
case "ESP":
initString = "FC B5 05 48 " +
"C0 46 41 21 " +
"09 22 02 4D " +
"A8 47 00 20 " +
"03 21 FC BD " +
"B9 6A 00 02 " +
"00 80 3C 02";
initOffset = 0x0210101C;
branchCodeString = "00 F1 B2 F9";
break;
default:
unsupportedROMLanguage();
return;
}
break;
case "HeartGold":
case "SoulSilver":
fileID = 0;
branchOffset = 0x02000CD0;
initString = "FC B5 05 48 " +
"C0 46 1C 21 " +
"00 22 02 4D " +
"A8 47 00 20 " +
"03 21 FC BD " +
"09 75 00 02 " +
"00 80 3C 02";
switch (lang) {
case "USA":
initOffset = 0x02110334;
branchCodeString = "0F F1 30 FB";
break;
case "ESP":
initOffset = 0x02110354;
branchCodeString = "0F F1 40 FB";
break;
default:
unsupportedROMLanguage();
return;
}
break;
default:
unsupportedROM();
return;
}
initOffset -= 0x02000000;
branchOffset -= 0x02000000;
DialogResult d;
d = MessageBox.Show("Confirming this process will apply the following changes:\n\n" +
"- Backup ARM9 file (arm9.bin.bak will be created)." + "\n\n" +
"- Replace " + (branchCodeString.Length/3+1) + " bytes of data at arm9 offset 0x" + branchOffset.ToString("X") + " with " + '\n' + branchCodeString + "\n\n" +
"- Replace " + (initString.Length / 3+1) + " bytes of data at arm9 offset 0x" + initOffset.ToString("X") + " with " + '\n' + initString + "\n\n" +
"- Modify file #" + fileID + " inside " + '\n' + rom.getSyntheticOverlayPath() + '\n' + " to accommodate for 88KB of data (no backup)." + "\n\n" +
"Do you wish to continue?",
"Confirm to proceed", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (d == DialogResult.Yes) {
if (arm9expand(arm9path, fileID, initOffset, initString, branchOffset, branchCodeString))
MessageBox.Show("Operation successful.", "ARM9 usable memory has been expanded.", MessageBoxButtons.OK, MessageBoxIcon.Information);
else {
MessageBox.Show("Operation failed. It is strongly advised that you restore the arm9 backup (arm9.bin.bak).", "Something went wrong",
MessageBoxButtons.OK, MessageBoxIcon.Error);
}
} else {
MessageBox.Show("No changes have been made.", "Operation canceled", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void applyPokemonNamesToNormalCase_Click(object sender, EventArgs e) {
String version = rom.getGameVersion();
int[] fileArchives = null;
switch (version) {
case "Diamond":
case "Pearl":
fileArchives = new int[2] { 443, 444 };
break;
case "Platinum":
fileArchives = new int[7] { 493, 494, 793, 794, 795, 796, 797};
break;
case "HeartGold":
case "SoulSilver":
fileArchives = new int[7] { 237, 238, 817, 818, 819, 820, 821};
break;
default:
unsupportedROM();
return;
}
DialogResult d;
d = MessageBox.Show("Confirming this process will apply the following changes:\n\n" +
"- Every Pokémon name will be converted to Normal Case." + "\n\n" +
"Do you wish to continue?",
"Confirm to proceed", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
if (d == DialogResult.Yes) {
namesToNormalCase(fileArchives);
MessageBox.Show("Operation successful.", "Pokémon names have been converted to Normal Case.", MessageBoxButtons.OK, MessageBoxIcon.Information);
} else {
MessageBox.Show("No changes have been made.", "Operation canceled", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private void namesToNormalCase(int[] fileArchives) {
//TODO implement this
}
private bool arm9expand(String arm9path, int fileID, long initOffset, string initString, long branchOffset, string branchString) {
if (File.Exists(arm9path + ".bak"))
File.Delete(arm9path + ".bak");
File.Copy(arm9path, arm9path + ".bak");
try {
long current = 0;
MainProgram.WriteToArm9(current, MainProgram.ReadFromArm9(current, branchOffset - current)); //Copy all until branchOffset
MainProgram.WriteToArm9(branchOffset, hexStringtoByteArray(branchString, branchString.Length)); //Write new branchOffset
current = branchOffset + branchString.Length;
MainProgram.WriteToArm9(current, MainProgram.ReadFromArm9(current, initOffset - current)); //Copy all from branchOffset to initOffset
MainProgram.WriteToArm9(initOffset, hexStringtoByteArray(initString, initString.Length)); //Write new initOffset
current = initOffset + initString.Length;
MainProgram.WriteToArm9(current, MainProgram.ReadFromArm9(current, -1));
} catch {
return false;
}
String fullFilePath = rom.getSyntheticOverlayPath() + '\\' + fileID.ToString().PadLeft(4, '0');
File.Delete(fullFilePath);
BinaryWriter f = new BinaryWriter(File.Create(fullFilePath));
for (int i = 0; i < 0x16000; i++)
f.Write((byte)0x00);
f.Close();
return true;
}
private byte[] hexStringtoByteArray (String hexString, int size) {
//FC B5 05 48 C0 46 41 21
//09 22 02 4D A8 47 00 20
//03 21 FC BD F1 64 00 02
//00 80 3C 02
hexString = hexString.Trim();
if ((hexString.Length+1) % 2 != 0)
return null;
if ((hexString.Length) > size*3)
return null;
byte[] b = new byte[size/3 + 1];
for (int i = 0; i < hexString.Length; i += 2) {
if (hexString[i] == ' ') {
hexString = hexString.Substring(1, hexString.Length - 1);
}
b[i/2] = Convert.ToByte(hexString.Substring(i, 2), 16);
}
return b;
}
private void unsupportedROM() {
MessageBox.Show("This operation is currently impossible to carry out on any Pokémon " + rom.getGameVersion() + "ROM.",
"Unsupported ROM", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
private void unsupportedROMLanguage() {
MessageBox.Show("This operation is currently impossible to carry out on the " + rom.GetLanguage() +
" version of this ROM.", "Unsupported language", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}

View File

@@ -117,4 +117,11 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="label3.Text" xml:space="preserve">
<value>Expands the ARM9's usable memory by repurposing a file
inside an unused NARC and turning it into a synthetic overlay,
in which you can place new code or new data.
This patch is necessary to accomplish most ASM edits.
</value>
</data>
</root>

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B

View File

@@ -1,5 +1,6 @@
using System.IO;
using System.Collections.Generic;
using System;
namespace DSPRE
{
@@ -11,22 +12,25 @@ namespace DSPRE
public class RomInfo
{
private string romID;
private string workingFolder;
private string workDir;
private string gameVersion;
#region Constructors (1)
public RomInfo(string id, string workingFolder)
public RomInfo(string id, string workDir)
{
romID = id;
gameVersion = getGameVersion();
this.workingFolder = workingFolder;
this.workDir = workDir;
}
#endregion
#region Methods (22)
public string getWorkingFolder() {
return workDir;
}
public string GetAreaDataFolderPath()
{
return workingFolder + @"extracted\area_data";
return workDir + @"unpacked\area_data";
}
public int GetAreaDataCount()
{
@@ -40,16 +44,16 @@ namespace DSPRE
case "Diamond":
case "Pearl":
case "Platinum":
path = @"extracted\DPPtBuildings";
path = @"unpacked\DPPtBuildings";
break;
default:
if (interior)
path = @"extracted\HGSSBuildingsIN";
path = @"unpacked\HGSSBuildingsIN";
else
path = @"extracted\HGSSBuildingsOUT";
path = @"unpacked\HGSSBuildingsOUT";
break;
}
return workingFolder + path;
return workDir + path;
}
public int GetBuildingCount(bool interior)
{
@@ -94,7 +98,7 @@ namespace DSPRE
}
public int GetHeaderCount()
{
return (int)new FileInfo(workingFolder + @"data\fielddata\maptable\mapname.bin").Length / 0x10;
return (int)new FileInfo(workDir + @"data\fielddata\maptable\mapname.bin").Length / 0x10;
}
public int GetAttackNamesMessageNumber()
{
@@ -238,14 +242,14 @@ namespace DSPRE
}
public string GetMapTexturesFolderPath()
{
return workingFolder + @"extracted\maptex";
return workDir + @"unpacked\maptex";
}
public int GetMapTexturesCount()
{
return Directory.GetFiles(GetMapTexturesFolderPath()).Length;
}
public string GetBuildingTexturesFolderPath() {
return workingFolder + @"extracted\TextureBLD";
return workDir + @"unpacked\TextureBLD";
}
public int GetBuildingTexturesCount()
@@ -253,27 +257,27 @@ namespace DSPRE
return Directory.GetFiles(GetBuildingTexturesFolderPath()).Length;
}
public string GetMatrixFolderPath() {
return workingFolder + @"extracted\matrix";
return workDir + @"unpacked\matrix";
}
public int GetMatrixCount()
{
return Directory.GetFiles(GetMatrixFolderPath()).Length;
}
public string GetMessageFolderPath()
public string GetTextArchivesPath()
{
return workingFolder + @"extracted\msg";
return workDir + @"unpacked\msg";
}
public int GetMessageCount()
{
return Directory.GetFiles(GetMessageFolderPath()).Length;
return Directory.GetFiles(GetTextArchivesPath()).Length;
}
public string GetTrainerDataFolderPath()
{
return workingFolder + @"extracted\trainerdata";
return workDir + @"unpacked\trainerdata";
}
public string GetMapFolderPath()
{
return workingFolder + @"extracted\maps";
return workDir + @"unpacked\maps";
}
public int GetMapCount()
{
@@ -281,11 +285,11 @@ namespace DSPRE
}
public string GetOverworldFolderPath()
{
return workingFolder + @"extracted\overworlds";
return workDir + @"unpacked\overworlds";
}
public string GetEncounterFolderPath()
{
return workingFolder + @"extracted\wildPokeData";
return workDir + @"unpacked\wildPokeData";
}
public int GetEventCount()
{
@@ -293,7 +297,7 @@ namespace DSPRE
}
public string GetEventFolderPath()
{
return workingFolder + @"extracted\events";
return workDir + @"unpacked\events";
}
public string GetLanguage()
{
@@ -390,7 +394,11 @@ namespace DSPRE
}
public string GetScriptFolderPath()
{
return workingFolder + @"extracted\scripts";
return workDir + @"unpacked\scripts";
}
internal string getSyntheticOverlayPath() {
return workDir + @"unpacked\syntheticOverlayNarc";
}