mirror of
https://github.com/AdAstra-LD/DS-Pokemon-Rom-Editor.git
synced 2026-10-02 06:47:55 -05:00
Fixed more DP commands
This commit is contained in:
22
DS_Map/HeaderSearch.Designer.cs
generated
22
DS_Map/HeaderSearch.Designer.cs
generated
@@ -27,7 +27,7 @@
|
||||
this.fieldToSearch1ComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.explanationLabel = new System.Windows.Forms.Label();
|
||||
this.operator1ComboBox = new System.Windows.Forms.ComboBox();
|
||||
this.value1TextBox = new System.Windows.Forms.TextBox();
|
||||
this.valueTextBox = new System.Windows.Forms.TextBox();
|
||||
this.startSearchButton = new System.Windows.Forms.Button();
|
||||
this.headerSearchResetButton = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
@@ -70,15 +70,15 @@
|
||||
this.operator1ComboBox.Size = new System.Drawing.Size(190, 24);
|
||||
this.operator1ComboBox.TabIndex = 8;
|
||||
//
|
||||
// value1TextBox
|
||||
// valueTextBox
|
||||
//
|
||||
this.value1TextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.value1TextBox.Location = new System.Drawing.Point(11, 108);
|
||||
this.value1TextBox.MaxLength = 16;
|
||||
this.value1TextBox.Name = "value1TextBox";
|
||||
this.value1TextBox.Size = new System.Drawing.Size(190, 22);
|
||||
this.value1TextBox.TabIndex = 9;
|
||||
this.value1TextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.value1TextBox_KeyDown);
|
||||
this.valueTextBox.Font = new System.Drawing.Font("Microsoft Sans Serif", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.valueTextBox.Location = new System.Drawing.Point(11, 108);
|
||||
this.valueTextBox.MaxLength = 16;
|
||||
this.valueTextBox.Name = "valueTextBox";
|
||||
this.valueTextBox.Size = new System.Drawing.Size(190, 22);
|
||||
this.valueTextBox.TabIndex = 9;
|
||||
this.valueTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.valueTextBox_KeyDown);
|
||||
//
|
||||
// startSearchButton
|
||||
//
|
||||
@@ -116,7 +116,7 @@
|
||||
this.ClientSize = new System.Drawing.Size(304, 145);
|
||||
this.Controls.Add(this.headerSearchResetButton);
|
||||
this.Controls.Add(this.startSearchButton);
|
||||
this.Controls.Add(this.value1TextBox);
|
||||
this.Controls.Add(this.valueTextBox);
|
||||
this.Controls.Add(this.operator1ComboBox);
|
||||
this.Controls.Add(this.explanationLabel);
|
||||
this.Controls.Add(this.fieldToSearch1ComboBox);
|
||||
@@ -136,7 +136,7 @@
|
||||
private System.Windows.Forms.ComboBox fieldToSearch1ComboBox;
|
||||
private System.Windows.Forms.Label explanationLabel;
|
||||
private System.Windows.Forms.ComboBox operator1ComboBox;
|
||||
private System.Windows.Forms.TextBox value1TextBox;
|
||||
private System.Windows.Forms.TextBox valueTextBox;
|
||||
private System.Windows.Forms.Button startSearchButton;
|
||||
private System.Windows.Forms.Button headerSearchResetButton;
|
||||
}
|
||||
|
||||
@@ -71,10 +71,10 @@ namespace DSPRE {
|
||||
|
||||
if (fieldToSearchComboBox.SelectedItem.ToString().Contains("ID")) {
|
||||
operatorComboBox.Items.AddRange(headerSearchNumericOperators);
|
||||
value1TextBox.MaxLength = 5;
|
||||
valueTextBox.MaxLength = 5;
|
||||
} else {
|
||||
operatorComboBox.Items.AddRange(headerSearchTextOperators);
|
||||
value1TextBox.MaxLength = 16;
|
||||
valueTextBox.MaxLength = 16;
|
||||
}
|
||||
|
||||
operatorComboBox.SelectedIndex = 0;
|
||||
@@ -167,22 +167,22 @@ namespace DSPRE {
|
||||
headerListBox.Items.Clear();
|
||||
List<string> result;
|
||||
|
||||
if (value1TextBox.Text == "") {
|
||||
if (valueTextBox.Text == "") {
|
||||
MessageBox.Show("Value to search is empty", "Can't search", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
result = advancedSearch(0, (short)intNames.Count, intNames, fieldToSearch1ComboBox.Text, operator1ComboBox.SelectedItem.ToString(), value1TextBox.Text);
|
||||
result = advancedSearch(0, (short)intNames.Count, intNames, fieldToSearch1ComboBox.Text, operator1ComboBox.SelectedItem.ToString(), valueTextBox.Text);
|
||||
} catch (FormatException) {
|
||||
MessageBox.Show("Make sure the value to search is correct.", "Format Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
value1TextBox.Clear();
|
||||
valueTextBox.Clear();
|
||||
headerListBox.Items.Add("Search parameters are invalid");
|
||||
headerListBox.Enabled = false;
|
||||
return;
|
||||
}
|
||||
|
||||
string searchConfiguration = fieldToSearch1ComboBox.Text + " " + operator1ComboBox.Text.ToLower() + " " + '"' + value1TextBox.Text + '"';
|
||||
string searchConfiguration = fieldToSearch1ComboBox.Text + " " + operator1ComboBox.Text.ToLower() + " " + '"' + valueTextBox.Text + '"';
|
||||
if (result == null || result.Count <= 0) {
|
||||
string res = "No header suits the search criteria.";
|
||||
headerListBox.Items.Add(res);
|
||||
@@ -197,13 +197,14 @@ namespace DSPRE {
|
||||
}
|
||||
Update();
|
||||
}
|
||||
private void value1TextBox_KeyDown(object sender, KeyEventArgs e) {
|
||||
private void valueTextBox_KeyDown(object sender, KeyEventArgs e) {
|
||||
if (e.KeyCode == Keys.Enter) {
|
||||
startSearchButton_Click(null, null);
|
||||
}
|
||||
}
|
||||
private void headerSearchResetButton_Click(object sender, EventArgs e) {
|
||||
HeaderSearchReset(headerListBox, intNames);
|
||||
valueTextBox.Clear();
|
||||
statusLabel.Text = "Ready";
|
||||
}
|
||||
public static void HeaderSearchReset(ListBox headerListBox, List<string> intNames) {
|
||||
|
||||
@@ -1434,7 +1434,7 @@ namespace DSPRE {
|
||||
[0x01DE] = new byte[] { 2, 2, 2, 2 },
|
||||
[0x01DF] = new byte[] { 2 },
|
||||
[0x01E0] = new byte[] { 2 },
|
||||
[0x01E1] = new byte[] { 2, 2, 2 },
|
||||
|
||||
[0x01E2] = new byte[] { 2, 2 },
|
||||
[0x01E3] = new byte[] { 2, 2 },
|
||||
[0x01E4] = new byte[] { 2 },
|
||||
@@ -1660,7 +1660,7 @@ namespace DSPRE {
|
||||
[0x02C0] = new byte[] { 2 },
|
||||
[0x02C1] = new byte[1] { 0 },
|
||||
[0x02C2] = new byte[1] { 0 },
|
||||
[0x02C3] = new byte[1] { 0 },
|
||||
[0x02C3] = new byte[1] { 1 },
|
||||
[0x02C4] = new byte[] { 1 },
|
||||
[0x02C5] = new byte[] { 1, 2 },
|
||||
[0x02C6] = new byte[] { 1, 2 },
|
||||
@@ -1803,6 +1803,8 @@ namespace DSPRE {
|
||||
public static Dictionary<ushort, byte[]> DPScrCmdParameters = new Dictionary<ushort, byte[]>() {
|
||||
[0x011D] = new byte[] { 1, 1, 2},
|
||||
|
||||
[0x01E1] = new byte[] { 2, 2},
|
||||
|
||||
[0x02C4] = new byte[] { 1, 2 },
|
||||
[0x02C5] = new byte[] { 1, 2 },
|
||||
[0x02C6] = new byte[] { 1, 2 },
|
||||
@@ -1833,6 +1835,8 @@ namespace DSPRE {
|
||||
public static Dictionary<ushort, byte[]> PlatScrCmdParameters = new Dictionary<ushort, byte[]>() {
|
||||
[0x011D] = new byte[] { 1, 1, 2, 2 },
|
||||
|
||||
[0x01E1] = new byte[] { 2, 2, 2 },
|
||||
|
||||
[0x02C4] = new byte[] { 1 },
|
||||
[0x02C5] = new byte[] { 1, 2 },
|
||||
[0x02C6] = new byte[] { 1, 2 },
|
||||
|
||||
@@ -64,16 +64,16 @@ namespace DSPRE {
|
||||
bool endScript = new bool();
|
||||
while (!endScript) {
|
||||
ScriptCommand command = ReadCommand(scrReader, ref functionOffsets, ref movementOffsets);
|
||||
if (command == null) {
|
||||
if (command.parameterList == null)
|
||||
return;
|
||||
} else {
|
||||
commandsList.Add(command);
|
||||
|
||||
commandsList.Add(command);
|
||||
|
||||
if (endCodes.Contains(command.id))
|
||||
endScript = true;
|
||||
}
|
||||
if (endCodes.Contains(command.id))
|
||||
endScript = true;
|
||||
|
||||
}
|
||||
this.scripts.Add(new Script(commandList: commandsList));
|
||||
scripts.Add(new Script(commandList: commandsList));
|
||||
} else {
|
||||
scripts.Add(new Script(useScript: duplicateIndex));
|
||||
}
|
||||
@@ -87,6 +87,9 @@ namespace DSPRE {
|
||||
bool endFunction = new bool();
|
||||
while (!endFunction) {
|
||||
ScriptCommand command = ReadCommand(scrReader, ref functionOffsets, ref movementOffsets);
|
||||
if (command.parameterList == null)
|
||||
return;
|
||||
|
||||
cmdList.Add(command);
|
||||
if (endCodes.Contains(command.id))
|
||||
endFunction = true;
|
||||
@@ -180,27 +183,23 @@ namespace DSPRE {
|
||||
break;
|
||||
case 0x21D:
|
||||
{
|
||||
if (RomInfo.gameVersion == "Plat") {
|
||||
byte parameter1 = dataReader.ReadByte();
|
||||
parameterList.Add(new byte[] { parameter1 });
|
||||
ushort parameter1 = dataReader.ReadUInt16();
|
||||
parameterList.Add(BitConverter.GetBytes( parameter1 ));
|
||||
|
||||
switch (parameter1) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
parameterList.Add(dataReader.ReadBytes(2));
|
||||
parameterList.Add(dataReader.ReadBytes(2));
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
parameterList.Add(dataReader.ReadBytes(2));
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
goto default;
|
||||
switch (parameter1) {
|
||||
case 0:
|
||||
case 1:
|
||||
case 2:
|
||||
case 3:
|
||||
parameterList.Add(dataReader.ReadBytes(2));
|
||||
parameterList.Add(dataReader.ReadBytes(2));
|
||||
break;
|
||||
case 4:
|
||||
case 5:
|
||||
parameterList.Add(dataReader.ReadBytes(2));
|
||||
break;
|
||||
case 6:
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -284,7 +283,7 @@ namespace DSPRE {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
addParametersToList(parameterList, id, dataReader);
|
||||
addParametersToList(ref parameterList, id, dataReader);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -385,14 +384,14 @@ namespace DSPRE {
|
||||
}
|
||||
break;
|
||||
default:
|
||||
addParametersToList(parameterList, id, dataReader);
|
||||
addParametersToList(ref parameterList, id, dataReader);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return new ScriptCommand(id, parameterList);
|
||||
}
|
||||
private void addParametersToList(List<byte[]> parameterList, ushort id, BinaryReader dataReader) {
|
||||
private void addParametersToList(ref List<byte[]> parameterList, ushort id, BinaryReader dataReader) {
|
||||
Console.WriteLine("Loaded command id: " + id.ToString("X4"));
|
||||
try {
|
||||
foreach (int bytesToRead in RomInfo.scriptParametersDict[id])
|
||||
@@ -401,10 +400,12 @@ namespace DSPRE {
|
||||
MessageBox.Show("Script command " + id + "can't be handled for now." +
|
||||
Environment.NewLine + "Reference offset 0x" + dataReader.BaseStream.Position.ToString("X"), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
parameterList = null;
|
||||
return;
|
||||
} catch {
|
||||
MessageBox.Show("Error: ID Read - " + id +
|
||||
Environment.NewLine + "Reference offset 0x" + dataReader.BaseStream.Position.ToString("X"), "Unrecognized script command", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
parameterList = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
public byte[] ToByteArray() {
|
||||
|
||||
Reference in New Issue
Block a user