Misc bugfixing and code restyling

Fixed more errors and exceptions,
moved ARM9 expansion code to a resx resource,
improved ui design of event editor
This commit is contained in:
AdAstra-LD
2021-01-12 05:22:28 +01:00
parent 2f673a2d8c
commit 1917f6ea32
9 changed files with 1166 additions and 729 deletions

View File

@@ -91,6 +91,11 @@
<ItemGroup>
<Compile Include="AB.cs" />
<Compile Include="AreaData.cs" />
<Compile Include="Resources\ROMToolboxDB\ARM9ExpansionDB.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>ARM9ExpansionDB.resx</DependentUpon>
</Compile>
<Compile Include="ROMToolboxDialog.cs">
<SubType>Form</SubType>
</Compile>
@@ -231,6 +236,10 @@
<Compile Include="SPK.Designer.cs">
<DependentUpon>SPK.cs</DependentUpon>
</Compile>
<EmbeddedResource Include="Resources\ROMToolboxDB\ARM9ExpansionDB.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>ARM9ExpansionDB.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="ROMToolboxDialog.resx">
<DependentUpon>ROMToolboxDialog.cs</DependentUpon>
</EmbeddedResource>

View File

@@ -1,4 +1,5 @@
using System.IO;
using System.Windows.Forms;
namespace DSPRE
{
@@ -312,23 +313,27 @@ namespace DSPRE
{
using (BinaryReader reader = new BinaryReader(data))
{
wildPok<EFBFBD>mon = reader.ReadByte();
areaDataID = reader.ReadByte();
unknown1 = reader.ReadByte();
unknown2 = reader.ReadByte();
matrix = reader.ReadUInt16();
script = reader.ReadUInt16();
levelScript = reader.ReadUInt16();
text = reader.ReadUInt16();
musicDay = reader.ReadUInt16();
musicNight = reader.ReadUInt16();
events = reader.ReadUInt16();
mapName = reader.ReadByte();
areaIcon = StandardizeAreaIcon(reader.ReadByte());
weather = StandardizeWeather(reader.ReadByte());
camera = reader.ReadByte();
followMode = reader.ReadByte();
flags = reader.ReadByte();
try {
wildPok<EFBFBD>mon = reader.ReadByte();
areaDataID = reader.ReadByte();
unknown1 = reader.ReadByte();
unknown2 = reader.ReadByte();
matrix = reader.ReadUInt16();
script = reader.ReadUInt16();
levelScript = reader.ReadUInt16();
text = reader.ReadUInt16();
musicDay = reader.ReadUInt16();
musicNight = reader.ReadUInt16();
events = reader.ReadUInt16();
mapName = reader.ReadByte();
areaIcon = StandardizeAreaIcon(reader.ReadByte());
weather = StandardizeWeather(reader.ReadByte());
camera = reader.ReadByte();
followMode = reader.ReadByte();
flags = reader.ReadByte();
} catch (EndOfStreamException) {
MessageBox.Show("Error loading headers.\n", "Unexpected EOF", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
#endregion<EFBFBD>Constructors

File diff suppressed because it is too large Load Diff

View File

@@ -59,9 +59,8 @@ namespace DSPRE {
unpack.WaitForExit();
}
private void DecompressArm9() {
if (new FileInfo(workDir + @"arm9.bin").Length < 0xC0000)
{
private bool DecompressArm9() {
if (new FileInfo(workDir + @"arm9.bin").Length < 0xBC000) {
BinaryWriter arm9Truncate = new BinaryWriter(File.OpenWrite(workDir + @"arm9.bin"));
long arm9Length = new FileInfo(workDir + @"arm9.bin").Length;
arm9Truncate.BaseStream.SetLength(arm9Length - 0xc);
@@ -75,6 +74,7 @@ namespace DSPRE {
decompress.StartInfo.CreateNoWindow = true;
decompress.Start();
decompress.WaitForExit();
return (new FileInfo(workDir + @"arm9.bin").Length > 1122000);
}
private void decompressOverlay(int overlayNumber, bool makeBackup) {
@@ -346,7 +346,7 @@ namespace DSPRE {
break;
default:
overworldTablePath = "overlay" + "\\" + "overlay_0001.bin";
decompressOverlay(1, true); // HGSS Overlay 1 must be uncompressed to be able to read the overworld table
decompressOverlay(1, true); // HGSS Overlay 1 must be uncompressed in order to read the overworld table
break;
}
@@ -1064,12 +1064,14 @@ namespace DSPRE {
using (ROMToolboxDialog window = new ROMToolboxDialog(romInfo))
{
window.ShowDialog();
if (window.standardizedItems) isItemRadioButton.Enabled = true;
if (window.standardizedItems)
isItemRadioButton.Enabled = true;
}
}
private void buildingEditorButton_Click(object sender, EventArgs e)
{
using (BuildingEditor editor = new BuildingEditor(romInfo)) editor.ShowDialog();
using (BuildingEditor editor = new BuildingEditor(romInfo))
editor.ShowDialog();
}
private void aboutToolStripMenuItem1_Click(object sender, EventArgs e)
{
@@ -1099,13 +1101,18 @@ namespace DSPRE {
/* Set ROM gameVersion and language */
romInfo = new RomInfo(gameCode, workDir);
gameVersion = romInfo.getGameVersion();
if (gameVersion == null) {
statusLabel.Text = "Ready";
return;
}
versionLabel.Text = "ROM: Pokémon " + gameVersion;
languageLabel.Text = "Language: " + romInfo.GetLanguage();
iconON = true;
languageLabel.Text = "Language: " + romInfo.getGameLanguage();
iconON = true;
gameIcon.Refresh(); // Paint game icon
statusLabel.Text = "Unpacking NARCs...";
Update();
/* Extract NARCs sub-archives*/
switch (gameVersion)
{
@@ -1118,10 +1125,16 @@ namespace DSPRE {
break;
default:
UnpackNARCsHeartGoldSoulSilver();
DecompressArm9();
if (!DecompressArm9()) {
MessageBox.Show("ARM9 decompression failed. The program can't proceed.\nAborting.",
"Errror with ARM9 decompression", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
break;
}
statusLabel.Text = "Setting up editors...";
Update();
/* Setup editors */
SetupFlagNames();
SetupHeaderEditor();
@@ -1139,6 +1152,7 @@ namespace DSPRE {
wildEditorButton.Enabled = true;
loadRomButton.Enabled = false;
openROMToolStripMenuItem.Enabled = false;
statusLabel.Text = "Ready";
}
@@ -1508,41 +1522,38 @@ namespace DSPRE {
}
private void openEventsButton_Click(object sender, EventArgs e)
{
if (matrixUpDown.Value != 0) eventAreaDataUpDown.Value = areaDataUpDown.Value; // Use Area Data for textures if matrix is not 0
eventMatrixUpDown.Value = matrixUpDown.Value; // Open the right matrix in event editor
selectEventComboBox.SelectedIndex = (int)eventFileUpDown.Value; // Select event file
disableHandlers = true;
if (currentEventFile.overworlds.Count > 0)
{
eventMatrixXUpDown.Value = currentEventFile.overworlds[0].xMatrixPosition;
eventMatrixYUpDown.Value = currentEventFile.overworlds[0].yMatrixPosition;
}
else if (currentEventFile.warps.Count > 0)
{
eventMatrixXUpDown.Value = currentEventFile.warps[0].xMatrixPosition;
eventMatrixYUpDown.Value = currentEventFile.warps[0].yMatrixPosition;
}
else if (currentEventFile.spawnables.Count > 0)
{
eventMatrixXUpDown.Value = currentEventFile.spawnables[0].xMatrixPosition;
eventMatrixYUpDown.Value = currentEventFile.spawnables[0].yMatrixPosition;
}
else if (currentEventFile.triggers.Count > 0)
{
eventMatrixXUpDown.Value = currentEventFile.triggers[0].xMatrixPosition;
eventMatrixYUpDown.Value = currentEventFile.triggers[0].yMatrixPosition;
}
else
{
eventMatrixXUpDown.Value = 0;
eventMatrixYUpDown.Value = 0;
}
if (matrixUpDown.Value != 0)
eventAreaDataUpDown.Value = areaDataUpDown.Value; // Use Area Data for textures if matrix is not 0
openEvents();
disableHandlers = false;
eventMatrixXUpDown_ValueChanged(null, null);
mainTabControl.SelectedTab = eventEditorTabPage;
}
private void openEvents() {
eventMatrixUpDown.Value = matrixUpDown.Value; // Open the right matrix in event editor
selectEventComboBox.SelectedIndex = (int)eventFileUpDown.Value; // Select event file
disableHandlers = true;
if (currentEventFile.overworlds.Count > 0) {
eventMatrixXUpDown.Value = currentEventFile.overworlds[0].xMatrixPosition;
eventMatrixYUpDown.Value = currentEventFile.overworlds[0].yMatrixPosition;
} else if (currentEventFile.warps.Count > 0) {
eventMatrixXUpDown.Value = currentEventFile.warps[0].xMatrixPosition;
eventMatrixYUpDown.Value = currentEventFile.warps[0].yMatrixPosition;
} else if (currentEventFile.spawnables.Count > 0) {
eventMatrixXUpDown.Value = currentEventFile.spawnables[0].xMatrixPosition;
eventMatrixYUpDown.Value = currentEventFile.spawnables[0].yMatrixPosition;
} else if (currentEventFile.triggers.Count > 0) {
eventMatrixXUpDown.Value = currentEventFile.triggers[0].xMatrixPosition;
eventMatrixYUpDown.Value = currentEventFile.triggers[0].yMatrixPosition;
} else {
eventMatrixXUpDown.Value = 0;
eventMatrixYUpDown.Value = 0;
}
}
private void openMatrixButton_Click(object sender, EventArgs e)
{
int matrixNumber = (int)matrixUpDown.Value;
@@ -3782,12 +3793,17 @@ namespace DSPRE {
eventMatrixXUpDown.Value = selectedEvent.xMatrixPosition;
eventMatrixYUpDown.Value = selectedEvent.yMatrixPosition;
}
private void destinationWarpGoToButton_Click(object sender, EventArgs e) {
selectEventComboBox.SelectedIndex = LoadHeader((int)warpHeaderUpDown.Value).events;
openEvents();
}
private void importEventFileButton_Click(object sender, EventArgs e)
{
/* Prompt user to select .evt file */
OpenFileDialog of = new OpenFileDialog();
of.Filter = "Event File (*.evt)|*.evt";
if (of.ShowDialog(this) != DialogResult.OK) return;
if (of.ShowDialog(this) != DialogResult.OK)
return;
/* Update matrix object in memory */
string path = romInfo.GetEventFolderPath() + "\\" + selectEventComboBox.SelectedIndex.ToString("D4");
@@ -3893,40 +3909,46 @@ namespace DSPRE {
}
private void signMatrixXUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers || spawnablesListBox.SelectedIndex == null)
return;
currentEventFile.spawnables[spawnablesListBox.SelectedIndex].xMatrixPosition = (ushort)signMatrixXUpDown.Value;
DisplayActiveEvents();
}
private void signMatrixYUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers || spawnablesListBox.SelectedIndex == null)
return;
currentEventFile.spawnables[spawnablesListBox.SelectedIndex].yMatrixPosition = (ushort)signMatrixYUpDown.Value;
DisplayActiveEvents();
}
private void signScriptUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers || spawnablesListBox.SelectedIndex == null)
return;
currentEventFile.spawnables[spawnablesListBox.SelectedIndex].scriptNumber = (ushort)signScriptUpDown.Value;
}
private void signMapXUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers || spawnablesListBox.SelectedIndex == null)
return;
currentEventFile.spawnables[spawnablesListBox.SelectedIndex].xMapPosition = (short)signMapXUpDown.Value;
DisplayActiveEvents();
}
private void signMapYUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers)
return;
currentEventFile.spawnables[spawnablesListBox.SelectedIndex].yMapPosition = (short)signMapYUpDown.Value;
DisplayActiveEvents();
}
private void signZUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers)
return;
currentEventFile.spawnables[spawnablesListBox.SelectedIndex].zPosition = (short)signZUpDown.Value;
DisplayActiveEvents();
@@ -3942,7 +3964,8 @@ namespace DSPRE {
}
private void isTrainerRadioButton_CheckedChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers)
return;
/* Disable script number control */
owScriptNumericUpDown.Enabled = false;
@@ -3964,11 +3987,13 @@ namespace DSPRE {
currentEventFile.overworlds[overworldsListBox.SelectedIndex].type = 0x1;
/* Adjust script number */
if (owTrainerComboBox.SelectedIndex >= 0) owTrainerComboBox_SelectedIndexChanged(null, null);
if (owTrainerComboBox.SelectedIndex >= 0)
owTrainerComboBox_SelectedIndexChanged(null, null);
}
private void isItemRadioButton_CheckedChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers)
return;
/* Disable script number control */
owScriptNumericUpDown.Enabled = false;
@@ -3996,7 +4021,8 @@ namespace DSPRE {
}
private void normalRadioButton_CheckedChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers)
return;
/* Enable script number control buttons */
owScriptNumericUpDown.Enabled = true;
@@ -4082,27 +4108,28 @@ namespace DSPRE {
}
private void owFlagNumericUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers)
if (disableHandlers || overworldsListBox.SelectedIndex == null)
return;
currentEventFile.overworlds[overworldsListBox.SelectedIndex].flag = (ushort)owFlagNumericUpDown.Value;
}
private void owIDNumericUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers)
if (disableHandlers || overworldsListBox.SelectedIndex == null)
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)
if (disableHandlers || overworldsListBox.SelectedIndex == null)
return;
currentEventFile.overworlds[overworldsListBox.SelectedIndex].movement = (ushort)owMovementComboBox.SelectedIndex;
}
private void owOrientationComboBox_SelectedIndexChanged(object sender, EventArgs e)
{
if (disableHandlers)
if (disableHandlers || overworldsListBox.SelectedIndex == null)
return;
currentEventFile.overworlds[overworldsListBox.SelectedIndex].orientation = (ushort)owOrientationComboBox.SelectedIndex;
owSpritePictureBox.BackgroundImage = GetOverworldImage(currentEventFile.overworlds[overworldsListBox.SelectedIndex].spriteID, currentEventFile.overworlds[overworldsListBox.SelectedIndex].orientation);
DisplayActiveEvents();
@@ -4110,13 +4137,13 @@ namespace DSPRE {
}
private void owScriptNumericUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers)
if (disableHandlers || overworldsListBox.SelectedIndex == null)
return;
currentEventFile.overworlds[overworldsListBox.SelectedIndex].scriptNumber = (ushort)owScriptNumericUpDown.Value;
}
private void owSightRangeUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers)
if (disableHandlers || overworldsListBox.SelectedIndex == null)
return;
currentEventFile.overworlds[overworldsListBox.SelectedIndex].sightRange = (ushort)owSightRangeUpDown.Value;
}
@@ -4124,7 +4151,7 @@ namespace DSPRE {
{
if (disableHandlers)
return;
if (currentEventFile.overworlds.Count != 0) {
if (overworldsListBox.SelectedIndex != 0) {
currentEventFile.overworlds[overworldsListBox.SelectedIndex].spriteID = (ushort)owSpriteComboBox.SelectedIndex;
owSpritePictureBox.BackgroundImage = GetOverworldImage(currentEventFile.overworlds[overworldsListBox.SelectedIndex].spriteID, currentEventFile.overworlds[overworldsListBox.SelectedIndex].orientation);
DisplayActiveEvents();
@@ -4288,7 +4315,8 @@ namespace DSPRE {
}
private void warpXMapUpDown_ValueChanged(object sender, EventArgs e)
{
if (disableHandlers) return;
if (disableHandlers || warpsListBox.SelectedIndex != null)
return;
currentEventFile.warps[warpsListBox.SelectedIndex].xMapPosition = (short)warpXMapUpDown.Value;
DisplayActiveEvents();
@@ -5507,5 +5535,7 @@ namespace DSPRE {
#endregion
}
}

View File

@@ -117,6 +117,12 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="unsupport3DText.Text" xml:space="preserve">
<value>Editing 3D models is not supported by this program.
They must be modeled in a 3D editor like Sketchup
or Blender, or (recommended option) they can be created
with 'Pokemon DS Map Studio' by Trifindo.</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>
@@ -416,7 +422,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACA
DwAAAk1TRnQBSQFMAgEBBwEAAXwBAgF8AQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
DwAAAk1TRnQBSQFMAgEBBwEAAcwBAgHMAQIBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo
AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA
AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5
AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA

View File

@@ -1,6 +1,8 @@
using NarcAPI;
using System;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Windows.Forms;
namespace DSPRE
@@ -33,10 +35,10 @@ namespace DSPRE
}
private void applyARM9ExpansionButton_Click(object sender, EventArgs e) {
String version = rom.getGameVersion();
String lang = rom.GetLanguage();
String arm9path = rom.getWorkingFolder() + @"arm9.bin";
arm9Expansion(rom.getWorkingFolder() + @"arm9.bin", rom.getGameVersion(), rom.getGameLanguage());
}
private void arm9Expansion(string arm9path, string version, string lang) {
long initOffset;
String initString;
@@ -45,26 +47,21 @@ namespace DSPRE
int fileID = -1;
ResourceManager arm9DB = new ResourceManager("DSPRE.Resources.ROMToolboxDB.ARM9ExpansionDB", Assembly.GetExecutingAssembly());
fileID = Int16.Parse(arm9DB.GetString("fileID" + version));
switch (version) {
case "Diamond":
case "Pearl":
fileID = 9;
initString = arm9DB.GetString("initString" + "Diamond");
branchCodeString = arm9DB.GetString("branchCode" + "Diamond" + lang);
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();
@@ -72,32 +69,15 @@ namespace DSPRE
}
break;
case "Platinum":
fileID = 9;
initString = arm9DB.GetString("initString" + version + lang);
branchCodeString = arm9DB.GetString("branchCode" + version + lang);
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();
@@ -106,23 +86,15 @@ namespace DSPRE
break;
case "HeartGold":
case "SoulSilver":
fileID = 0;
initString = arm9DB.GetString("initString" + "HeartGold");
branchCodeString = arm9DB.GetString("branchCode" + "HeartGold" + lang);
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();
@@ -139,15 +111,15 @@ namespace DSPRE
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" +
"- 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);
MessageBox.Show("Operation successful.", "Process completed.", 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);
@@ -257,7 +229,7 @@ namespace DSPRE
}
private void unsupportedROMLanguage() {
MessageBox.Show("This operation is currently impossible to carry out on the " + rom.GetLanguage() +
MessageBox.Show("This operation is currently impossible to carry out on the " + rom.getGameLanguage() +
" version of this ROM.", "Unsupported language", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}

View File

@@ -0,0 +1,198 @@
//------------------------------------------------------------------------------
// <auto-generated>
// Il codice è stato generato da uno strumento.
// Versione runtime:4.0.30319.42000
//
// Le modifiche apportate a questo file possono provocare un comportamento non corretto e andranno perse se
// il codice viene rigenerato.
// </auto-generated>
//------------------------------------------------------------------------------
namespace DSPRE.Resources.ROMToolboxDB {
using System;
/// <summary>
/// Classe di risorse fortemente tipizzata per la ricerca di stringhe localizzate e così via.
/// </summary>
// Questa classe è stata generata automaticamente dalla classe StronglyTypedResourceBuilder.
// tramite uno strumento quale ResGen o Visual Studio.
// Per aggiungere o rimuovere un membro, modificare il file con estensione ResX ed eseguire nuovamente ResGen
// con l'opzione /str oppure ricompilare il progetto VS.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "16.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class ARM9ExpansionDB {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal ARM9ExpansionDB() {
}
/// <summary>
/// Restituisce l'istanza di ResourceManager nella cache utilizzata da questa classe.
/// </summary>
[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("DSPRE.Resources.ROMToolboxDB.ARM9ExpansionDB", typeof(ARM9ExpansionDB).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Esegue l'override della proprietà CurrentUICulture del thread corrente per tutte le
/// ricerche di risorse eseguite utilizzando questa classe di risorse fortemente tipizzata.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 05 F1 04 FD.
/// </summary>
internal static string branchCodeDiamondESP {
get {
return ResourceManager.GetString("branchCodeDiamondESP", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 05 F1 34 FC.
/// </summary>
internal static string branchCodeDiamondUSA {
get {
return ResourceManager.GetString("branchCodeDiamondUSA", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 0F F1 40 FB.
/// </summary>
internal static string branchCodeHeartGoldESP {
get {
return ResourceManager.GetString("branchCodeHeartGoldESP", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 0F F1 30 FB.
/// </summary>
internal static string branchCodeHeartGoldUSA {
get {
return ResourceManager.GetString("branchCodeHeartGoldUSA", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 00 F1 B2 F9.
/// </summary>
internal static string branchCodePlatinumESP {
get {
return ResourceManager.GetString("branchCodePlatinumESP", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 00 F1 B4 F8.
/// </summary>
internal static string branchCodePlatinumUSA {
get {
return ResourceManager.GetString("branchCodePlatinumUSA", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 9.
/// </summary>
internal static string fileIDDiamond {
get {
return ResourceManager.GetString("fileIDDiamond", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 0.
/// </summary>
internal static string fileIDHeartGold {
get {
return ResourceManager.GetString("fileIDHeartGold", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 9.
/// </summary>
internal static string fileIDPearl {
get {
return ResourceManager.GetString("fileIDPearl", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 9.
/// </summary>
internal static string fileIDPlatinum {
get {
return ResourceManager.GetString("fileIDPlatinum", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 0.
/// </summary>
internal static string fileIDSoulSilver {
get {
return ResourceManager.GetString("fileIDSoulSilver", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 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.
/// </summary>
internal static string initStringDiamond {
get {
return ResourceManager.GetString("initStringDiamond", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 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.
/// </summary>
internal static string initStringHeartGold {
get {
return ResourceManager.GetString("initStringHeartGold", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 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.
/// </summary>
internal static string initStringPlatinumESP {
get {
return ResourceManager.GetString("initStringPlatinumESP", resourceCulture);
}
}
/// <summary>
/// Cerca una stringa localizzata simile a 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.
/// </summary>
internal static string initStringPlatinumUSA {
get {
return ResourceManager.GetString("initStringPlatinumUSA", resourceCulture);
}
}
}
}

View File

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

View File

@@ -1,25 +1,25 @@
using System.IO;
using System.Collections.Generic;
using System;
using System.Windows;
using System.Windows.Forms;
namespace DSPRE
{
namespace DSPRE {
/// <summary>
/// Class to store ROM data from GEN IV Pok<6F>mon games
/// </summary>
public class RomInfo
{
public class RomInfo {
private string romID;
private string workDir;
private string gameVersion;
private string language;
#region Constructors (1)
public RomInfo(string id, string workDir)
{
public RomInfo(string id, string workDir) {
romID = id;
gameVersion = getGameVersion();
gameVersion = loadGameVersion();
language = loadGameLanguage();
this.workDir = workDir;
}
#endregion
@@ -28,41 +28,34 @@ namespace DSPRE
public string getWorkingFolder() {
return workDir;
}
public string GetAreaDataFolderPath()
{
public string GetAreaDataFolderPath() {
return workDir + @"unpacked\area_data";
}
public int GetAreaDataCount()
{
public int GetAreaDataCount() {
return Directory.GetFiles(GetAreaDataFolderPath()).Length; ;
}
public string GetBuildingModelsFolderPath(bool interior)
{
public string GetBuildingModelsFolderPath(bool interior) {
string path;
switch (gameVersion)
{
switch (gameVersion) {
case "Diamond":
case "Pearl":
case "Platinum":
path = @"unpacked\DPPtBuildings";
break;
default:
if (interior)
if (interior)
path = @"unpacked\HGSSBuildingsIN";
else
else
path = @"unpacked\HGSSBuildingsOUT";
break;
}
return workDir + path;
}
public int GetBuildingCount(bool interior)
{
public int GetBuildingCount(bool interior) {
return Directory.GetFiles(GetBuildingModelsFolderPath(interior)).Length;
}
public int GetHeaderTableOffset()
{
Dictionary<string, int> offsets = new Dictionary<string, int>()
{
public int GetHeaderTableOffset() {
Dictionary<string, int> offsets = new Dictionary<string, int>() {
["ADAE"] = 0xEEDBC,
["ADAS"] = 0xEEE08,
["ADAI"] = 0xEED70,
@@ -96,15 +89,12 @@ namespace DSPRE
};
return offsets[this.romID];
}
public int GetHeaderCount()
{
public int GetHeaderCount() {
return (int)new FileInfo(workDir + @"data\fielddata\maptable\mapname.bin").Length / 0x10;
}
public int GetAttackNamesMessageNumber()
{
public int GetAttackNamesMessageNumber() {
int fileNumber;
switch (gameVersion)
{
switch (gameVersion) {
case "Diamond":
case "Pearl":
fileNumber = 588;
@@ -113,19 +103,17 @@ namespace DSPRE
fileNumber = 647;
break;
default:
if (GetLanguage() == "JAP")
if (getGameLanguage() == "JAP")
fileNumber = 739;
else
else
fileNumber = 750;
break;
}
return fileNumber;
}
public int GetItemNamesMessageNumber()
{
public int GetItemNamesMessageNumber() {
int fileNumber;
switch (gameVersion)
{
switch (gameVersion) {
case "Diamond":
case "Pearl":
fileNumber = 344;
@@ -134,17 +122,15 @@ namespace DSPRE
fileNumber = 392;
break;
default:
if (GetLanguage() == "JAP") fileNumber = 219;
if (getGameLanguage() == "JAP") fileNumber = 219;
else fileNumber = 222;
break;
}
return fileNumber;
}
public int GetMapNamesMessageNumber()
{
public int GetMapNamesMessageNumber() {
int fileNumber;
switch (gameVersion)
{
switch (gameVersion) {
case "Diamond":
case "Pearl":
fileNumber = 382;
@@ -153,17 +139,15 @@ namespace DSPRE
fileNumber = 433;
break;
default:
if (GetLanguage() == "JAP") fileNumber = 272;
if (getGameLanguage() == "JAP") fileNumber = 272;
else fileNumber = 279;
break;
}
return fileNumber;
}
public int GetItemScriptFileNumber()
{
public int GetItemScriptFileNumber() {
int fileNumber;
switch (gameVersion)
{
switch (gameVersion) {
case "Diamond":
case "Pearl":
fileNumber = 370;
@@ -177,11 +161,9 @@ namespace DSPRE
}
return fileNumber;
}
public int GetPok<EFBFBD>monNamesMessageNumber()
{
public int GetPok<EFBFBD>monNamesMessageNumber() {
int fileNumber;
switch (gameVersion)
{
switch (gameVersion) {
case "Diamond":
case "Pearl":
fileNumber = 362;
@@ -190,19 +172,17 @@ namespace DSPRE
fileNumber = 412;
break;
default:
if (GetLanguage() == "JAP")
if (getGameLanguage() == "JAP")
fileNumber = 232;
else
else
fileNumber = 237;
break;
}
return fileNumber;
}
public int GetTrainerNamesMessageNumber()
{
public int GetTrainerNamesMessageNumber() {
int fileNumber;
switch (gameVersion)
{
switch (gameVersion) {
case "Diamond":
case "Pearl":
fileNumber = 559;
@@ -211,19 +191,17 @@ namespace DSPRE
fileNumber = 618;
break;
default:
if (GetLanguage() == "JAP")
if (getGameLanguage() == "JAP")
fileNumber = 719;
else
else
fileNumber = 729;
break;
}
return fileNumber;
}
public int GetTrainerClassMessageNumber()
{
public int GetTrainerClassMessageNumber() {
int fileNumber;
switch (gameVersion)
{
switch (gameVersion) {
case "Diamond":
case "Pearl":
fileNumber = 560;
@@ -232,78 +210,64 @@ namespace DSPRE
fileNumber = 619;
break;
default:
if (GetLanguage() == "JAP")
if (getGameLanguage() == "JAP")
fileNumber = 720;
else
else
fileNumber = 730;
break;
}
return fileNumber;
}
public string GetMapTexturesFolderPath()
{
public string GetMapTexturesFolderPath() {
return workDir + @"unpacked\maptex";
}
public int GetMapTexturesCount()
{
public int GetMapTexturesCount() {
return Directory.GetFiles(GetMapTexturesFolderPath()).Length;
}
public string GetBuildingTexturesFolderPath() {
public string GetBuildingTexturesFolderPath() {
return workDir + @"unpacked\TextureBLD";
}
public int GetBuildingTexturesCount()
{
public int GetBuildingTexturesCount() {
return Directory.GetFiles(GetBuildingTexturesFolderPath()).Length;
}
public string GetMatrixFolderPath() {
public string GetMatrixFolderPath() {
return workDir + @"unpacked\matrix";
}
public int GetMatrixCount()
{
public int GetMatrixCount() {
return Directory.GetFiles(GetMatrixFolderPath()).Length;
}
public string GetTextArchivesPath()
{
public string GetTextArchivesPath() {
return workDir + @"unpacked\msg";
}
public int GetMessageCount()
{
public int GetMessageCount() {
return Directory.GetFiles(GetTextArchivesPath()).Length;
}
public string GetTrainerDataFolderPath()
{
public string GetTrainerDataFolderPath() {
return workDir + @"unpacked\trainerdata";
}
public string GetMapFolderPath()
{
public string GetMapFolderPath() {
return workDir + @"unpacked\maps";
}
public int GetMapCount()
{
public int GetMapCount() {
return Directory.GetFiles(GetMapFolderPath()).Length;
}
public string GetOverworldFolderPath()
{
public string GetOverworldFolderPath() {
return workDir + @"unpacked\overworlds";
}
public string GetEncounterFolderPath()
{
public string GetEncounterFolderPath() {
return workDir + @"unpacked\wildPokeData";
}
public int GetEventCount()
{
public int GetEventCount() {
return Directory.GetFiles(GetEventFolderPath()).Length;
}
public string GetEventFolderPath()
{
public string GetEventFolderPath() {
return workDir + @"unpacked\events";
}
public string GetLanguage()
{
public string loadGameLanguage() {
string language;
switch (romID)
{
switch (romID) {
case "ADAE":
case "APAE":
case "CPUE":
@@ -348,11 +312,18 @@ namespace DSPRE
default:
language = "JAP";
break;
}
}
return language;
}
public string getGameVersion()
{
public string getGameLanguage() {
return this.language;
}
public string getGameVersion() {
return gameVersion;
}
public string loadGameVersion() {
Dictionary<string, string> versions = new Dictionary<string, string>() {
["ADAE"] = "Diamond",
["ADAS"] = "Diamond",
@@ -386,14 +357,18 @@ namespace DSPRE
["IPGJ"] = "SoulSilver",
["LATA"] = "LATA",
};
return versions[this.romID];
try {
return versions[this.romID];
} catch (KeyNotFoundException) {
System.Windows.Forms.MessageBox.Show("The ROM you attempted to load is not supported.\nYou can only load Gen IV Pok<6F>mon ROMS, for now.", "Unsupported ROM",
MessageBoxButtons.OK, MessageBoxIcon.Error);
return null;
}
}
public int GetScriptCount()
{
public int GetScriptCount() {
return Directory.GetFiles(GetScriptFolderPath()).Length;
}
public string GetScriptFolderPath()
{
public string GetScriptFolderPath() {
return workDir + @"unpacked\scripts";
}