Skip to content

Commit 87b0252

Browse files
committed
porting data types
1 parent efd95da commit 87b0252

File tree

5 files changed

+170
-9
lines changed

5 files changed

+170
-9
lines changed

include/ctr/coll.h

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,67 @@ typedef struct TestVertex
4141
SVec3 interpolationPoint;
4242
} TestVertex;
4343

44+
typedef struct DriverQuadblockCollData
45+
{
46+
SVec3 driverPos;
47+
s16 driverHitRadius;
48+
s32 driverHitRadiusSquared;
49+
SVec3 driverNextPos;
50+
u16 collFlags;
51+
u16 searchFlags;
52+
s16 unk0;
53+
u32 skipCollNoQuadFlagsMatch;
54+
} DriverQuadblockCollData;
55+
56+
typedef union CollInputData
57+
{
58+
DriverQuadblockCollData quadblock;
59+
} CollInputData;
60+
61+
typedef struct CollDCache
62+
{
63+
SVec3 inputNextPos;
64+
s16 inputHitRadius;
65+
s32 inputHitRadiusSquared;
66+
s16 unk0;
67+
s16 unk1;
68+
CollInputData collInput;
69+
MeshInfo* meshInfo;
70+
BoundingBox bbox;
71+
s16 numVerticesTested;
72+
s16 numTrianglesTouched;
73+
s16 unk2;
74+
s16 numInstancesCollided;
75+
u32 unk3;
76+
BSPNode* bspNodes;
77+
TestVertex collIntersection;
78+
u8 unk4;
79+
u8 currTriangleIndex;
80+
Quadblock* currQuadblock;
81+
SVec3 collPos;
82+
u16 normalDominantAxis_TriCollided;
83+
SVec3 normalTriCollided;
84+
s16 unk5;
85+
SVec3 interpolationPoint;
86+
u8 barycentricTest;
87+
u8 collidedTriangleIndex;
88+
Quadblock* collidedQuadblock;
89+
s32 speedScale;
90+
u8 unk6[0x44];
91+
Vertex* collidedVertices[NUM_VERTICES_TRIANGLE];
92+
CollVertex* currTestVertices[NUM_VERTICES_TRIANGLE];
93+
SVec3 distInterpolationIntersection;
94+
s16 unk7;
95+
u16 quadblockThirdIndex;
96+
u16 quadblockFouthIndex;
97+
CollVertex quadblockCollVertices[NUM_VERTICES_QUADBLOCK];
98+
u32 stepFlags;
99+
s16 normalScale;
100+
u8 normalBitshift;
101+
u8 lodShift;
102+
} CollDCache;
103+
104+
#define DCACHE_COLL (*(CollDCache*) 0x1f800000)
105+
44106
void COLL_ProjectPointToEdge(SVec3* out, const SVec3* v1, const SVec3* v2, const SVec3* point);
45107
s32 COLL_BarycentricTest(TestVertex* t, const CollVertex* v1, const CollVertex* v2, const CollVertex* v3);

include/ctr/lev.h

Lines changed: 93 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
#include <ctr/macros.h>
44
#include <ctr/math.h>
5+
#include <ctr/prim.h>
6+
7+
#define NUM_VERTICES_QUADBLOCK 9
8+
#define NUM_VERTICES_TRIANGLE 3
59

610
typedef union Color
711
{
@@ -15,10 +19,98 @@ typedef union Color
1519
u32 color;
1620
} Color;
1721

22+
typedef struct TextureLayout
23+
{
24+
UV uv0;
25+
CLUT clut;
26+
UV uv1;
27+
PolyTexpage texpage;
28+
UV uv2;
29+
UV uv3;
30+
} TextureLayout;
31+
32+
typedef struct TextureGroup
33+
{
34+
TextureLayout far;
35+
TextureLayout middle;
36+
TextureLayout near;
37+
TextureLayout mosaic;
38+
} TextureGroup;
39+
1840
typedef struct Vertex
1941
{
2042
SVec3 pos;
2143
u16 flags;
2244
Color colorHi;
2345
Color colorLo;
24-
} Vertex;
46+
} Vertex;
47+
48+
typedef struct VisibleSet
49+
{
50+
u32* visibleBSPNodes;
51+
u32* visibleQuadblocks;
52+
u32* visibleInstances;
53+
u32* visibleExtra;
54+
} VisibleSet;
55+
56+
typedef struct Quadblock
57+
{
58+
u16 index[NUM_VERTICES_QUADBLOCK]; // 0x0
59+
u16 flags; // 0x12
60+
u32 drawOrderLow; // 0x14
61+
u32 drawOrderHigh; // 0x18
62+
u32 offMidTextures[4]; // 0x1C
63+
BoundingBox bbox; // 0x2C
64+
u8 terrain; // 0x38
65+
u8 weatherIntensity; // 0x39
66+
u8 weatherVanishRate; // 0x3A
67+
s8 speedImpact; // 0x3B
68+
u16 id; // 0x3C
69+
u8 checkpointIndex; // 0x3E
70+
u8 triNormalVecBitshift; // 0x3F
71+
u32 offLowTexture; // 0x40
72+
VisibleSet visibleSet; // 0x44
73+
u16 triNormalVecDividend[NUM_VERTICES_QUADBLOCK + 1]; // 0x48
74+
} Quadblock;
75+
76+
typedef struct BSPBranch
77+
{
78+
u16 flags; // 0x0
79+
u16 id; // 0x2
80+
BoundingBox bbox; // 0x4
81+
SVec3 axis; // 0x10
82+
u16 likelyPadding; // 0x16
83+
u16 leftChildID; // 0x18
84+
u16 rightChildID; // 0x1A
85+
u16 unk1; // 0x1C
86+
u16 unk2; // 0x1E
87+
} BSPBranch;
88+
89+
typedef struct BSPLeaf
90+
{
91+
u16 flags; // 0x0
92+
u16 id; // 0x2
93+
BoundingBox bbox; // 0x4
94+
u32 likelyPadding; // 0x10
95+
u32 offHitbox; // 0x14
96+
u32 numQuads; // 0x18
97+
Quadblock* quadblocks; // 0x1C
98+
} BSPLeaf;
99+
100+
typedef union BSPNode
101+
{
102+
BSPBranch branch;
103+
BSPLeaf leaf;
104+
} BSPNode;
105+
106+
typedef struct MeshInfo
107+
{
108+
u32 numQuadblocks; // 0x0
109+
u32 numVertices; // 0x4
110+
u32 unk1; // 0x8
111+
Quadblock* quadblocks; // 0xC
112+
Vertex* vertices; // 0x10
113+
u32 unk2; // 0x14
114+
BSPNode* bspNodes; // 0x18
115+
u32 numBSPNodes; // 0x1C
116+
} MeshInfo;

include/ctr/math.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,18 @@ typedef union Vec4
6969
s32 v[4];
7070
} Vec4;
7171

72-
typedef struct Matrix {
72+
typedef struct Matrix
73+
{
7374
s16 m[3][3];
7475
Vec3 t;
7576
} Matrix;
7677

78+
typedef struct BoundingBox
79+
{
80+
SVec3 min;
81+
SVec3 max;
82+
} BoundingBox;
83+
7784
typedef struct TrigTable
7885
{
7986
s16 sin;

include/ctr/prim.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
#include <ctr/macros.h>
44

5-
enum VertexCount
5+
typedef enum VertexCount
66
{
77
VertexCount_Point = 1,
88
VertexCount_Line = 2,
99
VertexCount_Tri = 3,
1010
VertexCount_Quad = 4,
11-
};
11+
} VertexCount;
1212

1313
typedef union Tag
1414
{
@@ -41,18 +41,18 @@ typedef union Texpage
4141
u32 self;
4242
} Texpage;
4343

44-
typedef struct
44+
typedef struct TPage
4545
{
4646
Tag tag;
4747
Texpage texpage;
4848
} TPage;
4949

50-
enum RenderCode
50+
typedef enum RenderCode
5151
{
5252
RenderCode_Polygon = 1,
5353
RenderCode_Line = 2,
5454
RenderCode_Rectangle = 3,
55-
};
55+
} RenderCode;
5656

5757
typedef union PrimCode
5858
{
@@ -100,8 +100,6 @@ typedef union ColorCode
100100
u32 self;
101101
} ColorCode;
102102

103-
typedef ColorCode Color;
104-
105103
#define MakeColorCode(red, green, blue, renderCode) (ColorCode) { .r = red, .g = green, .b = blue, .code = renderCode }
106104
#define MakeColor(red, green, blue) (Color) { .r = red, .g = green, .b = blue }
107105

rewrite/src/exe/coll.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ void COLL_ProjectPointToEdge(SVec3* out, const SVec3* v1, const SVec3* v2, const
3737
out->z = coords.z;
3838
TEST_COLL_ProjectPointToEdge(v1, v2, point, out);
3939
#ifdef TEST_COLL_IMPL
40+
/* This is a hand written assembly function that breaks the ABI,
41+
and some callers expect the argument registers to be untouched*/
4042
__asm__ volatile("move $a0, %0" : : "r"((u32)out));
4143
__asm__ volatile("move $a1, %0" : : "r"((u32)v1));
4244
__asm__ volatile("move $a2, %0" : : "r"((u32)v2));

0 commit comments

Comments
 (0)