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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
#pragma once
#include "endianness.h"
#include "n64/CommandMacros.h"
#include <string>
#include <spdlog/spdlog.h>
#include <spdlog/fmt/ostr.h>
#include <lib/binarytools/BinaryWriter.h>
#include <types/Vec3D.h>
enum class GeoOpcode {
BranchAndLink,
End,
Branch,
Return,
OpenNode,
CloseNode,
AssignAsView,
UpdateNodeFlags,
NodeRoot,
NodeOrthoProjection,
NodePerspective,
NodeStart,
NodeMasterList,
NodeLevelOfDetail,
NodeSwitchCase,
NodeCamera,
NodeTranslationRotation,
NodeTranslation,
NodeRotation,
NodeAnimatedPart,
NodeBillboard,
NodeDisplayList,
NodeShadow,
NodeObjectParent,
NodeAsm,
NodeBackground,
NOP,
CopyView,
NodeHeldObj,
NodeScale,
NOP2,
NOP3,
NodeCullingRadius,
};
inline std::ostream& operator<<(std::ostream& out, const GeoOpcode& opcode) {
std::string output;
switch (opcode) {
case GeoOpcode::BranchAndLink:
output = "GEO_BRANCH_AND_LINK";
break;
case GeoOpcode::End:
output = "GEO_END";
break;
case GeoOpcode::Branch:
output = "GEO_BRANCH";
break;
case GeoOpcode::Return:
output = "GEO_RETURN";
break;
case GeoOpcode::OpenNode:
output = "GEO_OPEN_NODE";
break;
case GeoOpcode::CloseNode:
output = "GEO_CLOSE_NODE";
break;
case GeoOpcode::AssignAsView:
output = "GEO_ASSIGN_AS_VIEW";
break;
case GeoOpcode::UpdateNodeFlags:
output = "GEO_UPDATE_NODE_FLAGS";
break;
case GeoOpcode::NodeRoot:
output = "GEO_NODE_SCREEN_AREA";
break;
case GeoOpcode::NodeOrthoProjection:
output = "GEO_NODE_ORTHO";
break;
case GeoOpcode::NodePerspective:
output = "GEO_CAMERA_FRUSTUM";
break;
case GeoOpcode::NodeStart:
output = "GEO_NODE_START";
break;
case GeoOpcode::NodeMasterList:
output = "GEO_ZBUFFER";
break;
case GeoOpcode::NodeLevelOfDetail:
output = "GEO_RENDER_RANGE";
break;
case GeoOpcode::NodeSwitchCase:
output = "GEO_SWITCH_CASE";
break;
case GeoOpcode::NodeCamera:
output = "GEO_CAMERA";
break;
case GeoOpcode::NodeTranslationRotation:
output = "GEO_TRANSLATE_ROTATE";
break;
case GeoOpcode::NodeTranslation:
output = "GEO_TRANSLATE";
break;
case GeoOpcode::NodeRotation:
output = "GEO_ROTATE";
break;
case GeoOpcode::NodeAnimatedPart:
output = "GEO_ANIMATED_PART";
break;
case GeoOpcode::NodeBillboard:
output = "GEO_BILLBOARD";
break;
case GeoOpcode::NodeDisplayList:
output = "GEO_DISPLAY_LIST";
break;
case GeoOpcode::NodeShadow:
output = "GEO_SHADOW";
break;
case GeoOpcode::NodeObjectParent:
output = "GEO_RENDER_OBJ";
break;
case GeoOpcode::NodeAsm:
output = "GEO_ASM";
break;
case GeoOpcode::NodeBackground:
output = "GEO_BACKGROUND";
break;
case GeoOpcode::NOP:
output = "GEO_NOP_1A";
break;
case GeoOpcode::CopyView:
output = "GEO_COPY_VIEW";
break;
case GeoOpcode::NodeHeldObj:
output = "GEO_HELD_OBJECT";
break;
case GeoOpcode::NodeScale:
output = "GEO_SCALE";
break;
case GeoOpcode::NOP2:
output = "GEO_NOP_1E";
break;
case GeoOpcode::NOP3:
output = "GEO_NOP_1F";
break;
case GeoOpcode::NodeCullingRadius:
output = "GEO_CULLING_RADIUS";
break;
default:
throw std::runtime_error("Unknown Opcode");
}
return out << output;
}
template <>
struct fmt::formatter<GeoOpcode> : fmt::formatter<std::string> {
auto format(const GeoOpcode& opcode, format_context& ctx) const {
std::stringstream ss;
ss << opcode; // This calls your operator<< above
return formatter<std::string>::format(ss.str(), ctx);
}
};
#define cur_geo_cmd_u8(offset) \
(cmd[CMD_PROCESS_OFFSET(offset)])
#define cur_geo_cmd_s16(offset) \
(int16_t)BSWAP16((*(int16_t *) &cmd[CMD_PROCESS_OFFSET(offset)]))
#define cur_geo_cmd_s32(offset) \
(s32)BSWAP32((*(s32 *) &cmd[CMD_PROCESS_OFFSET(offset)]))
#define cur_geo_cmd_u32(offset) \
(uint32_t) BSWAP32((*(uint32_t *) &cmd[CMD_PROCESS_OFFSET(offset)]))
class GeoLayoutCommand {
public:
virtual void Print(std::ostream& out) = 0;
virtual void Write(LUS::BinaryWriter& write) = 0;
};
|