Skip to content

Commit af2589f

Browse files
committed
fixes for Niko's profiler
1 parent 360b6bb commit af2589f

File tree

4 files changed

+34
-23
lines changed

4 files changed

+34
-23
lines changed

include/ctr/coll.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ typedef enum BarycentricTest
2323
BARYCENTRIC_TEST_INSIDE_TRIANGLE = 6,
2424
} BarycentricTest;
2525

26+
typedef enum CollFlags
27+
{
28+
COLLFLAGS_TEST_INSTANCES = 0x1,
29+
COLLFLAGS_HIGH_LOD_QUAD = 0x2,
30+
COLLFLAGS_CACHED_HIGH_LOD_VERTICES = 0x8,
31+
} CollFlags;
32+
2633
typedef struct CollVertex
2734
{
2835
SVec3 pos;
@@ -48,9 +55,8 @@ typedef struct DriverQuadblockCollData
4855
s32 driverHitRadiusSquared;
4956
SVec3 driverNextPos;
5057
u16 collFlags;
51-
u16 searchFlags;
52-
s16 unk0;
53-
u32 skipCollNoQuadFlagsMatch;
58+
u32 quadFlagsCheckColl;
59+
u32 quadFlagsIgnoreColl;
5460
} DriverQuadblockCollData;
5561

5662
typedef union CollInputData
@@ -97,7 +103,7 @@ typedef struct CollDCache
97103
u8 lodShift;
98104
} CollDCache;
99105

100-
#define DCACHE_COLL (*(CollDCache*) 0x1f800000)
106+
#define DCACHE_COLL (*(CollDCache*) 0x1f800108)
101107

102108
void COLL_ProjectPointToEdge(SVec3* out, const SVec3* v1, const SVec3* v2, const SVec3* point);
103109
void COLL_LoadQuadblockData_LowLOD(CollDCache* cache, Quadblock* quadblock);

include/ctr/profiler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
22

3-
#define REWRITE_PROFILER
3+
//#define REWRITE_PROFILER
44

55
void LoadProfilerPatches();

include/ctr/test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ force_inline void FlushCache()
2626

2727
//#define TEST_MATH_IMPL
2828
//#define TEST_RNG_IMPL
29-
//#define TEST_COLL_IMPL
29+
#define TEST_COLL_IMPL
3030

3131
#ifdef TEST_MATH_IMPL
3232
void TEST_MATH_Sin(u32 angle, s32 ret);

rewrite/src/profiler/profiler.c

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11

22
#include <ctr/profiler.h>
3+
4+
#ifdef REWRITE_PROFILER
5+
36
#include <ctr/nd.h>
47
#include <ctr/test.h>
58

@@ -56,17 +59,17 @@ struct GameTracker_Local
5659

5760
// 0x18
5861
struct DB db[2]; /* packet double buffer */
59-
62+
6063
// 0x160
6164
char buf[0x1768];
62-
65+
6366
// pointers to OT memory,
6467
// used in ClearOTagR
6568
// 0x18c8
6669
// 0x18cc
6770
// one for each DB
6871
void* otSwapchainDB[2];
69-
72+
7073
};
7174

7275
void DrawResults()
@@ -88,9 +91,9 @@ void DrawResults()
8891
// 0x100 - midpoint, 0x800 - center
8992
ND_sprintf(string, "%s %s", __DATE__, __TIME__);
9093
ND_DecalFont_DrawLine(string, 0x100, 0x8, 2, 0x8000);
91-
94+
9295
int numTest = sizeof(tests) / sizeof(struct BenchTest);
93-
96+
9497
for(int i = 0; i < numTest; i++)
9598
{
9699
ND_sprintf(string, "%s %d", &tests[i].name[8], tests[i].val);
@@ -103,37 +106,37 @@ int testIndex=0;
103106
void RunTest()
104107
{
105108
int numTest = sizeof(tests) / sizeof(struct BenchTest);
106-
109+
107110
int timer = *(int*)(0x80096b20+0x1cec);
108-
111+
109112
// In between each test, run 15 frames
110113
if((timer & 0xF) != 0xF)
111114
return;
112-
115+
113116
if(testIndex < numTest)
114117
{
115118
// Stop XA
116119
void ND_CDSYS_XAPauseForce();
117120
ND_CDSYS_XAPauseForce();
118-
121+
119122
// From Spyro 2 Demo Launcher
120123
void ND_Music_Stop();
121124
void ND_howl_StopAudio(int a, int b, int c);
122125
void ND_Bank_DestroyAll();
123126
void ND_howl_Disable();
124-
127+
125128
// From Spyro 2 Demo Launcher
126129
ND_Music_Stop();
127130
ND_howl_StopAudio(1,1,1);
128131
ND_Bank_DestroyAll();
129132
ND_howl_Disable();
130-
133+
131134
ND_EnterCriticalSection();
132135
ND_ResetRCnt(0xf2000001);
133136
tests[testIndex].funcPtr();
134137
tests[testIndex].val = ND_GetRCnt(0xf2000001);
135138
ND_ExitCriticalSection();
136-
139+
137140
testIndex++;
138141
}
139142
}
@@ -142,7 +145,7 @@ void Hook_DrawOTag(int a)
142145
{
143146
DrawResults();
144147
ND_DrawOTag(a);
145-
148+
146149
// Run first test AFTER first DrawOTag,
147150
// so it does not take forever for screen to refresh,
148151
// Therefore, always run a test after DrawOTag
@@ -153,15 +156,17 @@ void LoadProfilerPatches()
153156
{
154157
#define JAL(dest) (((unsigned long)dest & 0x3FFFFFF) >> 2 | 0xC000000)
155158
*(int*)0x800379b0 = JAL(Hook_DrawOTag);
156-
159+
157160
// JR RA so main menu never loads
158161
*(int*)0x8003cfc0 = 0x3E00008;
159162
*(int*)0x8003cfc4 = 0;
160-
163+
161164
// JR RA so RaceFlag does not drawpoly
162165
*(int*)0x800444e8 = 0x3E00008;
163166
*(int*)0x800444ec = 0;
164-
167+
165168
// skip XA on boot "Start Your Engines..."
166169
*(int*)0x8003c958 = 0;
167-
}
170+
}
171+
172+
#endif

0 commit comments

Comments
 (0)