Skip to content

Commit 580b1f0

Browse files
committed
Add generic debug functions for reporting frame times via OSGetTime and OSReport
1 parent d48bda6 commit 580b1f0

File tree

5 files changed

+61
-0
lines changed

5 files changed

+61
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#pragma once
2+
3+
#include <cstdint>
4+
#include <cstdarg>
5+
6+
namespace gc::OSError {
7+
8+
extern "C" {
9+
10+
void OSReport(const char *msg, ...);
11+
// OSPanic
12+
// OSSetErrorHandler
13+
// __OSUnhandledException
14+
15+
}
16+
17+
}

ttyd-tools/rel/include/ttyd.eu.lst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,12 @@
21552155
// 8029B6EC:__OSContextInit
21562156
8029B734:L_OSFillFPUContext
21572157

2158+
// OSError.c
2159+
8029B860:OSReport
2160+
// 8029B8E0:OSPanic
2161+
// 8029BA0C:OSSetErrorHandler
2162+
// 8029BC24:__OSUnhandledException
2163+
21582164
// OSFont.c
21592165
// 8029C86C:GetFontCode
21602166
// 8029C9E0:Decode

ttyd-tools/rel/include/ttyd.jp.lst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,12 @@
21502150
// 8029189C:__OSContextInit
21512151
802918E4:L_OSFillFPUContext
21522152

2153+
// OSError.c
2154+
80291A10:OSReport
2155+
// 80291A90:OSPanic
2156+
// 80291BBC:OSSetErrorHandler
2157+
// 80291DD4:__OSUnhandledException
2158+
21532159
// OSFont.c
21542160
// 80292A1C:GetFontCode
21552161
// 80292B90:Decode

ttyd-tools/rel/include/ttyd.us.lst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2151,6 +2151,12 @@
21512151
// 802976A0:__OSContextInit
21522152
802976E8:L_OSFillFPUContext
21532153

2154+
// OSError.c
2155+
80297814:OSReport
2156+
// 80297894:OSPanic
2157+
// 802979C0:OSSetErrorHandler
2158+
// 80297BD8:__OSUnhandledException
2159+
21542160
// OSFont.c
21552161
// 80298820:GetFontCode
21562162
// 80298994:Decode

ttyd-tools/rel/source/draw.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "assembly.h"
88
#include "main.h"
99

10+
#include <gc/OSTime.h>
11+
#include <gc/OSError.h>
1012
#include <gc/gx.h>
1113
#include <gc/ppc.h>
1214
#include <gc/OSContext.h>
@@ -300,6 +302,30 @@ void drawText(const char *text, int32_t x, int32_t y, uint8_t alpha, uint32_t co
300302
}
301303
}
302304

305+
int64_t reportCurrentFrameTime(const char *label)
306+
{
307+
int64_t CurrentFrameTime = gc::OSTime::OSGetTime();
308+
309+
gc::OSError::OSReport(
310+
"%s Raw: 0x%016" PRIX64 "\n",
311+
label,
312+
CurrentFrameTime);
313+
314+
return CurrentFrameTime;
315+
}
316+
317+
int64_t reportFrameTimeDifference(const char *label, int64_t startFrameTime, int64_t endFrameTime)
318+
{
319+
int64_t FrameTimeDifference = endFrameTime - startFrameTime;
320+
321+
gc::OSError::OSReport(
322+
"%s Dif: 0x%" PRIX64 "\n",
323+
label,
324+
FrameTimeDifference);
325+
326+
return FrameTimeDifference;
327+
}
328+
303329
uint16_t getMessageWidth(const char *text, float scale)
304330
{
305331
uint16_t LineLength = ttyd::fontmgr::FontGetMessageWidth(text);

0 commit comments

Comments
 (0)