Skip to content

Commit 8b825af

Browse files
committed
dont generate code if profiler guard isn't active
1 parent bf94982 commit 8b825af

File tree

4 files changed

+22
-16
lines changed

4 files changed

+22
-16
lines changed

include/ctr/profiler.h

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

3-
#define REWRITE_PROFILER
3+
//#define REWRITE_PROFILER
44
void LoadProfilerPatches();

rewrite/buildList.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ common, header, 0x8000B0B8, 0x0, src/hooks/dll/load_decomp.c
55
// decomp files
66
common, DLL, 0x80200000, 0x0, src/exe/*.c, DECOMP.BIN
77
common, DLL, 0x80600000, 0x0, src/tests/*.c src/tests/test_wrappers.s, TESTS.BIN
8-
common, DLL, 0x80600000, 0x0, src/tests/*.c, TESTS.BIN
98

109
// profiler files
1110
common, DLL, 0x80500000, 0x0, src/profiler/*.c, PROFILER.BIN

rewrite/src/profiler/benchmark.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// When running OG functions,
66
// dont forget to undefine these in ctr\test.h:
77
// TEST_MATH_IMPL, TEST_RNG_IMPL, TEST_COLL_IMPL
8+
#ifdef REWRITE_PROFILER
89

910
void RunBenchmark()
1011
{
@@ -30,5 +31,7 @@ void RunBenchmark()
3031
{
3132
ND_COLL_ProjectPointToEdge(&out, &v1, &v2, &point);
3233
}
33-
34-
}
34+
35+
}
36+
37+
#endif // REWRITE_PROFILER

rewrite/src/profiler/profiler.c

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <ctr/profiler.h>
22
#include <ctr/nd.h>
33

4+
#ifdef REWRITE_PROFILER
5+
46
// No Vehicle.h
57
struct MetaPhys
68
{
@@ -51,7 +53,7 @@ int Debug_GetPreciseTime()
5153
int sysClock =
5254
ND_GetRCnt(0xf2000001) +
5355
sdata->rcntTotalUnits;
54-
56+
5557
return sysClock;
5658
}
5759

@@ -65,42 +67,44 @@ void Hook_DrawOTag(int a)
6567
if (timeRed == 0)
6668
{
6769
timeStart = Debug_GetPreciseTime();
68-
70+
6971
void RunBenchmark();
7072
RunBenchmark();
71-
73+
7274
timeEnd = Debug_GetPreciseTime();
73-
75+
7476

7577
timeRed = timeEnd - timeStart;
7678
}
77-
79+
7880
struct GameTracker* gGT = sdata->gGT;
79-
81+
8082
if((gGT->gameMode1 & (LOADING|1)) == 0)
8183
{
8284
// reset depth to CLOSEST
8385
gGT->pushBuffer_UI.ptrOT =
8486
gGT->otSwapchainDB[gGT->swapchainIndex];
85-
86-
87+
88+
8789
#ifndef REBUILD_PC
8890
char* string = (char*)0x1f800000;
8991
#else
9092
char string[128];
9193
#endif
92-
94+
9395
ND_sprintf(string, "RED %d", timeRed);
9496
ND_DecalFont_DrawLine(string, 0x14, 0x5C, FONT_SMALL, 0);
9597
}
96-
98+
9799
ND_DrawOTag(a);
98100
}
99101

100102
#define JMP(dest) (((unsigned long)dest & 0x3FFFFFF) >> 2 | 0x8000000)
101103
#define JAL(dest) (((unsigned long)dest & 0x3FFFFFF) >> 2 | 0xC000000)
102104

103105
void LoadProfilerPatches()
104-
{
106+
{
105107
*(int*)0x800379b0 = JAL(Hook_DrawOTag);
106-
}
108+
}
109+
110+
#endif // REWRITE_PROFILER

0 commit comments

Comments
 (0)