Skip to content

Commit d6cc476

Browse files
committed
Add ROM version verification, patching, and Gzip routines
Add ROM region, version, and byte ordering verification Patch ROM for extended level table Move BE to Utils file
1 parent 8d6d4b1 commit d6cc476

6 files changed

Lines changed: 347 additions & 100 deletions

File tree

BlastCorpsEditor/BlastCorpsEditor.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@
4747
<Reference Include="System.Xml" />
4848
</ItemGroup>
4949
<ItemGroup>
50+
<Compile Include="Utils.cs" />
5051
<Compile Include="BlastCorpsEditorForm.cs">
5152
<SubType>Form</SubType>
5253
</Compile>
5354
<Compile Include="BlastCorpsEditorForm.Designer.cs">
5455
<DependentUpon>BlastCorpsEditorForm.cs</DependentUpon>
5556
</Compile>
5657
<Compile Include="BlastCorpsLevel.cs" />
58+
<Compile Include="BlastCorpsRom.cs" />
5759
<Compile Include="BlastCorpsViewer.cs">
5860
<SubType>UserControl</SubType>
5961
</Compile>

BlastCorpsEditor/BlastCorpsEditorForm.Designer.cs

Lines changed: 17 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

BlastCorpsEditor/BlastCorpsEditorForm.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,5 +358,22 @@ private void exportToolStripMenuItem_Click(object sender, EventArgs e)
358358
fs.Close();
359359
}
360360
}
361+
362+
private void openROMToolStripMenuItem_Click(object sender, EventArgs e)
363+
{
364+
OpenFileDialog openFileDialog1 = new OpenFileDialog();
365+
366+
openFileDialog1.Filter = "N64 ROM (.z64)|*.z64|All Files (*.*)|*.*";
367+
openFileDialog1.FilterIndex = 1;
368+
369+
DialogResult dresult = openFileDialog1.ShowDialog();
370+
371+
if (dresult == DialogResult.OK)
372+
{
373+
BlastCorpsRom rom = new BlastCorpsRom();
374+
rom.LoadRom(openFileDialog1.FileName);
375+
rom.ExtendRom(Path.Combine(Path.GetTempPath(), "BC.ext.z64"));
376+
}
377+
}
361378
}
362379
}

BlastCorpsEditor/BlastCorpsLevel.cs

Lines changed: 1 addition & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -3,98 +3,6 @@
33

44
namespace BlastCorpsEditor
55
{
6-
// helper class for converting arrays of bytes in big endian to native integer types
7-
class BE
8-
{
9-
public static UInt32 U32(byte[] buf, uint i)
10-
{
11-
byte[] u32bytes = new byte[4];
12-
Array.Copy(buf, i, u32bytes, 0, u32bytes.Length);
13-
if (BitConverter.IsLittleEndian)
14-
{
15-
Array.Reverse(u32bytes);
16-
}
17-
return BitConverter.ToUInt32(u32bytes, 0);
18-
}
19-
20-
public static Int32 I32(byte[] buf, uint i)
21-
{
22-
byte[] i32bytes = new byte[4];
23-
Array.Copy(buf, i, i32bytes, 0, i32bytes.Length);
24-
if (BitConverter.IsLittleEndian)
25-
{
26-
Array.Reverse(i32bytes);
27-
}
28-
return BitConverter.ToInt32(i32bytes, 0);
29-
}
30-
31-
public static UInt16 U16(byte[] buf, uint i)
32-
{
33-
byte[] u16bytes = new byte[2];
34-
Array.Copy(buf, i, u16bytes, 0, u16bytes.Length);
35-
if (BitConverter.IsLittleEndian)
36-
{
37-
Array.Reverse(u16bytes);
38-
}
39-
return BitConverter.ToUInt16(u16bytes, 0);
40-
}
41-
42-
public static Int16 I16(byte[] buf, uint i)
43-
{
44-
byte[] i16bytes = new byte[2];
45-
Array.Copy(buf, i, i16bytes, 0, i16bytes.Length);
46-
if (BitConverter.IsLittleEndian)
47-
{
48-
Array.Reverse(i16bytes);
49-
}
50-
return BitConverter.ToInt16(i16bytes, 0);
51-
}
52-
53-
public static int ToBytes(Int16 val, byte[] buf, int i)
54-
{
55-
byte[] data = BitConverter.GetBytes(val);
56-
if (BitConverter.IsLittleEndian)
57-
{
58-
Array.Reverse(data);
59-
}
60-
Array.Copy(data, 0, buf, i, data.Length);
61-
return data.Length;
62-
}
63-
64-
public static int ToBytes(UInt16 val, byte[] buf, int i)
65-
{
66-
byte[] data = BitConverter.GetBytes(val);
67-
if (BitConverter.IsLittleEndian)
68-
{
69-
Array.Reverse(data);
70-
}
71-
Array.Copy(data, 0, buf, i, data.Length);
72-
return data.Length;
73-
}
74-
75-
public static int ToBytes(Int32 val, byte[] buf, int i)
76-
{
77-
byte[] data = BitConverter.GetBytes(val);
78-
if (BitConverter.IsLittleEndian)
79-
{
80-
Array.Reverse(data);
81-
}
82-
Array.Copy(data, 0, buf, i, data.Length);
83-
return data.Length;
84-
}
85-
86-
public static int ToBytes(UInt32 val, byte[] buf, int i)
87-
{
88-
byte[] data = BitConverter.GetBytes(val);
89-
if (BitConverter.IsLittleEndian)
90-
{
91-
Array.Reverse(data);
92-
}
93-
Array.Copy(data, 0, buf, i, data.Length);
94-
return data.Length;
95-
}
96-
}
97-
986
public class BlastCorpsLevelMeta
997
{
1008
public uint id { get; set; }
@@ -750,7 +658,7 @@ private static int AppendArray(byte[] dest, int offset, byte[] src)
750658

751659
public byte[] ToBytes()
752660
{
753-
// TODO: better estimate of size
661+
// TODO: convert to MemoryStream
754662
byte[] data = new byte[400 * 1024];
755663
int offset = 0x0;
756664

0 commit comments

Comments
 (0)