Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
4c17814
add `Import XML (ZAPD)` menu item with Designer
Dragorn421 Aug 1, 2021
5702c62
implement import zapd xml (wip)
Dragorn421 Aug 24, 2021
fe98948
Fix GetDListSize: step 8 bytes per command
Dragorn421 Aug 24, 2021
fee0f19
Import CI textures and map the Tlut TextureHolder
Dragorn421 Aug 24, 2021
ca29f58
Implement `<Limb>` (`Type="Standard"` only)
Dragorn421 Aug 24, 2021
c9fe728
Check LimbType is Standard for skeletons
Dragorn421 Aug 24, 2021
ac52bab
Implement `<Blob>`
Dragorn421 Aug 24, 2021
1fc4830
Implement `<LimbTable>` (untested)
Dragorn421 Aug 24, 2021
bdedeca
Implement `<Array>` of `<Vtx/>`
Dragorn421 Aug 24, 2021
1db6a94
Add `UnimplementedHolder` (mostly like `UnknowHolder`)
Dragorn421 Aug 25, 2021
8b396c2
"implement" skeleton (all types) using LOD limbs with UnimplementedHo…
Dragorn421 Aug 25, 2021
942c74d
"implement" lod limbs with UnimplementedHolder
Dragorn421 Aug 25, 2021
7e4d2d1
Fix Array of Vector typing in UnimplementedHolder description
Dragorn421 Aug 25, 2021
f567f51
Fix `Limb` import, use `LimbType` not `Type`
Dragorn421 Aug 26, 2021
1bee40f
"Implement" Skin Skeleton and Limb (`UnimplementedHolder`)
Dragorn421 Aug 26, 2021
939d695
Revert resx changes made by Visual Studio Designer
Dragorn421 Aug 26, 2021
783cd2b
Implement `Offset` being optional and default to end offset of last-a…
Dragorn421 Aug 29, 2021
fba153b
Use either `Type` or `LimbType` for `<Limb>`
Dragorn421 Aug 29, 2021
0e1d745
Implement `<Mtx>`
Dragorn421 Sep 13, 2021
d8e8463
Merge branch 'dev' into zapdxml2
Dragorn421 Sep 19, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Z64Utils/Common/Filters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static class Filters
public const string N64 = "N64 Rom (*.n64; *.z64)|*.n64;*.z64";
public const string BIN = "Bin Files (*.bin)|*.bin";
public const string JSON = "JSON Files (*.json)|*.json";
public const string XML = "XML Files (*.xml)|*.xml";
public const string C = "C Files (*.c)|*.c";
}
}
21 changes: 21 additions & 0 deletions Z64Utils/F3DZEX/Command/CmdEncoding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,28 @@ public static byte[] EncodeCmds(List<CmdInfo> dlist)
return ms.GetBuffer().Take((int)ms.Length).ToArray();
}
}
public static int GetDListSize(byte[] ucode, int off = 0)
{
int length = 0;
using (MemoryStream ms = new MemoryStream(ucode))
{
ms.Position = off;
while (ms.Position < ms.Length)
{
length += 1;
CmdID id = (CmdID)ms.ReadByte();

if (!DEC_TABLE.ContainsKey(id))
throw new InvalidF3DZEXOpCodeException($"Invalid OpCode : {id:X}");

ms.Seek(7, SeekOrigin.Current);

if (id == CmdID.G_ENDDL)
break;
}
}
return length * 8;
}

public static readonly Dictionary<CmdID, Func<BitReader, CmdInfo>> DEC_TABLE = new Dictionary<CmdID, Func<BitReader, CmdInfo>>()
{
Expand Down
10 changes: 10 additions & 0 deletions Z64Utils/Forms/ObjectAnalyzerForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

60 changes: 58 additions & 2 deletions Z64Utils/Forms/ObjectAnalyzerForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,19 @@ private void UpdateMap()
for (int i = 0; i < _obj.Entries.Count; i++)
{
var entry = _obj.Entries[i];
string type;
if (entry.GetEntryType() == Z64Object.EntryType.Unimplemented)
type = "XXX " + ((Z64Object.UnimplementedHolder)entry).Description;
else
type = entry.GetEntryType().ToString();
string addrStr = $"{new SegmentedAddress(_segment, _obj.OffsetOf(entry)).VAddr:X8}";
string entryStr = $"{addrStr}{entry.Name}{entry.GetEntryType()}".ToLower();
string entryStr = $"{addrStr}{entry.Name}{type}".ToLower();

if (entryStr.Contains(compare))
{
var item = listView_map.Items.Add(addrStr);
item.SubItems.Add(entry.Name);
item.SubItems.Add(entry.GetEntryType().ToString());
item.SubItems.Add(type);
item.Tag = i;
}
}
Expand Down Expand Up @@ -346,6 +351,13 @@ private void listView_map_SelectedIndexChanged(object sender, EventArgs e)
SelectTabPage(tabPage_unknow);
break;
}
case Z64Object.EntryType.Unimplemented:
{
string description = ((Z64Object.UnimplementedHolder)holder).Description;
// todo show description
SelectTabPage(tabPage_unknow);
break;
}
default: SelectTabPage(tabPage_empty); break;
}

Expand Down Expand Up @@ -540,6 +552,7 @@ private void exportCToolStripMenuItem_Click(object sender, EventArgs e)
break;
}
case Z64Object.EntryType.Unknown:
case Z64Object.EntryType.Unimplemented:
{
sw.WriteLine($"u8 {entry.Name}[] = \r\n{{");

Expand Down Expand Up @@ -620,6 +633,49 @@ private void exportCToolStripMenuItem_Click(object sender, EventArgs e)
}
}

private void importXMLZAPDToolStripMenuItem_Click(object sender, EventArgs e)
{
openFileDialog1.FileName = "";
openFileDialog1.Filter = $"{Filters.XML}|{Filters.ALL}";
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string xml = File.ReadAllText(openFileDialog1.FileName);
StringWriter warnings = new StringWriter();
Z64Object newObj = null;

try
{
// todo allow the user to provide fileName somehow
newObj = Z64Object.FromXmlZAPD(xml, _data, warnings);
}
catch (FileFormatException ex)
{
warnings.WriteLine();
warnings.WriteLine("The XML is not a ZAPD-compatible XML file:");
warnings.WriteLine(ex.Message);
}
catch (NotImplementedException ex)
{
warnings.WriteLine();
warnings.WriteLine("The XML uses features that aren't implemented yet:");
warnings.WriteLine(ex.Message);
}

string warningsStr = warnings.ToString();
if (warningsStr.Length != 0)
{
TextForm form = new TextForm(SystemIcons.Warning, "Warning", warningsStr);
form.ShowDialog();
}

if (newObj != null)
{
_obj = newObj;
UpdateMap();
}
}
}

private void textBox_filter_TextChanged(object sender, EventArgs e)
{
UpdateMap();
Expand Down
Loading