blob: d75bc8dea60839c87a6d9dbaf2561d2d64ac5343 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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);
}
}
}
|