Skip to content

Commit 4b3261d

Browse files
committed
Implemented a function for drawing on the debug layer with a specified order
Currently applying this to the heap errors, as they need to be readable when displayed with other things.
1 parent 98b1ac5 commit 4b3261d

File tree

5 files changed

+23
-2
lines changed

5 files changed

+23
-2
lines changed

ttyd-tools/rel/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ MACHDEP = -mno-sdata -mgcn -DGEKKO -mcpu=750 -meabi -mhard-float
5454
CFLAGS = -nostdlib -ffreestanding -ffunction-sections -fdata-sections -g -Os -Wall -Werror $(MACHDEP) $(INCLUDE)
5555
CXXFLAGS = -fno-exceptions -fno-rtti -std=gnu++17 $(CFLAGS)
5656

57-
FUNCWRAPS = -Wl,--wrap,sprintf -Wl,--wrap,strcmp -Wl,--wrap,strncmp -Wl,--wrap,strcpy -Wl,--wrap,strncpy -Wl,--wrap,strcat -Wl,--wrap,strlen -Wl,--wrap,memcpy -Wl,--wrap,memset -Wl,--wrap,sysMsec2Frame -Wl,--wrap,keyGetButton -Wl,--wrap,keyGetButtonTrg -Wl,--wrap,seqGetSeq -Wl,--wrap,seqGetNextSeq -Wl,--wrap,swByteGet -Wl,--wrap,swByteSet -Wl,--wrap,swClear -Wl,--wrap,swSet -Wl,--wrap,marioStGetSystemLevel -Wl,--wrap,marioStSystemLevel -Wl,--wrap,marioGetPartyId -Wl,--wrap,marioGetExtraPartyId -Wl,--wrap,marioGetPtr -Wl,--wrap,partyGetPtr -Wl,--wrap,pouchGetPtr -Wl,--wrap,btlGetScreenPoint -Wl,--wrap,evtGetWork -Wl,--wrap,eventStgNum -Wl,--wrap,eventStgDtPtr -Wl,--wrap,winGetPtr -Wl,--wrap,winOpenEnable -Wl,--wrap,CARDClose -Wl,--wrap,DCFlushRange -Wl,--wrap,ICInvalidateRange -Wl,--wrap,__udivdi3 -Wl,--wrap,__umoddi3
57+
FUNCWRAPS = -Wl,--wrap,sprintf -Wl,--wrap,strcmp -Wl,--wrap,strncmp -Wl,--wrap,strcpy -Wl,--wrap,strncpy -Wl,--wrap,strcat -Wl,--wrap,strlen -Wl,--wrap,memcpy -Wl,--wrap,memset -Wl,--wrap,sysMsec2Frame -Wl,--wrap,keyGetButton -Wl,--wrap,keyGetButtonTrg -Wl,--wrap,seqGetSeq -Wl,--wrap,seqGetNextSeq -Wl,--wrap,swByteGet -Wl,--wrap,swByteSet -Wl,--wrap,swClear -Wl,--wrap,swSet -Wl,--wrap,marioStGetSystemLevel -Wl,--wrap,marioStSystemLevel -Wl,--wrap,marioGetPartyId -Wl,--wrap,marioGetExtraPartyId -Wl,--wrap,marioGetPtr -Wl,--wrap,partyGetPtr -Wl,--wrap,pouchGetPtr -Wl,--wrap,btlGetScreenPoint -Wl,--wrap,evtGetWork -Wl,--wrap,eventStgNum -Wl,--wrap,eventStgDtPtr -Wl,--wrap,winGetPtr -Wl,--wrap,winOpenEnable -Wl,--wrap,CARDClose -Wl,--wrap,DCFlushRange -Wl,--wrap,ICInvalidateRange -Wl,--wrap,__udivdi3 -Wl,--wrap,__umoddi3 -Wl,--wrap,dispEntry
5858

5959
LDFLAGS = -r -e _prolog -u _prolog -u _epilog -u _unresolved -Wl,--gc-sections -nostdlib -g $(MACHDEP) -Wl,-Map,$(notdir $@).map $(FUNCWRAPS)
6060

ttyd-tools/rel/include/draw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace mod {
66

77
void drawFunctionOnDebugLayer(void (*func)());
8+
void drawFunctionOnDebugLayerWithOrder(void (*func)(), float order);
89
void drawFunctionOn2DLayer(void (*func)());
910

1011
void drawMenuWindow();

ttyd-tools/rel/source/draw.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ void drawFunctionOnDebugLayer(void (*func)())
5959
}, reinterpret_cast<void *>(func));
6060
}
6161

62+
void drawFunctionOnDebugLayerWithOrder(void (*func)(), float order)
63+
{
64+
ttyd::dispdrv::dispEntry(ttyd::dispdrv::CameraId::kDebug3d, 2, order,
65+
[](ttyd::dispdrv::CameraId cameraId, void *user)
66+
{
67+
reinterpret_cast<void (*)()>(user)();
68+
}, reinterpret_cast<void *>(func));
69+
}
70+
6271
void drawFunctionOn2DLayer(void (*func)())
6372
{
6473
ttyd::dispdrv::dispEntry(ttyd::dispdrv::CameraId::k2d, 2, 0.f,

ttyd-tools/rel/source/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ void checkHeaps()
629629
// Draw any errors that occured
630630
if (HeapBuffer[0] != '\0')
631631
{
632-
drawFunctionOnDebugLayer(drawHeapArrayErrors);
632+
drawFunctionOnDebugLayerWithOrder(drawHeapArrayErrors, 100.f);
633633
}
634634
}
635635

ttyd-tools/rel/source/wrappers.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <ttyd/mario.h>
55
#include <ttyd/evtmgr.h>
66
#include <ttyd/event.h>
7+
#include <ttyd/dispdrv.h>
78

89
#include <cstdint>
910
#include <cstdio>
@@ -49,6 +50,9 @@ extern "C"
4950
uint64_t __real___udivdi3(uint64_t a, uint64_t b);
5051
uint64_t __real___umoddi3(uint64_t a, uint64_t b);
5152

53+
void __real_dispEntry(ttyd::dispdrv::CameraId cameraId, uint8_t renderMode,
54+
float order, ttyd::dispdrv::PFN_dispCallback callback, void *user);
55+
5256
// Wrap functions
5357
// sprintf
5458
__attribute__((noinline)) int32_t __wrap_sprintf(char *buffer, const char *format, ...)
@@ -269,4 +273,11 @@ extern "C"
269273
{
270274
return __real___umoddi3(a, b);
271275
}
276+
277+
// dispEntry
278+
__attribute__((noinline)) void __wrap_dispEntry(ttyd::dispdrv::CameraId cameraId,
279+
uint8_t renderMode, float order, ttyd::dispdrv::PFN_dispCallback callback, void *user)
280+
{
281+
__real_dispEntry(cameraId, renderMode, order, callback, user);
282+
}
272283
}

0 commit comments

Comments
 (0)