diff options
author | Treeki <treeki@gmail.com> | 2011-03-08 05:17:56 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-03-08 05:17:56 +0100 |
commit | 7d391e33a0b3d9793c95fce832abb2c6d9002186 (patch) | |
tree | 075f8ec6272ad3ea12be44a8c2083f89b0d55228 /NW4RTools/DisplayListWriter.cs | |
parent | e962fd89af865d6e01522e9752f5fbd855ce128a (diff) | |
download | nw4rtools-7d391e33a0b3d9793c95fce832abb2c6d9002186.tar.gz nw4rtools-7d391e33a0b3d9793c95fce832abb2c6d9002186.zip |
late night commit! obj importer is basic but working. also, tidied up DL stuff
Diffstat (limited to '')
-rw-r--r-- | NW4RTools/DisplayListWriter.cs | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/NW4RTools/DisplayListWriter.cs b/NW4RTools/DisplayListWriter.cs new file mode 100644 index 0000000..d75bc8d --- /dev/null +++ b/NW4RTools/DisplayListWriter.cs @@ -0,0 +1,83 @@ +using System; +namespace NW4RTools { + public class DisplayListWriter : OutputStream { + public DisplayListWriter() : base(ByteEndian.BigEndian) { + } + + + public void End() { + AlignTo(0x20); + } + + + public void Nop() { + WriteByte(0); + } + + public void LoadBPReg(UInt32 value) { + WriteByte((byte)GXCommand.LoadBPReg); + WriteUInt32(value); + } + + public void LoadCPReg(byte command, UInt32 value) { + WriteByte((byte)GXCommand.LoadCPReg); + WriteByte(command); + WriteUInt32(value); + } + + public void LoadXFReg(ushort address, byte[] data) { + if ((data.Length & 3) != 0) { + throw new ArgumentException("Data length passed to LoadXFReg() is not aligned to 4 bytes", "data"); + } + + if (data.Length < 4 || data.Length > 0x44) { + throw new ArgumentException("Data length passed to LoadXFReg() must be at least 4 bytes and at most 0x44 bytes", "data"); + } + + WriteByte((byte)GXCommand.LoadXFReg); + WriteByte(0); + WriteByte((byte)((data.Length / 4) - 1)); + WriteUInt16(address); + WriteBytes(data); + } + + public void LoadPosMtxFromArray(uint number) { + WriteByte((byte)GXCommand.LoadPosMtxFromArray); + WriteUInt32(number); + } + + public void LoadNrmMtxFromArray(uint number) { + WriteByte((byte)GXCommand.LoadNrmMtxFromArray); + WriteUInt32(number); + } + + public void LoadTexCoordMtxFromArray(uint number) { + WriteByte((byte)GXCommand.LoadTexCoordMtxFromArray); + WriteUInt32(number); + } + + public void LoadLightFromArray(uint number) { + WriteByte((byte)GXCommand.LoadLightFromArray); + WriteUInt32(number); + } + + public void CallDisplayList(uint pointer, uint size) { + WriteByte((byte)GXCommand.CallDL); + WriteUInt32(pointer); + WriteUInt32(size); + } + + public void UnknownMetrics() { + WriteByte((byte)GXCommand.UnknownMetrics); + } + + public void BeginPrimitives(PrimitiveType type, int vatIndex, ushort vtxCount) { + byte command = (byte)GXCommand.DrawPrimitiveMask; + command |= (byte)((byte)type << (byte)GXCommand.PrimitiveShiftAmount); + command |= (byte)vatIndex; + WriteByte(command); + WriteUInt16(vtxCount); + } + } +} + |